babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415
  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. * Width of the texture to apply the post process on
  13626. */
  13627. width: number;
  13628. /**
  13629. * Height of the texture to apply the post process on
  13630. */
  13631. height: number;
  13632. /**
  13633. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13634. * @hidden
  13635. */
  13636. _outputTexture: Nullable<InternalTexture>;
  13637. /**
  13638. * Sampling mode used by the shader
  13639. * See https://doc.babylonjs.com/classes/3.1/texture
  13640. */
  13641. renderTargetSamplingMode: number;
  13642. /**
  13643. * Clear color to use when screen clearing
  13644. */
  13645. clearColor: Color4;
  13646. /**
  13647. * If the buffer needs to be cleared before applying the post process. (default: true)
  13648. * Should be set to false if shader will overwrite all previous pixels.
  13649. */
  13650. autoClear: boolean;
  13651. /**
  13652. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13653. */
  13654. alphaMode: number;
  13655. /**
  13656. * Sets the setAlphaBlendConstants of the babylon engine
  13657. */
  13658. alphaConstants: Color4;
  13659. /**
  13660. * Animations to be used for the post processing
  13661. */
  13662. animations: import("babylonjs/Animations/animation").Animation[];
  13663. /**
  13664. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13665. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13666. */
  13667. enablePixelPerfectMode: boolean;
  13668. /**
  13669. * Force the postprocess to be applied without taking in account viewport
  13670. */
  13671. forceFullscreenViewport: boolean;
  13672. /**
  13673. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13674. *
  13675. * | Value | Type | Description |
  13676. * | ----- | ----------------------------------- | ----------- |
  13677. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13678. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13679. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13680. *
  13681. */
  13682. scaleMode: number;
  13683. /**
  13684. * Force textures to be a power of two (default: false)
  13685. */
  13686. alwaysForcePOT: boolean;
  13687. private _samples;
  13688. /**
  13689. * Number of sample textures (default: 1)
  13690. */
  13691. samples: number;
  13692. /**
  13693. * Modify the scale of the post process to be the same as the viewport (default: false)
  13694. */
  13695. adaptScaleToCurrentViewport: boolean;
  13696. private _camera;
  13697. private _scene;
  13698. private _engine;
  13699. private _options;
  13700. private _reusable;
  13701. private _textureType;
  13702. /**
  13703. * Smart array of input and output textures for the post process.
  13704. * @hidden
  13705. */
  13706. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13707. /**
  13708. * The index in _textures that corresponds to the output texture.
  13709. * @hidden
  13710. */
  13711. _currentRenderTextureInd: number;
  13712. private _effect;
  13713. private _samplers;
  13714. private _fragmentUrl;
  13715. private _vertexUrl;
  13716. private _parameters;
  13717. private _scaleRatio;
  13718. protected _indexParameters: any;
  13719. private _shareOutputWithPostProcess;
  13720. private _texelSize;
  13721. private _forcedOutputTexture;
  13722. /**
  13723. * Returns the fragment url or shader name used in the post process.
  13724. * @returns the fragment url or name in the shader store.
  13725. */
  13726. getEffectName(): string;
  13727. /**
  13728. * An event triggered when the postprocess is activated.
  13729. */
  13730. onActivateObservable: Observable<Camera>;
  13731. private _onActivateObserver;
  13732. /**
  13733. * A function that is added to the onActivateObservable
  13734. */
  13735. onActivate: Nullable<(camera: Camera) => void>;
  13736. /**
  13737. * An event triggered when the postprocess changes its size.
  13738. */
  13739. onSizeChangedObservable: Observable<PostProcess>;
  13740. private _onSizeChangedObserver;
  13741. /**
  13742. * A function that is added to the onSizeChangedObservable
  13743. */
  13744. onSizeChanged: (postProcess: PostProcess) => void;
  13745. /**
  13746. * An event triggered when the postprocess applies its effect.
  13747. */
  13748. onApplyObservable: Observable<Effect>;
  13749. private _onApplyObserver;
  13750. /**
  13751. * A function that is added to the onApplyObservable
  13752. */
  13753. onApply: (effect: Effect) => void;
  13754. /**
  13755. * An event triggered before rendering the postprocess
  13756. */
  13757. onBeforeRenderObservable: Observable<Effect>;
  13758. private _onBeforeRenderObserver;
  13759. /**
  13760. * A function that is added to the onBeforeRenderObservable
  13761. */
  13762. onBeforeRender: (effect: Effect) => void;
  13763. /**
  13764. * An event triggered after rendering the postprocess
  13765. */
  13766. onAfterRenderObservable: Observable<Effect>;
  13767. private _onAfterRenderObserver;
  13768. /**
  13769. * A function that is added to the onAfterRenderObservable
  13770. */
  13771. onAfterRender: (efect: Effect) => void;
  13772. /**
  13773. * 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
  13774. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13775. */
  13776. inputTexture: InternalTexture;
  13777. /**
  13778. * Gets the camera which post process is applied to.
  13779. * @returns The camera the post process is applied to.
  13780. */
  13781. getCamera(): Camera;
  13782. /**
  13783. * Gets the texel size of the postprocess.
  13784. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13785. */
  13786. readonly texelSize: Vector2;
  13787. /**
  13788. * Creates a new instance PostProcess
  13789. * @param name The name of the PostProcess.
  13790. * @param fragmentUrl The url of the fragment shader to be used.
  13791. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13792. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13793. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13794. * @param camera The camera to apply the render pass to.
  13795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13796. * @param engine The engine which the post process will be applied. (default: current engine)
  13797. * @param reusable If the post process can be reused on the same frame. (default: false)
  13798. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13799. * @param textureType Type of textures used when performing the post process. (default: 0)
  13800. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13801. * @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
  13802. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13803. */
  13804. constructor(
  13805. /** Name of the PostProcess. */
  13806. 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);
  13807. /**
  13808. * Gets the engine which this post process belongs to.
  13809. * @returns The engine the post process was enabled with.
  13810. */
  13811. getEngine(): Engine;
  13812. /**
  13813. * The effect that is created when initializing the post process.
  13814. * @returns The created effect corrisponding the the postprocess.
  13815. */
  13816. getEffect(): Effect;
  13817. /**
  13818. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13819. * @param postProcess The post process to share the output with.
  13820. * @returns This post process.
  13821. */
  13822. shareOutputWith(postProcess: PostProcess): PostProcess;
  13823. /**
  13824. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13825. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13826. */
  13827. useOwnOutput(): void;
  13828. /**
  13829. * Updates the effect with the current post process compile time values and recompiles the shader.
  13830. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13831. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13832. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13833. * @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
  13834. * @param onCompiled Called when the shader has been compiled.
  13835. * @param onError Called if there is an error when compiling a shader.
  13836. */
  13837. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13838. /**
  13839. * The post process is reusable if it can be used multiple times within one frame.
  13840. * @returns If the post process is reusable
  13841. */
  13842. isReusable(): boolean;
  13843. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13844. markTextureDirty(): void;
  13845. /**
  13846. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13847. * 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.
  13848. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13849. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13850. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13851. * @returns The target texture that was bound to be written to.
  13852. */
  13853. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13854. /**
  13855. * If the post process is supported.
  13856. */
  13857. readonly isSupported: boolean;
  13858. /**
  13859. * The aspect ratio of the output texture.
  13860. */
  13861. readonly aspectRatio: number;
  13862. /**
  13863. * Get a value indicating if the post-process is ready to be used
  13864. * @returns true if the post-process is ready (shader is compiled)
  13865. */
  13866. isReady(): boolean;
  13867. /**
  13868. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13869. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13870. */
  13871. apply(): Nullable<Effect>;
  13872. private _disposeTextures;
  13873. /**
  13874. * Disposes the post process.
  13875. * @param camera The camera to dispose the post process on.
  13876. */
  13877. dispose(camera?: Camera): void;
  13878. }
  13879. }
  13880. declare module "babylonjs/PostProcesses/postProcessManager" {
  13881. import { Nullable } from "babylonjs/types";
  13882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13883. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13884. import { Scene } from "babylonjs/scene";
  13885. /**
  13886. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13887. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13888. */
  13889. export class PostProcessManager {
  13890. private _scene;
  13891. private _indexBuffer;
  13892. private _vertexBuffers;
  13893. /**
  13894. * Creates a new instance PostProcess
  13895. * @param scene The scene that the post process is associated with.
  13896. */
  13897. constructor(scene: Scene);
  13898. private _prepareBuffers;
  13899. private _buildIndexBuffer;
  13900. /**
  13901. * Rebuilds the vertex buffers of the manager.
  13902. * @hidden
  13903. */
  13904. _rebuild(): void;
  13905. /**
  13906. * Prepares a frame to be run through a post process.
  13907. * @param sourceTexture The input texture to the post procesess. (default: null)
  13908. * @param postProcesses An array of post processes to be run. (default: null)
  13909. * @returns True if the post processes were able to be run.
  13910. * @hidden
  13911. */
  13912. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13913. /**
  13914. * Manually render a set of post processes to a texture.
  13915. * @param postProcesses An array of post processes to be run.
  13916. * @param targetTexture The target texture to render to.
  13917. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13918. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13919. * @param lodLevel defines which lod of the texture to render to
  13920. */
  13921. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13922. /**
  13923. * Finalize the result of the output of the postprocesses.
  13924. * @param doNotPresent If true the result will not be displayed to the screen.
  13925. * @param targetTexture The target texture to render to.
  13926. * @param faceIndex The index of the face to bind the target texture to.
  13927. * @param postProcesses The array of post processes to render.
  13928. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13929. * @hidden
  13930. */
  13931. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13932. /**
  13933. * Disposes of the post process manager.
  13934. */
  13935. dispose(): void;
  13936. }
  13937. }
  13938. declare module "babylonjs/Materials/Textures/rawTexture" {
  13939. import { Scene } from "babylonjs/scene";
  13940. import { Texture } from "babylonjs/Materials/Textures/texture";
  13941. /**
  13942. * Raw texture can help creating a texture directly from an array of data.
  13943. * This can be super useful if you either get the data from an uncompressed source or
  13944. * if you wish to create your texture pixel by pixel.
  13945. */
  13946. export class RawTexture extends Texture {
  13947. /**
  13948. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13949. */
  13950. format: number;
  13951. private _engine;
  13952. /**
  13953. * Instantiates a new RawTexture.
  13954. * Raw texture can help creating a texture directly from an array of data.
  13955. * This can be super useful if you either get the data from an uncompressed source or
  13956. * if you wish to create your texture pixel by pixel.
  13957. * @param data define the array of data to use to create the texture
  13958. * @param width define the width of the texture
  13959. * @param height define the height of the texture
  13960. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13961. * @param scene define the scene the texture belongs to
  13962. * @param generateMipMaps define whether mip maps should be generated or not
  13963. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13964. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13965. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13966. */
  13967. constructor(data: ArrayBufferView, width: number, height: number,
  13968. /**
  13969. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13970. */
  13971. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13972. /**
  13973. * Updates the texture underlying data.
  13974. * @param data Define the new data of the texture
  13975. */
  13976. update(data: ArrayBufferView): void;
  13977. /**
  13978. * Creates a luminance texture from some data.
  13979. * @param data Define the texture data
  13980. * @param width Define the width of the texture
  13981. * @param height Define the height of the texture
  13982. * @param scene Define the scene the texture belongs to
  13983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13986. * @returns the luminance texture
  13987. */
  13988. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13989. /**
  13990. * Creates a luminance alpha texture from some data.
  13991. * @param data Define the texture data
  13992. * @param width Define the width of the texture
  13993. * @param height Define the height of the texture
  13994. * @param scene Define the scene the texture belongs to
  13995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13998. * @returns the luminance alpha texture
  13999. */
  14000. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14001. /**
  14002. * Creates an alpha texture from some data.
  14003. * @param data Define the texture data
  14004. * @param width Define the width of the texture
  14005. * @param height Define the height of the texture
  14006. * @param scene Define the scene the texture belongs to
  14007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14010. * @returns the alpha texture
  14011. */
  14012. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14013. /**
  14014. * Creates a RGB texture from some data.
  14015. * @param data Define the texture data
  14016. * @param width Define the width of the texture
  14017. * @param height Define the height of the texture
  14018. * @param scene Define the scene the texture belongs to
  14019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14023. * @returns the RGB alpha texture
  14024. */
  14025. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14026. /**
  14027. * Creates a RGBA texture from some data.
  14028. * @param data Define the texture data
  14029. * @param width Define the width of the texture
  14030. * @param height Define the height of the texture
  14031. * @param scene Define the scene the texture belongs to
  14032. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14033. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14034. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14035. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14036. * @returns the RGBA texture
  14037. */
  14038. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14039. /**
  14040. * Creates a R texture from some data.
  14041. * @param data Define the texture data
  14042. * @param width Define the width of the texture
  14043. * @param height Define the height of the texture
  14044. * @param scene Define the scene the texture belongs to
  14045. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14046. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14047. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14048. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14049. * @returns the R texture
  14050. */
  14051. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14052. }
  14053. }
  14054. declare module "babylonjs/Layers/layerSceneComponent" {
  14055. import { Scene } from "babylonjs/scene";
  14056. import { ISceneComponent } from "babylonjs/sceneComponent";
  14057. import { Layer } from "babylonjs/Layers/layer";
  14058. module "babylonjs/abstractScene" {
  14059. interface AbstractScene {
  14060. /**
  14061. * The list of layers (background and foreground) of the scene
  14062. */
  14063. layers: Array<Layer>;
  14064. }
  14065. }
  14066. /**
  14067. * Defines the layer scene component responsible to manage any layers
  14068. * in a given scene.
  14069. */
  14070. export class LayerSceneComponent implements ISceneComponent {
  14071. /**
  14072. * The component name helpfull to identify the component in the list of scene components.
  14073. */
  14074. readonly name: string;
  14075. /**
  14076. * The scene the component belongs to.
  14077. */
  14078. scene: Scene;
  14079. private _engine;
  14080. /**
  14081. * Creates a new instance of the component for the given scene
  14082. * @param scene Defines the scene to register the component in
  14083. */
  14084. constructor(scene: Scene);
  14085. /**
  14086. * Registers the component in a given scene
  14087. */
  14088. register(): void;
  14089. /**
  14090. * Rebuilds the elements related to this component in case of
  14091. * context lost for instance.
  14092. */
  14093. rebuild(): void;
  14094. /**
  14095. * Disposes the component and the associated ressources.
  14096. */
  14097. dispose(): void;
  14098. private _draw;
  14099. private _drawCameraPredicate;
  14100. private _drawCameraBackground;
  14101. private _drawCameraForeground;
  14102. private _drawRenderTargetPredicate;
  14103. private _drawRenderTargetBackground;
  14104. private _drawRenderTargetForeground;
  14105. }
  14106. }
  14107. declare module "babylonjs/Shaders/layer.fragment" {
  14108. /** @hidden */
  14109. export var layerPixelShader: {
  14110. name: string;
  14111. shader: string;
  14112. };
  14113. }
  14114. declare module "babylonjs/Shaders/layer.vertex" {
  14115. /** @hidden */
  14116. export var layerVertexShader: {
  14117. name: string;
  14118. shader: string;
  14119. };
  14120. }
  14121. declare module "babylonjs/Layers/layer" {
  14122. import { Observable } from "babylonjs/Misc/observable";
  14123. import { Nullable } from "babylonjs/types";
  14124. import { Scene } from "babylonjs/scene";
  14125. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14126. import { Texture } from "babylonjs/Materials/Textures/texture";
  14127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14128. import "babylonjs/Shaders/layer.fragment";
  14129. import "babylonjs/Shaders/layer.vertex";
  14130. /**
  14131. * This represents a full screen 2d layer.
  14132. * This can be useful to display a picture in the background of your scene for instance.
  14133. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14134. */
  14135. export class Layer {
  14136. /**
  14137. * Define the name of the layer.
  14138. */
  14139. name: string;
  14140. /**
  14141. * Define the texture the layer should display.
  14142. */
  14143. texture: Nullable<Texture>;
  14144. /**
  14145. * Is the layer in background or foreground.
  14146. */
  14147. isBackground: boolean;
  14148. /**
  14149. * Define the color of the layer (instead of texture).
  14150. */
  14151. color: Color4;
  14152. /**
  14153. * Define the scale of the layer in order to zoom in out of the texture.
  14154. */
  14155. scale: Vector2;
  14156. /**
  14157. * Define an offset for the layer in order to shift the texture.
  14158. */
  14159. offset: Vector2;
  14160. /**
  14161. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14162. */
  14163. alphaBlendingMode: number;
  14164. /**
  14165. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14166. * Alpha test will not mix with the background color in case of transparency.
  14167. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14168. */
  14169. alphaTest: boolean;
  14170. /**
  14171. * Define a mask to restrict the layer to only some of the scene cameras.
  14172. */
  14173. layerMask: number;
  14174. /**
  14175. * Define the list of render target the layer is visible into.
  14176. */
  14177. renderTargetTextures: RenderTargetTexture[];
  14178. /**
  14179. * Define if the layer is only used in renderTarget or if it also
  14180. * renders in the main frame buffer of the canvas.
  14181. */
  14182. renderOnlyInRenderTargetTextures: boolean;
  14183. private _scene;
  14184. private _vertexBuffers;
  14185. private _indexBuffer;
  14186. private _effect;
  14187. private _alphaTestEffect;
  14188. /**
  14189. * An event triggered when the layer is disposed.
  14190. */
  14191. onDisposeObservable: Observable<Layer>;
  14192. private _onDisposeObserver;
  14193. /**
  14194. * Back compatibility with callback before the onDisposeObservable existed.
  14195. * The set callback will be triggered when the layer has been disposed.
  14196. */
  14197. onDispose: () => void;
  14198. /**
  14199. * An event triggered before rendering the scene
  14200. */
  14201. onBeforeRenderObservable: Observable<Layer>;
  14202. private _onBeforeRenderObserver;
  14203. /**
  14204. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14205. * The set callback will be triggered just before rendering the layer.
  14206. */
  14207. onBeforeRender: () => void;
  14208. /**
  14209. * An event triggered after rendering the scene
  14210. */
  14211. onAfterRenderObservable: Observable<Layer>;
  14212. private _onAfterRenderObserver;
  14213. /**
  14214. * Back compatibility with callback before the onAfterRenderObservable existed.
  14215. * The set callback will be triggered just after rendering the layer.
  14216. */
  14217. onAfterRender: () => void;
  14218. /**
  14219. * Instantiates a new layer.
  14220. * This represents a full screen 2d layer.
  14221. * This can be useful to display a picture in the background of your scene for instance.
  14222. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14223. * @param name Define the name of the layer in the scene
  14224. * @param imgUrl Define the url of the texture to display in the layer
  14225. * @param scene Define the scene the layer belongs to
  14226. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14227. * @param color Defines a color for the layer
  14228. */
  14229. constructor(
  14230. /**
  14231. * Define the name of the layer.
  14232. */
  14233. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14234. private _createIndexBuffer;
  14235. /** @hidden */
  14236. _rebuild(): void;
  14237. /**
  14238. * Renders the layer in the scene.
  14239. */
  14240. render(): void;
  14241. /**
  14242. * Disposes and releases the associated ressources.
  14243. */
  14244. dispose(): void;
  14245. }
  14246. }
  14247. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14248. import { Scene } from "babylonjs/scene";
  14249. import { ISceneComponent } from "babylonjs/sceneComponent";
  14250. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14251. module "babylonjs/abstractScene" {
  14252. interface AbstractScene {
  14253. /**
  14254. * The list of procedural textures added to the scene
  14255. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14256. */
  14257. proceduralTextures: Array<ProceduralTexture>;
  14258. }
  14259. }
  14260. /**
  14261. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14262. * in a given scene.
  14263. */
  14264. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14265. /**
  14266. * The component name helpfull to identify the component in the list of scene components.
  14267. */
  14268. readonly name: string;
  14269. /**
  14270. * The scene the component belongs to.
  14271. */
  14272. scene: Scene;
  14273. /**
  14274. * Creates a new instance of the component for the given scene
  14275. * @param scene Defines the scene to register the component in
  14276. */
  14277. constructor(scene: Scene);
  14278. /**
  14279. * Registers the component in a given scene
  14280. */
  14281. register(): void;
  14282. /**
  14283. * Rebuilds the elements related to this component in case of
  14284. * context lost for instance.
  14285. */
  14286. rebuild(): void;
  14287. /**
  14288. * Disposes the component and the associated ressources.
  14289. */
  14290. dispose(): void;
  14291. private _beforeClear;
  14292. }
  14293. }
  14294. declare module "babylonjs/Shaders/procedural.vertex" {
  14295. /** @hidden */
  14296. export var proceduralVertexShader: {
  14297. name: string;
  14298. shader: string;
  14299. };
  14300. }
  14301. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14302. import { Observable } from "babylonjs/Misc/observable";
  14303. import { Nullable } from "babylonjs/types";
  14304. import { Scene } from "babylonjs/scene";
  14305. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14306. import { Effect } from "babylonjs/Materials/effect";
  14307. import { Texture } from "babylonjs/Materials/Textures/texture";
  14308. import "babylonjs/Shaders/procedural.vertex";
  14309. /**
  14310. * 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.
  14311. * This is the base class of any Procedural texture and contains most of the shareable code.
  14312. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14313. */
  14314. export class ProceduralTexture extends Texture {
  14315. isCube: boolean;
  14316. /**
  14317. * Define if the texture is enabled or not (disabled texture will not render)
  14318. */
  14319. isEnabled: boolean;
  14320. /**
  14321. * Define if the texture must be cleared before rendering (default is true)
  14322. */
  14323. autoClear: boolean;
  14324. /**
  14325. * Callback called when the texture is generated
  14326. */
  14327. onGenerated: () => void;
  14328. /**
  14329. * Event raised when the texture is generated
  14330. */
  14331. onGeneratedObservable: Observable<ProceduralTexture>;
  14332. /** @hidden */
  14333. _generateMipMaps: boolean;
  14334. /** @hidden **/
  14335. _effect: Effect;
  14336. /** @hidden */
  14337. _textures: {
  14338. [key: string]: Texture;
  14339. };
  14340. private _size;
  14341. private _currentRefreshId;
  14342. private _refreshRate;
  14343. private _vertexBuffers;
  14344. private _indexBuffer;
  14345. private _uniforms;
  14346. private _samplers;
  14347. private _fragment;
  14348. private _floats;
  14349. private _ints;
  14350. private _floatsArrays;
  14351. private _colors3;
  14352. private _colors4;
  14353. private _vectors2;
  14354. private _vectors3;
  14355. private _matrices;
  14356. private _fallbackTexture;
  14357. private _fallbackTextureUsed;
  14358. private _engine;
  14359. private _cachedDefines;
  14360. private _contentUpdateId;
  14361. private _contentData;
  14362. /**
  14363. * Instantiates a new procedural texture.
  14364. * 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.
  14365. * This is the base class of any Procedural texture and contains most of the shareable code.
  14366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14367. * @param name Define the name of the texture
  14368. * @param size Define the size of the texture to create
  14369. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14370. * @param scene Define the scene the texture belongs to
  14371. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14372. * @param generateMipMaps Define if the texture should creates mip maps or not
  14373. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14374. */
  14375. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14376. /**
  14377. * The effect that is created when initializing the post process.
  14378. * @returns The created effect corrisponding the the postprocess.
  14379. */
  14380. getEffect(): Effect;
  14381. /**
  14382. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14383. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14384. */
  14385. getContent(): Nullable<ArrayBufferView>;
  14386. private _createIndexBuffer;
  14387. /** @hidden */
  14388. _rebuild(): void;
  14389. /**
  14390. * Resets the texture in order to recreate its associated resources.
  14391. * This can be called in case of context loss
  14392. */
  14393. reset(): void;
  14394. protected _getDefines(): string;
  14395. /**
  14396. * Is the texture ready to be used ? (rendered at least once)
  14397. * @returns true if ready, otherwise, false.
  14398. */
  14399. isReady(): boolean;
  14400. /**
  14401. * Resets the refresh counter of the texture and start bak from scratch.
  14402. * Could be useful to regenerate the texture if it is setup to render only once.
  14403. */
  14404. resetRefreshCounter(): void;
  14405. /**
  14406. * Set the fragment shader to use in order to render the texture.
  14407. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14408. */
  14409. setFragment(fragment: any): void;
  14410. /**
  14411. * Define the refresh rate of the texture or the rendering frequency.
  14412. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14413. */
  14414. refreshRate: number;
  14415. /** @hidden */
  14416. _shouldRender(): boolean;
  14417. /**
  14418. * Get the size the texture is rendering at.
  14419. * @returns the size (texture is always squared)
  14420. */
  14421. getRenderSize(): number;
  14422. /**
  14423. * Resize the texture to new value.
  14424. * @param size Define the new size the texture should have
  14425. * @param generateMipMaps Define whether the new texture should create mip maps
  14426. */
  14427. resize(size: number, generateMipMaps: boolean): void;
  14428. private _checkUniform;
  14429. /**
  14430. * Set a texture in the shader program used to render.
  14431. * @param name Define the name of the uniform samplers as defined in the shader
  14432. * @param texture Define the texture to bind to this sampler
  14433. * @return the texture itself allowing "fluent" like uniform updates
  14434. */
  14435. setTexture(name: string, texture: Texture): ProceduralTexture;
  14436. /**
  14437. * Set a float in the shader.
  14438. * @param name Define the name of the uniform as defined in the shader
  14439. * @param value Define the value to give to the uniform
  14440. * @return the texture itself allowing "fluent" like uniform updates
  14441. */
  14442. setFloat(name: string, value: number): ProceduralTexture;
  14443. /**
  14444. * Set a int in the shader.
  14445. * @param name Define the name of the uniform as defined in the shader
  14446. * @param value Define the value to give to the uniform
  14447. * @return the texture itself allowing "fluent" like uniform updates
  14448. */
  14449. setInt(name: string, value: number): ProceduralTexture;
  14450. /**
  14451. * Set an array of floats in the shader.
  14452. * @param name Define the name of the uniform as defined in the shader
  14453. * @param value Define the value to give to the uniform
  14454. * @return the texture itself allowing "fluent" like uniform updates
  14455. */
  14456. setFloats(name: string, value: number[]): ProceduralTexture;
  14457. /**
  14458. * Set a vec3 in the shader from a Color3.
  14459. * @param name Define the name of the uniform as defined in the shader
  14460. * @param value Define the value to give to the uniform
  14461. * @return the texture itself allowing "fluent" like uniform updates
  14462. */
  14463. setColor3(name: string, value: Color3): ProceduralTexture;
  14464. /**
  14465. * Set a vec4 in the shader from a Color4.
  14466. * @param name Define the name of the uniform as defined in the shader
  14467. * @param value Define the value to give to the uniform
  14468. * @return the texture itself allowing "fluent" like uniform updates
  14469. */
  14470. setColor4(name: string, value: Color4): ProceduralTexture;
  14471. /**
  14472. * Set a vec2 in the shader from a Vector2.
  14473. * @param name Define the name of the uniform as defined in the shader
  14474. * @param value Define the value to give to the uniform
  14475. * @return the texture itself allowing "fluent" like uniform updates
  14476. */
  14477. setVector2(name: string, value: Vector2): ProceduralTexture;
  14478. /**
  14479. * Set a vec3 in the shader from a Vector3.
  14480. * @param name Define the name of the uniform as defined in the shader
  14481. * @param value Define the value to give to the uniform
  14482. * @return the texture itself allowing "fluent" like uniform updates
  14483. */
  14484. setVector3(name: string, value: Vector3): ProceduralTexture;
  14485. /**
  14486. * Set a mat4 in the shader from a MAtrix.
  14487. * @param name Define the name of the uniform as defined in the shader
  14488. * @param value Define the value to give to the uniform
  14489. * @return the texture itself allowing "fluent" like uniform updates
  14490. */
  14491. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14492. /**
  14493. * Render the texture to its associated render target.
  14494. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14495. */
  14496. render(useCameraPostProcess?: boolean): void;
  14497. /**
  14498. * Clone the texture.
  14499. * @returns the cloned texture
  14500. */
  14501. clone(): ProceduralTexture;
  14502. /**
  14503. * Dispose the texture and release its asoociated resources.
  14504. */
  14505. dispose(): void;
  14506. }
  14507. }
  14508. declare module "babylonjs/Particles/baseParticleSystem" {
  14509. import { Nullable } from "babylonjs/types";
  14510. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14512. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14513. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14514. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14515. import { Scene } from "babylonjs/scene";
  14516. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14517. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14518. import { Texture } from "babylonjs/Materials/Textures/texture";
  14519. import { Animation } from "babylonjs/Animations/animation";
  14520. /**
  14521. * This represents the base class for particle system in Babylon.
  14522. * 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.
  14523. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14524. * @example https://doc.babylonjs.com/babylon101/particles
  14525. */
  14526. export class BaseParticleSystem {
  14527. /**
  14528. * Source color is added to the destination color without alpha affecting the result
  14529. */
  14530. static BLENDMODE_ONEONE: number;
  14531. /**
  14532. * Blend current color and particle color using particle’s alpha
  14533. */
  14534. static BLENDMODE_STANDARD: number;
  14535. /**
  14536. * Add current color and particle color multiplied by particle’s alpha
  14537. */
  14538. static BLENDMODE_ADD: number;
  14539. /**
  14540. * Multiply current color with particle color
  14541. */
  14542. static BLENDMODE_MULTIPLY: number;
  14543. /**
  14544. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14545. */
  14546. static BLENDMODE_MULTIPLYADD: number;
  14547. /**
  14548. * List of animations used by the particle system.
  14549. */
  14550. animations: Animation[];
  14551. /**
  14552. * The id of the Particle system.
  14553. */
  14554. id: string;
  14555. /**
  14556. * The friendly name of the Particle system.
  14557. */
  14558. name: string;
  14559. /**
  14560. * The rendering group used by the Particle system to chose when to render.
  14561. */
  14562. renderingGroupId: number;
  14563. /**
  14564. * The emitter represents the Mesh or position we are attaching the particle system to.
  14565. */
  14566. emitter: Nullable<AbstractMesh | Vector3>;
  14567. /**
  14568. * The maximum number of particles to emit per frame
  14569. */
  14570. emitRate: number;
  14571. /**
  14572. * If you want to launch only a few particles at once, that can be done, as well.
  14573. */
  14574. manualEmitCount: number;
  14575. /**
  14576. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14577. */
  14578. updateSpeed: number;
  14579. /**
  14580. * The amount of time the particle system is running (depends of the overall update speed).
  14581. */
  14582. targetStopDuration: number;
  14583. /**
  14584. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14585. */
  14586. disposeOnStop: boolean;
  14587. /**
  14588. * Minimum power of emitting particles.
  14589. */
  14590. minEmitPower: number;
  14591. /**
  14592. * Maximum power of emitting particles.
  14593. */
  14594. maxEmitPower: number;
  14595. /**
  14596. * Minimum life time of emitting particles.
  14597. */
  14598. minLifeTime: number;
  14599. /**
  14600. * Maximum life time of emitting particles.
  14601. */
  14602. maxLifeTime: number;
  14603. /**
  14604. * Minimum Size of emitting particles.
  14605. */
  14606. minSize: number;
  14607. /**
  14608. * Maximum Size of emitting particles.
  14609. */
  14610. maxSize: number;
  14611. /**
  14612. * Minimum scale of emitting particles on X axis.
  14613. */
  14614. minScaleX: number;
  14615. /**
  14616. * Maximum scale of emitting particles on X axis.
  14617. */
  14618. maxScaleX: number;
  14619. /**
  14620. * Minimum scale of emitting particles on Y axis.
  14621. */
  14622. minScaleY: number;
  14623. /**
  14624. * Maximum scale of emitting particles on Y axis.
  14625. */
  14626. maxScaleY: number;
  14627. /**
  14628. * Gets or sets the minimal initial rotation in radians.
  14629. */
  14630. minInitialRotation: number;
  14631. /**
  14632. * Gets or sets the maximal initial rotation in radians.
  14633. */
  14634. maxInitialRotation: number;
  14635. /**
  14636. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14637. */
  14638. minAngularSpeed: number;
  14639. /**
  14640. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14641. */
  14642. maxAngularSpeed: number;
  14643. /**
  14644. * The texture used to render each particle. (this can be a spritesheet)
  14645. */
  14646. particleTexture: Nullable<Texture>;
  14647. /**
  14648. * The layer mask we are rendering the particles through.
  14649. */
  14650. layerMask: number;
  14651. /**
  14652. * This can help using your own shader to render the particle system.
  14653. * The according effect will be created
  14654. */
  14655. customShader: any;
  14656. /**
  14657. * By default particle system starts as soon as they are created. This prevents the
  14658. * automatic start to happen and let you decide when to start emitting particles.
  14659. */
  14660. preventAutoStart: boolean;
  14661. private _noiseTexture;
  14662. /**
  14663. * Gets or sets a texture used to add random noise to particle positions
  14664. */
  14665. noiseTexture: Nullable<ProceduralTexture>;
  14666. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14667. noiseStrength: Vector3;
  14668. /**
  14669. * Callback triggered when the particle animation is ending.
  14670. */
  14671. onAnimationEnd: Nullable<() => void>;
  14672. /**
  14673. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14674. */
  14675. blendMode: number;
  14676. /**
  14677. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14678. * to override the particles.
  14679. */
  14680. forceDepthWrite: boolean;
  14681. /** 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 */
  14682. preWarmCycles: number;
  14683. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14684. preWarmStepOffset: number;
  14685. /**
  14686. * 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)
  14687. */
  14688. spriteCellChangeSpeed: number;
  14689. /**
  14690. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14691. */
  14692. startSpriteCellID: number;
  14693. /**
  14694. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14695. */
  14696. endSpriteCellID: number;
  14697. /**
  14698. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14699. */
  14700. spriteCellWidth: number;
  14701. /**
  14702. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14703. */
  14704. spriteCellHeight: number;
  14705. /**
  14706. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14707. */
  14708. spriteRandomStartCell: boolean;
  14709. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14710. translationPivot: Vector2;
  14711. /** @hidden */
  14712. protected _isAnimationSheetEnabled: boolean;
  14713. /**
  14714. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14715. */
  14716. beginAnimationOnStart: boolean;
  14717. /**
  14718. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14719. */
  14720. beginAnimationFrom: number;
  14721. /**
  14722. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14723. */
  14724. beginAnimationTo: number;
  14725. /**
  14726. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14727. */
  14728. beginAnimationLoop: boolean;
  14729. /**
  14730. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14731. */
  14732. isAnimationSheetEnabled: boolean;
  14733. /**
  14734. * Get hosting scene
  14735. * @returns the scene
  14736. */
  14737. getScene(): Scene;
  14738. /**
  14739. * You can use gravity if you want to give an orientation to your particles.
  14740. */
  14741. gravity: Vector3;
  14742. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14743. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14744. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14745. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14746. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14747. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14748. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14749. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14750. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14751. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14752. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14753. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14754. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14755. /**
  14756. * Defines the delay in milliseconds before starting the system (0 by default)
  14757. */
  14758. startDelay: number;
  14759. /**
  14760. * Gets the current list of drag gradients.
  14761. * You must use addDragGradient and removeDragGradient to udpate this list
  14762. * @returns the list of drag gradients
  14763. */
  14764. getDragGradients(): Nullable<Array<FactorGradient>>;
  14765. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14766. limitVelocityDamping: number;
  14767. /**
  14768. * Gets the current list of limit velocity gradients.
  14769. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14770. * @returns the list of limit velocity gradients
  14771. */
  14772. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14773. /**
  14774. * Gets the current list of color gradients.
  14775. * You must use addColorGradient and removeColorGradient to udpate this list
  14776. * @returns the list of color gradients
  14777. */
  14778. getColorGradients(): Nullable<Array<ColorGradient>>;
  14779. /**
  14780. * Gets the current list of size gradients.
  14781. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14782. * @returns the list of size gradients
  14783. */
  14784. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14785. /**
  14786. * Gets the current list of color remap gradients.
  14787. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14788. * @returns the list of color remap gradients
  14789. */
  14790. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14791. /**
  14792. * Gets the current list of alpha remap gradients.
  14793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14794. * @returns the list of alpha remap gradients
  14795. */
  14796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14797. /**
  14798. * Gets the current list of life time gradients.
  14799. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14800. * @returns the list of life time gradients
  14801. */
  14802. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14803. /**
  14804. * Gets the current list of angular speed gradients.
  14805. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14806. * @returns the list of angular speed gradients
  14807. */
  14808. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14809. /**
  14810. * Gets the current list of velocity gradients.
  14811. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14812. * @returns the list of velocity gradients
  14813. */
  14814. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14815. /**
  14816. * Gets the current list of start size gradients.
  14817. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14818. * @returns the list of start size gradients
  14819. */
  14820. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14821. /**
  14822. * Gets the current list of emit rate gradients.
  14823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14824. * @returns the list of emit rate gradients
  14825. */
  14826. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14827. /**
  14828. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14829. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14830. */
  14831. direction1: Vector3;
  14832. /**
  14833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14834. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14835. */
  14836. direction2: Vector3;
  14837. /**
  14838. * 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.
  14839. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14840. */
  14841. minEmitBox: Vector3;
  14842. /**
  14843. * 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.
  14844. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14845. */
  14846. maxEmitBox: Vector3;
  14847. /**
  14848. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14849. */
  14850. color1: Color4;
  14851. /**
  14852. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14853. */
  14854. color2: Color4;
  14855. /**
  14856. * Color the particle will have at the end of its lifetime
  14857. */
  14858. colorDead: Color4;
  14859. /**
  14860. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14861. */
  14862. textureMask: Color4;
  14863. /**
  14864. * The particle emitter type defines the emitter used by the particle system.
  14865. * It can be for example box, sphere, or cone...
  14866. */
  14867. particleEmitterType: IParticleEmitterType;
  14868. /** @hidden */
  14869. _isSubEmitter: boolean;
  14870. /**
  14871. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14872. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14873. */
  14874. billboardMode: number;
  14875. protected _isBillboardBased: boolean;
  14876. /**
  14877. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14878. */
  14879. isBillboardBased: boolean;
  14880. /**
  14881. * The scene the particle system belongs to.
  14882. */
  14883. protected _scene: Scene;
  14884. /**
  14885. * Local cache of defines for image processing.
  14886. */
  14887. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14888. /**
  14889. * Default configuration related to image processing available in the standard Material.
  14890. */
  14891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14892. /**
  14893. * Gets the image processing configuration used either in this material.
  14894. */
  14895. /**
  14896. * Sets the Default image processing configuration used either in the this material.
  14897. *
  14898. * If sets to null, the scene one is in use.
  14899. */
  14900. imageProcessingConfiguration: ImageProcessingConfiguration;
  14901. /**
  14902. * Attaches a new image processing configuration to the Standard Material.
  14903. * @param configuration
  14904. */
  14905. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14906. /** @hidden */
  14907. protected _reset(): void;
  14908. /** @hidden */
  14909. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14910. /**
  14911. * Instantiates a particle system.
  14912. * 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.
  14913. * @param name The name of the particle system
  14914. */
  14915. constructor(name: string);
  14916. /**
  14917. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14920. * @returns the emitter
  14921. */
  14922. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14923. /**
  14924. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14925. * @param radius The radius of the hemisphere to emit from
  14926. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14927. * @returns the emitter
  14928. */
  14929. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14930. /**
  14931. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14932. * @param radius The radius of the sphere to emit from
  14933. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14934. * @returns the emitter
  14935. */
  14936. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14937. /**
  14938. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14939. * @param radius The radius of the sphere to emit from
  14940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14942. * @returns the emitter
  14943. */
  14944. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14945. /**
  14946. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14947. * @param radius The radius of the emission cylinder
  14948. * @param height The height of the emission cylinder
  14949. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14950. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14951. * @returns the emitter
  14952. */
  14953. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14954. /**
  14955. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14956. * @param radius The radius of the cylinder to emit from
  14957. * @param height The height of the emission cylinder
  14958. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14961. * @returns the emitter
  14962. */
  14963. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14964. /**
  14965. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14966. * @param radius The radius of the cone to emit from
  14967. * @param angle The base angle of the cone
  14968. * @returns the emitter
  14969. */
  14970. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14971. /**
  14972. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14975. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14976. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14977. * @returns the emitter
  14978. */
  14979. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14980. }
  14981. }
  14982. declare module "babylonjs/Particles/subEmitter" {
  14983. import { Scene } from "babylonjs/scene";
  14984. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14985. /**
  14986. * Type of sub emitter
  14987. */
  14988. export enum SubEmitterType {
  14989. /**
  14990. * Attached to the particle over it's lifetime
  14991. */
  14992. ATTACHED = 0,
  14993. /**
  14994. * Created when the particle dies
  14995. */
  14996. END = 1
  14997. }
  14998. /**
  14999. * Sub emitter class used to emit particles from an existing particle
  15000. */
  15001. export class SubEmitter {
  15002. /**
  15003. * the particle system to be used by the sub emitter
  15004. */
  15005. particleSystem: ParticleSystem;
  15006. /**
  15007. * Type of the submitter (Default: END)
  15008. */
  15009. type: SubEmitterType;
  15010. /**
  15011. * 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)
  15012. * Note: This only is supported when using an emitter of type Mesh
  15013. */
  15014. inheritDirection: boolean;
  15015. /**
  15016. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15017. */
  15018. inheritedVelocityAmount: number;
  15019. /**
  15020. * Creates a sub emitter
  15021. * @param particleSystem the particle system to be used by the sub emitter
  15022. */
  15023. constructor(
  15024. /**
  15025. * the particle system to be used by the sub emitter
  15026. */
  15027. particleSystem: ParticleSystem);
  15028. /**
  15029. * Clones the sub emitter
  15030. * @returns the cloned sub emitter
  15031. */
  15032. clone(): SubEmitter;
  15033. /**
  15034. * Serialize current object to a JSON object
  15035. * @returns the serialized object
  15036. */
  15037. serialize(): any;
  15038. /** @hidden */
  15039. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15040. /**
  15041. * Creates a new SubEmitter from a serialized JSON version
  15042. * @param serializationObject defines the JSON object to read from
  15043. * @param scene defines the hosting scene
  15044. * @param rootUrl defines the rootUrl for data loading
  15045. * @returns a new SubEmitter
  15046. */
  15047. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15048. /** Release associated resources */
  15049. dispose(): void;
  15050. }
  15051. }
  15052. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15053. /** @hidden */
  15054. export var clipPlaneFragmentDeclaration: {
  15055. name: string;
  15056. shader: string;
  15057. };
  15058. }
  15059. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15060. /** @hidden */
  15061. export var imageProcessingDeclaration: {
  15062. name: string;
  15063. shader: string;
  15064. };
  15065. }
  15066. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15067. /** @hidden */
  15068. export var imageProcessingFunctions: {
  15069. name: string;
  15070. shader: string;
  15071. };
  15072. }
  15073. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15074. /** @hidden */
  15075. export var clipPlaneFragment: {
  15076. name: string;
  15077. shader: string;
  15078. };
  15079. }
  15080. declare module "babylonjs/Shaders/particles.fragment" {
  15081. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15082. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15083. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15084. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15086. /** @hidden */
  15087. export var particlesPixelShader: {
  15088. name: string;
  15089. shader: string;
  15090. };
  15091. }
  15092. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15093. /** @hidden */
  15094. export var clipPlaneVertexDeclaration: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15100. /** @hidden */
  15101. export var clipPlaneVertex: {
  15102. name: string;
  15103. shader: string;
  15104. };
  15105. }
  15106. declare module "babylonjs/Shaders/particles.vertex" {
  15107. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15108. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15109. /** @hidden */
  15110. export var particlesVertexShader: {
  15111. name: string;
  15112. shader: string;
  15113. };
  15114. }
  15115. declare module "babylonjs/Particles/particleSystem" {
  15116. import { Nullable } from "babylonjs/types";
  15117. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15118. import { Observable } from "babylonjs/Misc/observable";
  15119. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15120. import { Effect } from "babylonjs/Materials/effect";
  15121. import { Scene, IDisposable } from "babylonjs/scene";
  15122. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15123. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15124. import { Particle } from "babylonjs/Particles/particle";
  15125. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15126. import "babylonjs/Shaders/particles.fragment";
  15127. import "babylonjs/Shaders/particles.vertex";
  15128. /**
  15129. * This represents a particle system in Babylon.
  15130. * 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.
  15131. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15132. * @example https://doc.babylonjs.com/babylon101/particles
  15133. */
  15134. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15135. /**
  15136. * Billboard mode will only apply to Y axis
  15137. */
  15138. static readonly BILLBOARDMODE_Y: number;
  15139. /**
  15140. * Billboard mode will apply to all axes
  15141. */
  15142. static readonly BILLBOARDMODE_ALL: number;
  15143. /**
  15144. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15145. */
  15146. static readonly BILLBOARDMODE_STRETCHED: number;
  15147. /**
  15148. * This function can be defined to provide custom update for active particles.
  15149. * This function will be called instead of regular update (age, position, color, etc.).
  15150. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15151. */
  15152. updateFunction: (particles: Particle[]) => void;
  15153. private _emitterWorldMatrix;
  15154. /**
  15155. * This function can be defined to specify initial direction for every new particle.
  15156. * It by default use the emitterType defined function
  15157. */
  15158. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15159. /**
  15160. * This function can be defined to specify initial position for every new particle.
  15161. * It by default use the emitterType defined function
  15162. */
  15163. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15164. /**
  15165. * @hidden
  15166. */
  15167. _inheritedVelocityOffset: Vector3;
  15168. /**
  15169. * An event triggered when the system is disposed
  15170. */
  15171. onDisposeObservable: Observable<ParticleSystem>;
  15172. private _onDisposeObserver;
  15173. /**
  15174. * Sets a callback that will be triggered when the system is disposed
  15175. */
  15176. onDispose: () => void;
  15177. private _particles;
  15178. private _epsilon;
  15179. private _capacity;
  15180. private _stockParticles;
  15181. private _newPartsExcess;
  15182. private _vertexData;
  15183. private _vertexBuffer;
  15184. private _vertexBuffers;
  15185. private _spriteBuffer;
  15186. private _indexBuffer;
  15187. private _effect;
  15188. private _customEffect;
  15189. private _cachedDefines;
  15190. private _scaledColorStep;
  15191. private _colorDiff;
  15192. private _scaledDirection;
  15193. private _scaledGravity;
  15194. private _currentRenderId;
  15195. private _alive;
  15196. private _useInstancing;
  15197. private _started;
  15198. private _stopped;
  15199. private _actualFrame;
  15200. private _scaledUpdateSpeed;
  15201. private _vertexBufferSize;
  15202. /** @hidden */
  15203. _currentEmitRateGradient: Nullable<FactorGradient>;
  15204. /** @hidden */
  15205. _currentEmitRate1: number;
  15206. /** @hidden */
  15207. _currentEmitRate2: number;
  15208. /** @hidden */
  15209. _currentStartSizeGradient: Nullable<FactorGradient>;
  15210. /** @hidden */
  15211. _currentStartSize1: number;
  15212. /** @hidden */
  15213. _currentStartSize2: number;
  15214. private readonly _rawTextureWidth;
  15215. private _rampGradientsTexture;
  15216. private _useRampGradients;
  15217. /** Gets or sets a boolean indicating that ramp gradients must be used
  15218. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15219. */
  15220. useRampGradients: boolean;
  15221. /**
  15222. * 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.
  15223. * 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: [])
  15224. */
  15225. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15226. private _subEmitters;
  15227. /**
  15228. * @hidden
  15229. * If the particle systems emitter should be disposed when the particle system is disposed
  15230. */
  15231. _disposeEmitterOnDispose: boolean;
  15232. /**
  15233. * The current active Sub-systems, this property is used by the root particle system only.
  15234. */
  15235. activeSubSystems: Array<ParticleSystem>;
  15236. private _rootParticleSystem;
  15237. /**
  15238. * Gets the current list of active particles
  15239. */
  15240. readonly particles: Particle[];
  15241. /**
  15242. * Returns the string "ParticleSystem"
  15243. * @returns a string containing the class name
  15244. */
  15245. getClassName(): string;
  15246. /**
  15247. * Instantiates a particle system.
  15248. * 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.
  15249. * @param name The name of the particle system
  15250. * @param capacity The max number of particles alive at the same time
  15251. * @param scene The scene the particle system belongs to
  15252. * @param customEffect a custom effect used to change the way particles are rendered by default
  15253. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15254. * @param epsilon Offset used to render the particles
  15255. */
  15256. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15257. private _addFactorGradient;
  15258. private _removeFactorGradient;
  15259. /**
  15260. * Adds a new life time gradient
  15261. * @param gradient defines the gradient to use (between 0 and 1)
  15262. * @param factor defines the life time factor to affect to the specified gradient
  15263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15264. * @returns the current particle system
  15265. */
  15266. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15267. /**
  15268. * Remove a specific life time gradient
  15269. * @param gradient defines the gradient to remove
  15270. * @returns the current particle system
  15271. */
  15272. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15273. /**
  15274. * Adds a new size gradient
  15275. * @param gradient defines the gradient to use (between 0 and 1)
  15276. * @param factor defines the size factor to affect to the specified gradient
  15277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15278. * @returns the current particle system
  15279. */
  15280. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15281. /**
  15282. * Remove a specific size gradient
  15283. * @param gradient defines the gradient to remove
  15284. * @returns the current particle system
  15285. */
  15286. removeSizeGradient(gradient: number): IParticleSystem;
  15287. /**
  15288. * Adds a new color remap gradient
  15289. * @param gradient defines the gradient to use (between 0 and 1)
  15290. * @param min defines the color remap minimal range
  15291. * @param max defines the color remap maximal range
  15292. * @returns the current particle system
  15293. */
  15294. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15295. /**
  15296. * Remove a specific color remap gradient
  15297. * @param gradient defines the gradient to remove
  15298. * @returns the current particle system
  15299. */
  15300. removeColorRemapGradient(gradient: number): IParticleSystem;
  15301. /**
  15302. * Adds a new alpha remap gradient
  15303. * @param gradient defines the gradient to use (between 0 and 1)
  15304. * @param min defines the alpha remap minimal range
  15305. * @param max defines the alpha remap maximal range
  15306. * @returns the current particle system
  15307. */
  15308. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15309. /**
  15310. * Remove a specific alpha remap gradient
  15311. * @param gradient defines the gradient to remove
  15312. * @returns the current particle system
  15313. */
  15314. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15315. /**
  15316. * Adds a new angular speed gradient
  15317. * @param gradient defines the gradient to use (between 0 and 1)
  15318. * @param factor defines the angular speed to affect to the specified gradient
  15319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15320. * @returns the current particle system
  15321. */
  15322. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15323. /**
  15324. * Remove a specific angular speed gradient
  15325. * @param gradient defines the gradient to remove
  15326. * @returns the current particle system
  15327. */
  15328. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15329. /**
  15330. * Adds a new velocity gradient
  15331. * @param gradient defines the gradient to use (between 0 and 1)
  15332. * @param factor defines the velocity to affect to the specified gradient
  15333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15334. * @returns the current particle system
  15335. */
  15336. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15337. /**
  15338. * Remove a specific velocity gradient
  15339. * @param gradient defines the gradient to remove
  15340. * @returns the current particle system
  15341. */
  15342. removeVelocityGradient(gradient: number): IParticleSystem;
  15343. /**
  15344. * Adds a new limit velocity gradient
  15345. * @param gradient defines the gradient to use (between 0 and 1)
  15346. * @param factor defines the limit velocity value to affect to the specified gradient
  15347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15348. * @returns the current particle system
  15349. */
  15350. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15351. /**
  15352. * Remove a specific limit velocity gradient
  15353. * @param gradient defines the gradient to remove
  15354. * @returns the current particle system
  15355. */
  15356. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15357. /**
  15358. * Adds a new drag gradient
  15359. * @param gradient defines the gradient to use (between 0 and 1)
  15360. * @param factor defines the drag value to affect to the specified gradient
  15361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15362. * @returns the current particle system
  15363. */
  15364. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15365. /**
  15366. * Remove a specific drag gradient
  15367. * @param gradient defines the gradient to remove
  15368. * @returns the current particle system
  15369. */
  15370. removeDragGradient(gradient: number): IParticleSystem;
  15371. /**
  15372. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15373. * @param gradient defines the gradient to use (between 0 and 1)
  15374. * @param factor defines the emit rate value to affect to the specified gradient
  15375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15376. * @returns the current particle system
  15377. */
  15378. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15379. /**
  15380. * Remove a specific emit rate gradient
  15381. * @param gradient defines the gradient to remove
  15382. * @returns the current particle system
  15383. */
  15384. removeEmitRateGradient(gradient: number): IParticleSystem;
  15385. /**
  15386. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15387. * @param gradient defines the gradient to use (between 0 and 1)
  15388. * @param factor defines the start size value to affect to the specified gradient
  15389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15390. * @returns the current particle system
  15391. */
  15392. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15393. /**
  15394. * Remove a specific start size gradient
  15395. * @param gradient defines the gradient to remove
  15396. * @returns the current particle system
  15397. */
  15398. removeStartSizeGradient(gradient: number): IParticleSystem;
  15399. private _createRampGradientTexture;
  15400. /**
  15401. * Gets the current list of ramp gradients.
  15402. * You must use addRampGradient and removeRampGradient to udpate this list
  15403. * @returns the list of ramp gradients
  15404. */
  15405. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15406. /**
  15407. * Adds a new ramp gradient used to remap particle colors
  15408. * @param gradient defines the gradient to use (between 0 and 1)
  15409. * @param color defines the color to affect to the specified gradient
  15410. * @returns the current particle system
  15411. */
  15412. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15413. /**
  15414. * Remove a specific ramp gradient
  15415. * @param gradient defines the gradient to remove
  15416. * @returns the current particle system
  15417. */
  15418. removeRampGradient(gradient: number): ParticleSystem;
  15419. /**
  15420. * Adds a new color gradient
  15421. * @param gradient defines the gradient to use (between 0 and 1)
  15422. * @param color1 defines the color to affect to the specified gradient
  15423. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15424. * @returns this particle system
  15425. */
  15426. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15427. /**
  15428. * Remove a specific color gradient
  15429. * @param gradient defines the gradient to remove
  15430. * @returns this particle system
  15431. */
  15432. removeColorGradient(gradient: number): IParticleSystem;
  15433. private _fetchR;
  15434. protected _reset(): void;
  15435. private _resetEffect;
  15436. private _createVertexBuffers;
  15437. private _createIndexBuffer;
  15438. /**
  15439. * Gets the maximum number of particles active at the same time.
  15440. * @returns The max number of active particles.
  15441. */
  15442. getCapacity(): number;
  15443. /**
  15444. * Gets whether there are still active particles in the system.
  15445. * @returns True if it is alive, otherwise false.
  15446. */
  15447. isAlive(): boolean;
  15448. /**
  15449. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15450. * @returns True if it has been started, otherwise false.
  15451. */
  15452. isStarted(): boolean;
  15453. private _prepareSubEmitterInternalArray;
  15454. /**
  15455. * Starts the particle system and begins to emit
  15456. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15457. */
  15458. start(delay?: number): void;
  15459. /**
  15460. * Stops the particle system.
  15461. * @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.
  15462. */
  15463. stop(stopSubEmitters?: boolean): void;
  15464. /**
  15465. * Remove all active particles
  15466. */
  15467. reset(): void;
  15468. /**
  15469. * @hidden (for internal use only)
  15470. */
  15471. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15472. /**
  15473. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15474. * Its lifetime will start back at 0.
  15475. */
  15476. recycleParticle: (particle: Particle) => void;
  15477. private _stopSubEmitters;
  15478. private _createParticle;
  15479. private _removeFromRoot;
  15480. private _emitFromParticle;
  15481. private _update;
  15482. /** @hidden */
  15483. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15484. /** @hidden */
  15485. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15486. /** @hidden */
  15487. private _getEffect;
  15488. /**
  15489. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15490. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15491. */
  15492. animate(preWarmOnly?: boolean): void;
  15493. private _appendParticleVertices;
  15494. /**
  15495. * Rebuilds the particle system.
  15496. */
  15497. rebuild(): void;
  15498. /**
  15499. * Is this system ready to be used/rendered
  15500. * @return true if the system is ready
  15501. */
  15502. isReady(): boolean;
  15503. private _render;
  15504. /**
  15505. * Renders the particle system in its current state.
  15506. * @returns the current number of particles
  15507. */
  15508. render(): number;
  15509. /**
  15510. * Disposes the particle system and free the associated resources
  15511. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15512. */
  15513. dispose(disposeTexture?: boolean): void;
  15514. /**
  15515. * Clones the particle system.
  15516. * @param name The name of the cloned object
  15517. * @param newEmitter The new emitter to use
  15518. * @returns the cloned particle system
  15519. */
  15520. clone(name: string, newEmitter: any): ParticleSystem;
  15521. /**
  15522. * Serializes the particle system to a JSON object.
  15523. * @returns the JSON object
  15524. */
  15525. serialize(): any;
  15526. /** @hidden */
  15527. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15528. /** @hidden */
  15529. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15530. /**
  15531. * Parses a JSON object to create a particle system.
  15532. * @param parsedParticleSystem The JSON object to parse
  15533. * @param scene The scene to create the particle system in
  15534. * @param rootUrl The root url to use to load external dependencies like texture
  15535. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15536. * @returns the Parsed particle system
  15537. */
  15538. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15539. }
  15540. }
  15541. declare module "babylonjs/Particles/particle" {
  15542. import { Nullable } from "babylonjs/types";
  15543. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15544. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15545. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15546. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15547. /**
  15548. * A particle represents one of the element emitted by a particle system.
  15549. * This is mainly define by its coordinates, direction, velocity and age.
  15550. */
  15551. export class Particle {
  15552. /**
  15553. * The particle system the particle belongs to.
  15554. */
  15555. particleSystem: ParticleSystem;
  15556. private static _Count;
  15557. /**
  15558. * Unique ID of the particle
  15559. */
  15560. id: number;
  15561. /**
  15562. * The world position of the particle in the scene.
  15563. */
  15564. position: Vector3;
  15565. /**
  15566. * The world direction of the particle in the scene.
  15567. */
  15568. direction: Vector3;
  15569. /**
  15570. * The color of the particle.
  15571. */
  15572. color: Color4;
  15573. /**
  15574. * The color change of the particle per step.
  15575. */
  15576. colorStep: Color4;
  15577. /**
  15578. * Defines how long will the life of the particle be.
  15579. */
  15580. lifeTime: number;
  15581. /**
  15582. * The current age of the particle.
  15583. */
  15584. age: number;
  15585. /**
  15586. * The current size of the particle.
  15587. */
  15588. size: number;
  15589. /**
  15590. * The current scale of the particle.
  15591. */
  15592. scale: Vector2;
  15593. /**
  15594. * The current angle of the particle.
  15595. */
  15596. angle: number;
  15597. /**
  15598. * Defines how fast is the angle changing.
  15599. */
  15600. angularSpeed: number;
  15601. /**
  15602. * Defines the cell index used by the particle to be rendered from a sprite.
  15603. */
  15604. cellIndex: number;
  15605. /**
  15606. * The information required to support color remapping
  15607. */
  15608. remapData: Vector4;
  15609. /** @hidden */
  15610. _randomCellOffset?: number;
  15611. /** @hidden */
  15612. _initialDirection: Nullable<Vector3>;
  15613. /** @hidden */
  15614. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15615. /** @hidden */
  15616. _initialStartSpriteCellID: number;
  15617. /** @hidden */
  15618. _initialEndSpriteCellID: number;
  15619. /** @hidden */
  15620. _currentColorGradient: Nullable<ColorGradient>;
  15621. /** @hidden */
  15622. _currentColor1: Color4;
  15623. /** @hidden */
  15624. _currentColor2: Color4;
  15625. /** @hidden */
  15626. _currentSizeGradient: Nullable<FactorGradient>;
  15627. /** @hidden */
  15628. _currentSize1: number;
  15629. /** @hidden */
  15630. _currentSize2: number;
  15631. /** @hidden */
  15632. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15633. /** @hidden */
  15634. _currentAngularSpeed1: number;
  15635. /** @hidden */
  15636. _currentAngularSpeed2: number;
  15637. /** @hidden */
  15638. _currentVelocityGradient: Nullable<FactorGradient>;
  15639. /** @hidden */
  15640. _currentVelocity1: number;
  15641. /** @hidden */
  15642. _currentVelocity2: number;
  15643. /** @hidden */
  15644. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15645. /** @hidden */
  15646. _currentLimitVelocity1: number;
  15647. /** @hidden */
  15648. _currentLimitVelocity2: number;
  15649. /** @hidden */
  15650. _currentDragGradient: Nullable<FactorGradient>;
  15651. /** @hidden */
  15652. _currentDrag1: number;
  15653. /** @hidden */
  15654. _currentDrag2: number;
  15655. /** @hidden */
  15656. _randomNoiseCoordinates1: Vector3;
  15657. /** @hidden */
  15658. _randomNoiseCoordinates2: Vector3;
  15659. /**
  15660. * Creates a new instance Particle
  15661. * @param particleSystem the particle system the particle belongs to
  15662. */
  15663. constructor(
  15664. /**
  15665. * The particle system the particle belongs to.
  15666. */
  15667. particleSystem: ParticleSystem);
  15668. private updateCellInfoFromSystem;
  15669. /**
  15670. * Defines how the sprite cell index is updated for the particle
  15671. */
  15672. updateCellIndex(): void;
  15673. /** @hidden */
  15674. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15675. /** @hidden */
  15676. _inheritParticleInfoToSubEmitters(): void;
  15677. /** @hidden */
  15678. _reset(): void;
  15679. /**
  15680. * Copy the properties of particle to another one.
  15681. * @param other the particle to copy the information to.
  15682. */
  15683. copyTo(other: Particle): void;
  15684. }
  15685. }
  15686. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15687. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15688. import { Effect } from "babylonjs/Materials/effect";
  15689. import { Particle } from "babylonjs/Particles/particle";
  15690. /**
  15691. * Particle emitter represents a volume emitting particles.
  15692. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15693. */
  15694. export interface IParticleEmitterType {
  15695. /**
  15696. * Called by the particle System when the direction is computed for the created particle.
  15697. * @param worldMatrix is the world matrix of the particle system
  15698. * @param directionToUpdate is the direction vector to update with the result
  15699. * @param particle is the particle we are computed the direction for
  15700. */
  15701. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15702. /**
  15703. * Called by the particle System when the position is computed for the created particle.
  15704. * @param worldMatrix is the world matrix of the particle system
  15705. * @param positionToUpdate is the position vector to update with the result
  15706. * @param particle is the particle we are computed the position for
  15707. */
  15708. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15709. /**
  15710. * Clones the current emitter and returns a copy of it
  15711. * @returns the new emitter
  15712. */
  15713. clone(): IParticleEmitterType;
  15714. /**
  15715. * Called by the GPUParticleSystem to setup the update shader
  15716. * @param effect defines the update shader
  15717. */
  15718. applyToShader(effect: Effect): void;
  15719. /**
  15720. * Returns a string to use to update the GPU particles update shader
  15721. * @returns the effect defines string
  15722. */
  15723. getEffectDefines(): string;
  15724. /**
  15725. * Returns a string representing the class name
  15726. * @returns a string containing the class name
  15727. */
  15728. getClassName(): string;
  15729. /**
  15730. * Serializes the particle system to a JSON object.
  15731. * @returns the JSON object
  15732. */
  15733. serialize(): any;
  15734. /**
  15735. * Parse properties from a JSON object
  15736. * @param serializationObject defines the JSON object
  15737. */
  15738. parse(serializationObject: any): void;
  15739. }
  15740. }
  15741. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15742. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15743. import { Effect } from "babylonjs/Materials/effect";
  15744. import { Particle } from "babylonjs/Particles/particle";
  15745. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15746. /**
  15747. * Particle emitter emitting particles from the inside of a box.
  15748. * It emits the particles randomly between 2 given directions.
  15749. */
  15750. export class BoxParticleEmitter implements IParticleEmitterType {
  15751. /**
  15752. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15753. */
  15754. direction1: Vector3;
  15755. /**
  15756. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15757. */
  15758. direction2: Vector3;
  15759. /**
  15760. * 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.
  15761. */
  15762. minEmitBox: Vector3;
  15763. /**
  15764. * 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.
  15765. */
  15766. maxEmitBox: Vector3;
  15767. /**
  15768. * Creates a new instance BoxParticleEmitter
  15769. */
  15770. constructor();
  15771. /**
  15772. * Called by the particle System when the direction is computed for the created particle.
  15773. * @param worldMatrix is the world matrix of the particle system
  15774. * @param directionToUpdate is the direction vector to update with the result
  15775. * @param particle is the particle we are computed the direction for
  15776. */
  15777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15778. /**
  15779. * Called by the particle System when the position is computed for the created particle.
  15780. * @param worldMatrix is the world matrix of the particle system
  15781. * @param positionToUpdate is the position vector to update with the result
  15782. * @param particle is the particle we are computed the position for
  15783. */
  15784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15785. /**
  15786. * Clones the current emitter and returns a copy of it
  15787. * @returns the new emitter
  15788. */
  15789. clone(): BoxParticleEmitter;
  15790. /**
  15791. * Called by the GPUParticleSystem to setup the update shader
  15792. * @param effect defines the update shader
  15793. */
  15794. applyToShader(effect: Effect): void;
  15795. /**
  15796. * Returns a string to use to update the GPU particles update shader
  15797. * @returns a string containng the defines string
  15798. */
  15799. getEffectDefines(): string;
  15800. /**
  15801. * Returns the string "BoxParticleEmitter"
  15802. * @returns a string containing the class name
  15803. */
  15804. getClassName(): string;
  15805. /**
  15806. * Serializes the particle system to a JSON object.
  15807. * @returns the JSON object
  15808. */
  15809. serialize(): any;
  15810. /**
  15811. * Parse properties from a JSON object
  15812. * @param serializationObject defines the JSON object
  15813. */
  15814. parse(serializationObject: any): void;
  15815. }
  15816. }
  15817. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15818. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15819. import { Effect } from "babylonjs/Materials/effect";
  15820. import { Particle } from "babylonjs/Particles/particle";
  15821. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15822. /**
  15823. * Particle emitter emitting particles from the inside of a cone.
  15824. * It emits the particles alongside the cone volume from the base to the particle.
  15825. * The emission direction might be randomized.
  15826. */
  15827. export class ConeParticleEmitter implements IParticleEmitterType {
  15828. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15829. directionRandomizer: number;
  15830. private _radius;
  15831. private _angle;
  15832. private _height;
  15833. /**
  15834. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15835. */
  15836. radiusRange: number;
  15837. /**
  15838. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15839. */
  15840. heightRange: number;
  15841. /**
  15842. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15843. */
  15844. emitFromSpawnPointOnly: boolean;
  15845. /**
  15846. * Gets or sets the radius of the emission cone
  15847. */
  15848. radius: number;
  15849. /**
  15850. * Gets or sets the angle of the emission cone
  15851. */
  15852. angle: number;
  15853. private _buildHeight;
  15854. /**
  15855. * Creates a new instance ConeParticleEmitter
  15856. * @param radius the radius of the emission cone (1 by default)
  15857. * @param angle the cone base angle (PI by default)
  15858. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15859. */
  15860. constructor(radius?: number, angle?: number,
  15861. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15862. directionRandomizer?: number);
  15863. /**
  15864. * Called by the particle System when the direction is computed for the created particle.
  15865. * @param worldMatrix is the world matrix of the particle system
  15866. * @param directionToUpdate is the direction vector to update with the result
  15867. * @param particle is the particle we are computed the direction for
  15868. */
  15869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15870. /**
  15871. * Called by the particle System when the position is computed for the created particle.
  15872. * @param worldMatrix is the world matrix of the particle system
  15873. * @param positionToUpdate is the position vector to update with the result
  15874. * @param particle is the particle we are computed the position for
  15875. */
  15876. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15877. /**
  15878. * Clones the current emitter and returns a copy of it
  15879. * @returns the new emitter
  15880. */
  15881. clone(): ConeParticleEmitter;
  15882. /**
  15883. * Called by the GPUParticleSystem to setup the update shader
  15884. * @param effect defines the update shader
  15885. */
  15886. applyToShader(effect: Effect): void;
  15887. /**
  15888. * Returns a string to use to update the GPU particles update shader
  15889. * @returns a string containng the defines string
  15890. */
  15891. getEffectDefines(): string;
  15892. /**
  15893. * Returns the string "ConeParticleEmitter"
  15894. * @returns a string containing the class name
  15895. */
  15896. getClassName(): string;
  15897. /**
  15898. * Serializes the particle system to a JSON object.
  15899. * @returns the JSON object
  15900. */
  15901. serialize(): any;
  15902. /**
  15903. * Parse properties from a JSON object
  15904. * @param serializationObject defines the JSON object
  15905. */
  15906. parse(serializationObject: any): void;
  15907. }
  15908. }
  15909. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15910. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15911. import { Effect } from "babylonjs/Materials/effect";
  15912. import { Particle } from "babylonjs/Particles/particle";
  15913. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15914. /**
  15915. * Particle emitter emitting particles from the inside of a cylinder.
  15916. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15917. */
  15918. export class CylinderParticleEmitter implements IParticleEmitterType {
  15919. /**
  15920. * The radius of the emission cylinder.
  15921. */
  15922. radius: number;
  15923. /**
  15924. * The height of the emission cylinder.
  15925. */
  15926. height: number;
  15927. /**
  15928. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15929. */
  15930. radiusRange: number;
  15931. /**
  15932. * How much to randomize the particle direction [0-1].
  15933. */
  15934. directionRandomizer: number;
  15935. /**
  15936. * Creates a new instance CylinderParticleEmitter
  15937. * @param radius the radius of the emission cylinder (1 by default)
  15938. * @param height the height of the emission cylinder (1 by default)
  15939. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15940. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15941. */
  15942. constructor(
  15943. /**
  15944. * The radius of the emission cylinder.
  15945. */
  15946. radius?: number,
  15947. /**
  15948. * The height of the emission cylinder.
  15949. */
  15950. height?: number,
  15951. /**
  15952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15953. */
  15954. radiusRange?: number,
  15955. /**
  15956. * How much to randomize the particle direction [0-1].
  15957. */
  15958. directionRandomizer?: number);
  15959. /**
  15960. * Called by the particle System when the direction is computed for the created particle.
  15961. * @param worldMatrix is the world matrix of the particle system
  15962. * @param directionToUpdate is the direction vector to update with the result
  15963. * @param particle is the particle we are computed the direction for
  15964. */
  15965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15966. /**
  15967. * Called by the particle System when the position is computed for the created particle.
  15968. * @param worldMatrix is the world matrix of the particle system
  15969. * @param positionToUpdate is the position vector to update with the result
  15970. * @param particle is the particle we are computed the position for
  15971. */
  15972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15973. /**
  15974. * Clones the current emitter and returns a copy of it
  15975. * @returns the new emitter
  15976. */
  15977. clone(): CylinderParticleEmitter;
  15978. /**
  15979. * Called by the GPUParticleSystem to setup the update shader
  15980. * @param effect defines the update shader
  15981. */
  15982. applyToShader(effect: Effect): void;
  15983. /**
  15984. * Returns a string to use to update the GPU particles update shader
  15985. * @returns a string containng the defines string
  15986. */
  15987. getEffectDefines(): string;
  15988. /**
  15989. * Returns the string "CylinderParticleEmitter"
  15990. * @returns a string containing the class name
  15991. */
  15992. getClassName(): string;
  15993. /**
  15994. * Serializes the particle system to a JSON object.
  15995. * @returns the JSON object
  15996. */
  15997. serialize(): any;
  15998. /**
  15999. * Parse properties from a JSON object
  16000. * @param serializationObject defines the JSON object
  16001. */
  16002. parse(serializationObject: any): void;
  16003. }
  16004. /**
  16005. * Particle emitter emitting particles from the inside of a cylinder.
  16006. * It emits the particles randomly between two vectors.
  16007. */
  16008. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16009. /**
  16010. * The min limit of the emission direction.
  16011. */
  16012. direction1: Vector3;
  16013. /**
  16014. * The max limit of the emission direction.
  16015. */
  16016. direction2: Vector3;
  16017. /**
  16018. * Creates a new instance CylinderDirectedParticleEmitter
  16019. * @param radius the radius of the emission cylinder (1 by default)
  16020. * @param height the height of the emission cylinder (1 by default)
  16021. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16022. * @param direction1 the min limit of the emission direction (up vector by default)
  16023. * @param direction2 the max limit of the emission direction (up vector by default)
  16024. */
  16025. constructor(radius?: number, height?: number, radiusRange?: number,
  16026. /**
  16027. * The min limit of the emission direction.
  16028. */
  16029. direction1?: Vector3,
  16030. /**
  16031. * The max limit of the emission direction.
  16032. */
  16033. direction2?: Vector3);
  16034. /**
  16035. * Called by the particle System when the direction is computed for the created particle.
  16036. * @param worldMatrix is the world matrix of the particle system
  16037. * @param directionToUpdate is the direction vector to update with the result
  16038. * @param particle is the particle we are computed the direction for
  16039. */
  16040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16041. /**
  16042. * Clones the current emitter and returns a copy of it
  16043. * @returns the new emitter
  16044. */
  16045. clone(): CylinderDirectedParticleEmitter;
  16046. /**
  16047. * Called by the GPUParticleSystem to setup the update shader
  16048. * @param effect defines the update shader
  16049. */
  16050. applyToShader(effect: Effect): void;
  16051. /**
  16052. * Returns a string to use to update the GPU particles update shader
  16053. * @returns a string containng the defines string
  16054. */
  16055. getEffectDefines(): string;
  16056. /**
  16057. * Returns the string "CylinderDirectedParticleEmitter"
  16058. * @returns a string containing the class name
  16059. */
  16060. getClassName(): string;
  16061. /**
  16062. * Serializes the particle system to a JSON object.
  16063. * @returns the JSON object
  16064. */
  16065. serialize(): any;
  16066. /**
  16067. * Parse properties from a JSON object
  16068. * @param serializationObject defines the JSON object
  16069. */
  16070. parse(serializationObject: any): void;
  16071. }
  16072. }
  16073. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16074. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16075. import { Effect } from "babylonjs/Materials/effect";
  16076. import { Particle } from "babylonjs/Particles/particle";
  16077. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16078. /**
  16079. * Particle emitter emitting particles from the inside of a hemisphere.
  16080. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16081. */
  16082. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16083. /**
  16084. * The radius of the emission hemisphere.
  16085. */
  16086. radius: number;
  16087. /**
  16088. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16089. */
  16090. radiusRange: number;
  16091. /**
  16092. * How much to randomize the particle direction [0-1].
  16093. */
  16094. directionRandomizer: number;
  16095. /**
  16096. * Creates a new instance HemisphericParticleEmitter
  16097. * @param radius the radius of the emission hemisphere (1 by default)
  16098. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16099. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16100. */
  16101. constructor(
  16102. /**
  16103. * The radius of the emission hemisphere.
  16104. */
  16105. radius?: number,
  16106. /**
  16107. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16108. */
  16109. radiusRange?: number,
  16110. /**
  16111. * How much to randomize the particle direction [0-1].
  16112. */
  16113. directionRandomizer?: number);
  16114. /**
  16115. * Called by the particle System when the direction is computed for the created particle.
  16116. * @param worldMatrix is the world matrix of the particle system
  16117. * @param directionToUpdate is the direction vector to update with the result
  16118. * @param particle is the particle we are computed the direction for
  16119. */
  16120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16121. /**
  16122. * Called by the particle System when the position is computed for the created particle.
  16123. * @param worldMatrix is the world matrix of the particle system
  16124. * @param positionToUpdate is the position vector to update with the result
  16125. * @param particle is the particle we are computed the position for
  16126. */
  16127. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16128. /**
  16129. * Clones the current emitter and returns a copy of it
  16130. * @returns the new emitter
  16131. */
  16132. clone(): HemisphericParticleEmitter;
  16133. /**
  16134. * Called by the GPUParticleSystem to setup the update shader
  16135. * @param effect defines the update shader
  16136. */
  16137. applyToShader(effect: Effect): void;
  16138. /**
  16139. * Returns a string to use to update the GPU particles update shader
  16140. * @returns a string containng the defines string
  16141. */
  16142. getEffectDefines(): string;
  16143. /**
  16144. * Returns the string "HemisphericParticleEmitter"
  16145. * @returns a string containing the class name
  16146. */
  16147. getClassName(): string;
  16148. /**
  16149. * Serializes the particle system to a JSON object.
  16150. * @returns the JSON object
  16151. */
  16152. serialize(): any;
  16153. /**
  16154. * Parse properties from a JSON object
  16155. * @param serializationObject defines the JSON object
  16156. */
  16157. parse(serializationObject: any): void;
  16158. }
  16159. }
  16160. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16161. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16162. import { Effect } from "babylonjs/Materials/effect";
  16163. import { Particle } from "babylonjs/Particles/particle";
  16164. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16165. /**
  16166. * Particle emitter emitting particles from a point.
  16167. * It emits the particles randomly between 2 given directions.
  16168. */
  16169. export class PointParticleEmitter implements IParticleEmitterType {
  16170. /**
  16171. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16172. */
  16173. direction1: Vector3;
  16174. /**
  16175. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16176. */
  16177. direction2: Vector3;
  16178. /**
  16179. * Creates a new instance PointParticleEmitter
  16180. */
  16181. constructor();
  16182. /**
  16183. * Called by the particle System when the direction is computed for the created particle.
  16184. * @param worldMatrix is the world matrix of the particle system
  16185. * @param directionToUpdate is the direction vector to update with the result
  16186. * @param particle is the particle we are computed the direction for
  16187. */
  16188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16189. /**
  16190. * Called by the particle System when the position is computed for the created particle.
  16191. * @param worldMatrix is the world matrix of the particle system
  16192. * @param positionToUpdate is the position vector to update with the result
  16193. * @param particle is the particle we are computed the position for
  16194. */
  16195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16196. /**
  16197. * Clones the current emitter and returns a copy of it
  16198. * @returns the new emitter
  16199. */
  16200. clone(): PointParticleEmitter;
  16201. /**
  16202. * Called by the GPUParticleSystem to setup the update shader
  16203. * @param effect defines the update shader
  16204. */
  16205. applyToShader(effect: Effect): void;
  16206. /**
  16207. * Returns a string to use to update the GPU particles update shader
  16208. * @returns a string containng the defines string
  16209. */
  16210. getEffectDefines(): string;
  16211. /**
  16212. * Returns the string "PointParticleEmitter"
  16213. * @returns a string containing the class name
  16214. */
  16215. getClassName(): string;
  16216. /**
  16217. * Serializes the particle system to a JSON object.
  16218. * @returns the JSON object
  16219. */
  16220. serialize(): any;
  16221. /**
  16222. * Parse properties from a JSON object
  16223. * @param serializationObject defines the JSON object
  16224. */
  16225. parse(serializationObject: any): void;
  16226. }
  16227. }
  16228. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16229. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16230. import { Effect } from "babylonjs/Materials/effect";
  16231. import { Particle } from "babylonjs/Particles/particle";
  16232. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16233. /**
  16234. * Particle emitter emitting particles from the inside of a sphere.
  16235. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16236. */
  16237. export class SphereParticleEmitter implements IParticleEmitterType {
  16238. /**
  16239. * The radius of the emission sphere.
  16240. */
  16241. radius: number;
  16242. /**
  16243. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16244. */
  16245. radiusRange: number;
  16246. /**
  16247. * How much to randomize the particle direction [0-1].
  16248. */
  16249. directionRandomizer: number;
  16250. /**
  16251. * Creates a new instance SphereParticleEmitter
  16252. * @param radius the radius of the emission sphere (1 by default)
  16253. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16254. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16255. */
  16256. constructor(
  16257. /**
  16258. * The radius of the emission sphere.
  16259. */
  16260. radius?: number,
  16261. /**
  16262. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16263. */
  16264. radiusRange?: number,
  16265. /**
  16266. * How much to randomize the particle direction [0-1].
  16267. */
  16268. directionRandomizer?: number);
  16269. /**
  16270. * Called by the particle System when the direction is computed for the created particle.
  16271. * @param worldMatrix is the world matrix of the particle system
  16272. * @param directionToUpdate is the direction vector to update with the result
  16273. * @param particle is the particle we are computed the direction for
  16274. */
  16275. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16276. /**
  16277. * Called by the particle System when the position is computed for the created particle.
  16278. * @param worldMatrix is the world matrix of the particle system
  16279. * @param positionToUpdate is the position vector to update with the result
  16280. * @param particle is the particle we are computed the position for
  16281. */
  16282. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16283. /**
  16284. * Clones the current emitter and returns a copy of it
  16285. * @returns the new emitter
  16286. */
  16287. clone(): SphereParticleEmitter;
  16288. /**
  16289. * Called by the GPUParticleSystem to setup the update shader
  16290. * @param effect defines the update shader
  16291. */
  16292. applyToShader(effect: Effect): void;
  16293. /**
  16294. * Returns a string to use to update the GPU particles update shader
  16295. * @returns a string containng the defines string
  16296. */
  16297. getEffectDefines(): string;
  16298. /**
  16299. * Returns the string "SphereParticleEmitter"
  16300. * @returns a string containing the class name
  16301. */
  16302. getClassName(): string;
  16303. /**
  16304. * Serializes the particle system to a JSON object.
  16305. * @returns the JSON object
  16306. */
  16307. serialize(): any;
  16308. /**
  16309. * Parse properties from a JSON object
  16310. * @param serializationObject defines the JSON object
  16311. */
  16312. parse(serializationObject: any): void;
  16313. }
  16314. /**
  16315. * Particle emitter emitting particles from the inside of a sphere.
  16316. * It emits the particles randomly between two vectors.
  16317. */
  16318. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16319. /**
  16320. * The min limit of the emission direction.
  16321. */
  16322. direction1: Vector3;
  16323. /**
  16324. * The max limit of the emission direction.
  16325. */
  16326. direction2: Vector3;
  16327. /**
  16328. * Creates a new instance SphereDirectedParticleEmitter
  16329. * @param radius the radius of the emission sphere (1 by default)
  16330. * @param direction1 the min limit of the emission direction (up vector by default)
  16331. * @param direction2 the max limit of the emission direction (up vector by default)
  16332. */
  16333. constructor(radius?: number,
  16334. /**
  16335. * The min limit of the emission direction.
  16336. */
  16337. direction1?: Vector3,
  16338. /**
  16339. * The max limit of the emission direction.
  16340. */
  16341. direction2?: Vector3);
  16342. /**
  16343. * Called by the particle System when the direction is computed for the created particle.
  16344. * @param worldMatrix is the world matrix of the particle system
  16345. * @param directionToUpdate is the direction vector to update with the result
  16346. * @param particle is the particle we are computed the direction for
  16347. */
  16348. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16349. /**
  16350. * Clones the current emitter and returns a copy of it
  16351. * @returns the new emitter
  16352. */
  16353. clone(): SphereDirectedParticleEmitter;
  16354. /**
  16355. * Called by the GPUParticleSystem to setup the update shader
  16356. * @param effect defines the update shader
  16357. */
  16358. applyToShader(effect: Effect): void;
  16359. /**
  16360. * Returns a string to use to update the GPU particles update shader
  16361. * @returns a string containng the defines string
  16362. */
  16363. getEffectDefines(): string;
  16364. /**
  16365. * Returns the string "SphereDirectedParticleEmitter"
  16366. * @returns a string containing the class name
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Serializes the particle system to a JSON object.
  16371. * @returns the JSON object
  16372. */
  16373. serialize(): any;
  16374. /**
  16375. * Parse properties from a JSON object
  16376. * @param serializationObject defines the JSON object
  16377. */
  16378. parse(serializationObject: any): void;
  16379. }
  16380. }
  16381. declare module "babylonjs/Particles/EmitterTypes/index" {
  16382. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16383. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16384. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16385. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16386. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16387. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16388. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16389. }
  16390. declare module "babylonjs/Particles/IParticleSystem" {
  16391. import { Nullable } from "babylonjs/types";
  16392. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16395. import { Texture } from "babylonjs/Materials/Textures/texture";
  16396. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16397. import { Scene } from "babylonjs/scene";
  16398. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16399. import { Animation } from "babylonjs/Animations/animation";
  16400. /**
  16401. * Interface representing a particle system in Babylon.js.
  16402. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16403. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16404. */
  16405. export interface IParticleSystem {
  16406. /**
  16407. * List of animations used by the particle system.
  16408. */
  16409. animations: Animation[];
  16410. /**
  16411. * The id of the Particle system.
  16412. */
  16413. id: string;
  16414. /**
  16415. * The name of the Particle system.
  16416. */
  16417. name: string;
  16418. /**
  16419. * The emitter represents the Mesh or position we are attaching the particle system to.
  16420. */
  16421. emitter: Nullable<AbstractMesh | Vector3>;
  16422. /**
  16423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16424. */
  16425. isBillboardBased: boolean;
  16426. /**
  16427. * The rendering group used by the Particle system to chose when to render.
  16428. */
  16429. renderingGroupId: number;
  16430. /**
  16431. * The layer mask we are rendering the particles through.
  16432. */
  16433. layerMask: number;
  16434. /**
  16435. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16436. */
  16437. updateSpeed: number;
  16438. /**
  16439. * The amount of time the particle system is running (depends of the overall update speed).
  16440. */
  16441. targetStopDuration: number;
  16442. /**
  16443. * The texture used to render each particle. (this can be a spritesheet)
  16444. */
  16445. particleTexture: Nullable<Texture>;
  16446. /**
  16447. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16448. */
  16449. blendMode: number;
  16450. /**
  16451. * Minimum life time of emitting particles.
  16452. */
  16453. minLifeTime: number;
  16454. /**
  16455. * Maximum life time of emitting particles.
  16456. */
  16457. maxLifeTime: number;
  16458. /**
  16459. * Minimum Size of emitting particles.
  16460. */
  16461. minSize: number;
  16462. /**
  16463. * Maximum Size of emitting particles.
  16464. */
  16465. maxSize: number;
  16466. /**
  16467. * Minimum scale of emitting particles on X axis.
  16468. */
  16469. minScaleX: number;
  16470. /**
  16471. * Maximum scale of emitting particles on X axis.
  16472. */
  16473. maxScaleX: number;
  16474. /**
  16475. * Minimum scale of emitting particles on Y axis.
  16476. */
  16477. minScaleY: number;
  16478. /**
  16479. * Maximum scale of emitting particles on Y axis.
  16480. */
  16481. maxScaleY: number;
  16482. /**
  16483. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16484. */
  16485. color1: Color4;
  16486. /**
  16487. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16488. */
  16489. color2: Color4;
  16490. /**
  16491. * Color the particle will have at the end of its lifetime.
  16492. */
  16493. colorDead: Color4;
  16494. /**
  16495. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16496. */
  16497. emitRate: number;
  16498. /**
  16499. * You can use gravity if you want to give an orientation to your particles.
  16500. */
  16501. gravity: Vector3;
  16502. /**
  16503. * Minimum power of emitting particles.
  16504. */
  16505. minEmitPower: number;
  16506. /**
  16507. * Maximum power of emitting particles.
  16508. */
  16509. maxEmitPower: number;
  16510. /**
  16511. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16512. */
  16513. minAngularSpeed: number;
  16514. /**
  16515. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16516. */
  16517. maxAngularSpeed: number;
  16518. /**
  16519. * Gets or sets the minimal initial rotation in radians.
  16520. */
  16521. minInitialRotation: number;
  16522. /**
  16523. * Gets or sets the maximal initial rotation in radians.
  16524. */
  16525. maxInitialRotation: number;
  16526. /**
  16527. * The particle emitter type defines the emitter used by the particle system.
  16528. * It can be for example box, sphere, or cone...
  16529. */
  16530. particleEmitterType: Nullable<IParticleEmitterType>;
  16531. /**
  16532. * Defines the delay in milliseconds before starting the system (0 by default)
  16533. */
  16534. startDelay: number;
  16535. /**
  16536. * 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
  16537. */
  16538. preWarmCycles: number;
  16539. /**
  16540. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16541. */
  16542. preWarmStepOffset: number;
  16543. /**
  16544. * 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)
  16545. */
  16546. spriteCellChangeSpeed: number;
  16547. /**
  16548. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16549. */
  16550. startSpriteCellID: number;
  16551. /**
  16552. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16553. */
  16554. endSpriteCellID: number;
  16555. /**
  16556. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16557. */
  16558. spriteCellWidth: number;
  16559. /**
  16560. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16561. */
  16562. spriteCellHeight: number;
  16563. /**
  16564. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16565. */
  16566. spriteRandomStartCell: boolean;
  16567. /**
  16568. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16569. */
  16570. isAnimationSheetEnabled: boolean;
  16571. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16572. translationPivot: Vector2;
  16573. /**
  16574. * Gets or sets a texture used to add random noise to particle positions
  16575. */
  16576. noiseTexture: Nullable<BaseTexture>;
  16577. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16578. noiseStrength: Vector3;
  16579. /**
  16580. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16581. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16582. */
  16583. billboardMode: number;
  16584. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16585. limitVelocityDamping: number;
  16586. /**
  16587. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16588. */
  16589. beginAnimationOnStart: boolean;
  16590. /**
  16591. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16592. */
  16593. beginAnimationFrom: number;
  16594. /**
  16595. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16596. */
  16597. beginAnimationTo: number;
  16598. /**
  16599. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16600. */
  16601. beginAnimationLoop: boolean;
  16602. /**
  16603. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16604. */
  16605. disposeOnStop: boolean;
  16606. /**
  16607. * Gets the maximum number of particles active at the same time.
  16608. * @returns The max number of active particles.
  16609. */
  16610. getCapacity(): number;
  16611. /**
  16612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16613. * @returns True if it has been started, otherwise false.
  16614. */
  16615. isStarted(): boolean;
  16616. /**
  16617. * Animates the particle system for this frame.
  16618. */
  16619. animate(): void;
  16620. /**
  16621. * Renders the particle system in its current state.
  16622. * @returns the current number of particles
  16623. */
  16624. render(): number;
  16625. /**
  16626. * Dispose the particle system and frees its associated resources.
  16627. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16628. */
  16629. dispose(disposeTexture?: boolean): void;
  16630. /**
  16631. * Clones the particle system.
  16632. * @param name The name of the cloned object
  16633. * @param newEmitter The new emitter to use
  16634. * @returns the cloned particle system
  16635. */
  16636. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16637. /**
  16638. * Serializes the particle system to a JSON object.
  16639. * @returns the JSON object
  16640. */
  16641. serialize(): any;
  16642. /**
  16643. * Rebuild the particle system
  16644. */
  16645. rebuild(): void;
  16646. /**
  16647. * Starts the particle system and begins to emit
  16648. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16649. */
  16650. start(delay?: number): void;
  16651. /**
  16652. * Stops the particle system.
  16653. */
  16654. stop(): void;
  16655. /**
  16656. * Remove all active particles
  16657. */
  16658. reset(): void;
  16659. /**
  16660. * Is this system ready to be used/rendered
  16661. * @return true if the system is ready
  16662. */
  16663. isReady(): boolean;
  16664. /**
  16665. * Adds a new color gradient
  16666. * @param gradient defines the gradient to use (between 0 and 1)
  16667. * @param color1 defines the color to affect to the specified gradient
  16668. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16669. * @returns the current particle system
  16670. */
  16671. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16672. /**
  16673. * Remove a specific color gradient
  16674. * @param gradient defines the gradient to remove
  16675. * @returns the current particle system
  16676. */
  16677. removeColorGradient(gradient: number): IParticleSystem;
  16678. /**
  16679. * Adds a new size gradient
  16680. * @param gradient defines the gradient to use (between 0 and 1)
  16681. * @param factor defines the size factor to affect to the specified gradient
  16682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16683. * @returns the current particle system
  16684. */
  16685. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16686. /**
  16687. * Remove a specific size gradient
  16688. * @param gradient defines the gradient to remove
  16689. * @returns the current particle system
  16690. */
  16691. removeSizeGradient(gradient: number): IParticleSystem;
  16692. /**
  16693. * Gets the current list of color gradients.
  16694. * You must use addColorGradient and removeColorGradient to udpate this list
  16695. * @returns the list of color gradients
  16696. */
  16697. getColorGradients(): Nullable<Array<ColorGradient>>;
  16698. /**
  16699. * Gets the current list of size gradients.
  16700. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16701. * @returns the list of size gradients
  16702. */
  16703. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16704. /**
  16705. * Gets the current list of angular speed gradients.
  16706. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16707. * @returns the list of angular speed gradients
  16708. */
  16709. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16710. /**
  16711. * Adds a new angular speed gradient
  16712. * @param gradient defines the gradient to use (between 0 and 1)
  16713. * @param factor defines the angular speed to affect to the specified gradient
  16714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16715. * @returns the current particle system
  16716. */
  16717. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16718. /**
  16719. * Remove a specific angular speed gradient
  16720. * @param gradient defines the gradient to remove
  16721. * @returns the current particle system
  16722. */
  16723. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16724. /**
  16725. * Gets the current list of velocity gradients.
  16726. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16727. * @returns the list of velocity gradients
  16728. */
  16729. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16730. /**
  16731. * Adds a new velocity gradient
  16732. * @param gradient defines the gradient to use (between 0 and 1)
  16733. * @param factor defines the velocity to affect to the specified gradient
  16734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16735. * @returns the current particle system
  16736. */
  16737. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16738. /**
  16739. * Remove a specific velocity gradient
  16740. * @param gradient defines the gradient to remove
  16741. * @returns the current particle system
  16742. */
  16743. removeVelocityGradient(gradient: number): IParticleSystem;
  16744. /**
  16745. * Gets the current list of limit velocity gradients.
  16746. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16747. * @returns the list of limit velocity gradients
  16748. */
  16749. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16750. /**
  16751. * Adds a new limit velocity gradient
  16752. * @param gradient defines the gradient to use (between 0 and 1)
  16753. * @param factor defines the limit velocity to affect to the specified gradient
  16754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16755. * @returns the current particle system
  16756. */
  16757. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16758. /**
  16759. * Remove a specific limit velocity gradient
  16760. * @param gradient defines the gradient to remove
  16761. * @returns the current particle system
  16762. */
  16763. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16764. /**
  16765. * Adds a new drag gradient
  16766. * @param gradient defines the gradient to use (between 0 and 1)
  16767. * @param factor defines the drag to affect to the specified gradient
  16768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16769. * @returns the current particle system
  16770. */
  16771. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16772. /**
  16773. * Remove a specific drag gradient
  16774. * @param gradient defines the gradient to remove
  16775. * @returns the current particle system
  16776. */
  16777. removeDragGradient(gradient: number): IParticleSystem;
  16778. /**
  16779. * Gets the current list of drag gradients.
  16780. * You must use addDragGradient and removeDragGradient to udpate this list
  16781. * @returns the list of drag gradients
  16782. */
  16783. getDragGradients(): Nullable<Array<FactorGradient>>;
  16784. /**
  16785. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16786. * @param gradient defines the gradient to use (between 0 and 1)
  16787. * @param factor defines the emit rate to affect to the specified gradient
  16788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16789. * @returns the current particle system
  16790. */
  16791. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16792. /**
  16793. * Remove a specific emit rate gradient
  16794. * @param gradient defines the gradient to remove
  16795. * @returns the current particle system
  16796. */
  16797. removeEmitRateGradient(gradient: number): IParticleSystem;
  16798. /**
  16799. * Gets the current list of emit rate gradients.
  16800. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16801. * @returns the list of emit rate gradients
  16802. */
  16803. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16804. /**
  16805. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16806. * @param gradient defines the gradient to use (between 0 and 1)
  16807. * @param factor defines the start size to affect to the specified gradient
  16808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16809. * @returns the current particle system
  16810. */
  16811. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16812. /**
  16813. * Remove a specific start size gradient
  16814. * @param gradient defines the gradient to remove
  16815. * @returns the current particle system
  16816. */
  16817. removeStartSizeGradient(gradient: number): IParticleSystem;
  16818. /**
  16819. * Gets the current list of start size gradients.
  16820. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16821. * @returns the list of start size gradients
  16822. */
  16823. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16824. /**
  16825. * Adds a new life time gradient
  16826. * @param gradient defines the gradient to use (between 0 and 1)
  16827. * @param factor defines the life time factor to affect to the specified gradient
  16828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16829. * @returns the current particle system
  16830. */
  16831. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16832. /**
  16833. * Remove a specific life time gradient
  16834. * @param gradient defines the gradient to remove
  16835. * @returns the current particle system
  16836. */
  16837. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16838. /**
  16839. * Gets the current list of life time gradients.
  16840. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16841. * @returns the list of life time gradients
  16842. */
  16843. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16844. /**
  16845. * Gets the current list of color gradients.
  16846. * You must use addColorGradient and removeColorGradient to udpate this list
  16847. * @returns the list of color gradients
  16848. */
  16849. getColorGradients(): Nullable<Array<ColorGradient>>;
  16850. /**
  16851. * Adds a new ramp gradient used to remap particle colors
  16852. * @param gradient defines the gradient to use (between 0 and 1)
  16853. * @param color defines the color to affect to the specified gradient
  16854. * @returns the current particle system
  16855. */
  16856. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16857. /**
  16858. * Gets the current list of ramp gradients.
  16859. * You must use addRampGradient and removeRampGradient to udpate this list
  16860. * @returns the list of ramp gradients
  16861. */
  16862. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16863. /** Gets or sets a boolean indicating that ramp gradients must be used
  16864. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16865. */
  16866. useRampGradients: boolean;
  16867. /**
  16868. * Adds a new color remap gradient
  16869. * @param gradient defines the gradient to use (between 0 and 1)
  16870. * @param min defines the color remap minimal range
  16871. * @param max defines the color remap maximal range
  16872. * @returns the current particle system
  16873. */
  16874. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16875. /**
  16876. * Gets the current list of color remap gradients.
  16877. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16878. * @returns the list of color remap gradients
  16879. */
  16880. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16881. /**
  16882. * Adds a new alpha remap gradient
  16883. * @param gradient defines the gradient to use (between 0 and 1)
  16884. * @param min defines the alpha remap minimal range
  16885. * @param max defines the alpha remap maximal range
  16886. * @returns the current particle system
  16887. */
  16888. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16889. /**
  16890. * Gets the current list of alpha remap gradients.
  16891. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16892. * @returns the list of alpha remap gradients
  16893. */
  16894. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16895. /**
  16896. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16897. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16898. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16899. * @returns the emitter
  16900. */
  16901. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16902. /**
  16903. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16904. * @param radius The radius of the hemisphere to emit from
  16905. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16906. * @returns the emitter
  16907. */
  16908. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16909. /**
  16910. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16911. * @param radius The radius of the sphere to emit from
  16912. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16913. * @returns the emitter
  16914. */
  16915. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16916. /**
  16917. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16918. * @param radius The radius of the sphere to emit from
  16919. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16920. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16921. * @returns the emitter
  16922. */
  16923. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16924. /**
  16925. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16926. * @param radius The radius of the emission cylinder
  16927. * @param height The height of the emission cylinder
  16928. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16929. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16930. * @returns the emitter
  16931. */
  16932. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16933. /**
  16934. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16935. * @param radius The radius of the cylinder to emit from
  16936. * @param height The height of the emission cylinder
  16937. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16938. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16939. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16940. * @returns the emitter
  16941. */
  16942. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16943. /**
  16944. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16945. * @param radius The radius of the cone to emit from
  16946. * @param angle The base angle of the cone
  16947. * @returns the emitter
  16948. */
  16949. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16950. /**
  16951. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16952. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16953. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16954. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16955. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16956. * @returns the emitter
  16957. */
  16958. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16959. /**
  16960. * Get hosting scene
  16961. * @returns the scene
  16962. */
  16963. getScene(): Scene;
  16964. }
  16965. }
  16966. declare module "babylonjs/Shaders/line.fragment" {
  16967. /** @hidden */
  16968. export var linePixelShader: {
  16969. name: string;
  16970. shader: string;
  16971. };
  16972. }
  16973. declare module "babylonjs/Shaders/line.vertex" {
  16974. /** @hidden */
  16975. export var lineVertexShader: {
  16976. name: string;
  16977. shader: string;
  16978. };
  16979. }
  16980. declare module "babylonjs/Rendering/edgesRenderer" {
  16981. import { Nullable } from "babylonjs/types";
  16982. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16984. import { Vector3 } from "babylonjs/Maths/math";
  16985. import { IDisposable } from "babylonjs/scene";
  16986. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16987. import "babylonjs/Shaders/line.fragment";
  16988. import "babylonjs/Shaders/line.vertex";
  16989. module "babylonjs/Meshes/abstractMesh" {
  16990. interface AbstractMesh {
  16991. /**
  16992. * Disables the mesh edge rendering mode
  16993. * @returns the currentAbstractMesh
  16994. */
  16995. disableEdgesRendering(): AbstractMesh;
  16996. /**
  16997. * Enables the edge rendering mode on the mesh.
  16998. * This mode makes the mesh edges visible
  16999. * @param epsilon defines the maximal distance between two angles to detect a face
  17000. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17001. * @returns the currentAbstractMesh
  17002. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17003. */
  17004. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17005. /**
  17006. * Gets the edgesRenderer associated with the mesh
  17007. */
  17008. edgesRenderer: Nullable<EdgesRenderer>;
  17009. }
  17010. }
  17011. module "babylonjs/Meshes/linesMesh" {
  17012. interface LinesMesh {
  17013. /**
  17014. * Enables the edge rendering mode on the mesh.
  17015. * This mode makes the mesh edges visible
  17016. * @param epsilon defines the maximal distance between two angles to detect a face
  17017. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17018. * @returns the currentAbstractMesh
  17019. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17020. */
  17021. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17022. }
  17023. }
  17024. module "babylonjs/Meshes/linesMesh" {
  17025. interface InstancedLinesMesh {
  17026. /**
  17027. * Enables the edge rendering mode on the mesh.
  17028. * This mode makes the mesh edges visible
  17029. * @param epsilon defines the maximal distance between two angles to detect a face
  17030. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17031. * @returns the current InstancedLinesMesh
  17032. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17033. */
  17034. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17035. }
  17036. }
  17037. /**
  17038. * Defines the minimum contract an Edges renderer should follow.
  17039. */
  17040. export interface IEdgesRenderer extends IDisposable {
  17041. /**
  17042. * Gets or sets a boolean indicating if the edgesRenderer is active
  17043. */
  17044. isEnabled: boolean;
  17045. /**
  17046. * Renders the edges of the attached mesh,
  17047. */
  17048. render(): void;
  17049. /**
  17050. * Checks wether or not the edges renderer is ready to render.
  17051. * @return true if ready, otherwise false.
  17052. */
  17053. isReady(): boolean;
  17054. }
  17055. /**
  17056. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17057. */
  17058. export class EdgesRenderer implements IEdgesRenderer {
  17059. /**
  17060. * Define the size of the edges with an orthographic camera
  17061. */
  17062. edgesWidthScalerForOrthographic: number;
  17063. /**
  17064. * Define the size of the edges with a perspective camera
  17065. */
  17066. edgesWidthScalerForPerspective: number;
  17067. protected _source: AbstractMesh;
  17068. protected _linesPositions: number[];
  17069. protected _linesNormals: number[];
  17070. protected _linesIndices: number[];
  17071. protected _epsilon: number;
  17072. protected _indicesCount: number;
  17073. protected _lineShader: ShaderMaterial;
  17074. protected _ib: WebGLBuffer;
  17075. protected _buffers: {
  17076. [key: string]: Nullable<VertexBuffer>;
  17077. };
  17078. protected _checkVerticesInsteadOfIndices: boolean;
  17079. private _meshRebuildObserver;
  17080. private _meshDisposeObserver;
  17081. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17082. isEnabled: boolean;
  17083. /**
  17084. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17085. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17086. * @param source Mesh used to create edges
  17087. * @param epsilon sum of angles in adjacency to check for edge
  17088. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17089. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17090. */
  17091. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17092. protected _prepareRessources(): void;
  17093. /** @hidden */
  17094. _rebuild(): void;
  17095. /**
  17096. * Releases the required resources for the edges renderer
  17097. */
  17098. dispose(): void;
  17099. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17100. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17101. /**
  17102. * Checks if the pair of p0 and p1 is en edge
  17103. * @param faceIndex
  17104. * @param edge
  17105. * @param faceNormals
  17106. * @param p0
  17107. * @param p1
  17108. * @private
  17109. */
  17110. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17111. /**
  17112. * push line into the position, normal and index buffer
  17113. * @protected
  17114. */
  17115. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17116. /**
  17117. * Generates lines edges from adjacencjes
  17118. * @private
  17119. */
  17120. _generateEdgesLines(): void;
  17121. /**
  17122. * Checks wether or not the edges renderer is ready to render.
  17123. * @return true if ready, otherwise false.
  17124. */
  17125. isReady(): boolean;
  17126. /**
  17127. * Renders the edges of the attached mesh,
  17128. */
  17129. render(): void;
  17130. }
  17131. /**
  17132. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17133. */
  17134. export class LineEdgesRenderer extends EdgesRenderer {
  17135. /**
  17136. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17137. * @param source LineMesh used to generate edges
  17138. * @param epsilon not important (specified angle for edge detection)
  17139. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17140. */
  17141. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17142. /**
  17143. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17144. */
  17145. _generateEdgesLines(): void;
  17146. }
  17147. }
  17148. declare module "babylonjs/Rendering/renderingGroup" {
  17149. import { SmartArray } from "babylonjs/Misc/smartArray";
  17150. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17152. import { Nullable } from "babylonjs/types";
  17153. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17154. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17155. import { Material } from "babylonjs/Materials/material";
  17156. import { Scene } from "babylonjs/scene";
  17157. /**
  17158. * This represents the object necessary to create a rendering group.
  17159. * This is exclusively used and created by the rendering manager.
  17160. * To modify the behavior, you use the available helpers in your scene or meshes.
  17161. * @hidden
  17162. */
  17163. export class RenderingGroup {
  17164. index: number;
  17165. private _scene;
  17166. private _opaqueSubMeshes;
  17167. private _transparentSubMeshes;
  17168. private _alphaTestSubMeshes;
  17169. private _depthOnlySubMeshes;
  17170. private _particleSystems;
  17171. private _spriteManagers;
  17172. private _opaqueSortCompareFn;
  17173. private _alphaTestSortCompareFn;
  17174. private _transparentSortCompareFn;
  17175. private _renderOpaque;
  17176. private _renderAlphaTest;
  17177. private _renderTransparent;
  17178. private _edgesRenderers;
  17179. onBeforeTransparentRendering: () => void;
  17180. /**
  17181. * Set the opaque sort comparison function.
  17182. * If null the sub meshes will be render in the order they were created
  17183. */
  17184. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17185. /**
  17186. * Set the alpha test sort comparison function.
  17187. * If null the sub meshes will be render in the order they were created
  17188. */
  17189. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17190. /**
  17191. * Set the transparent sort comparison function.
  17192. * If null the sub meshes will be render in the order they were created
  17193. */
  17194. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17195. /**
  17196. * Creates a new rendering group.
  17197. * @param index The rendering group index
  17198. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17199. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17200. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17201. */
  17202. 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>);
  17203. /**
  17204. * Render all the sub meshes contained in the group.
  17205. * @param customRenderFunction Used to override the default render behaviour of the group.
  17206. * @returns true if rendered some submeshes.
  17207. */
  17208. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17209. /**
  17210. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17211. * @param subMeshes The submeshes to render
  17212. */
  17213. private renderOpaqueSorted;
  17214. /**
  17215. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17216. * @param subMeshes The submeshes to render
  17217. */
  17218. private renderAlphaTestSorted;
  17219. /**
  17220. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17221. * @param subMeshes The submeshes to render
  17222. */
  17223. private renderTransparentSorted;
  17224. /**
  17225. * Renders the submeshes in a specified order.
  17226. * @param subMeshes The submeshes to sort before render
  17227. * @param sortCompareFn The comparison function use to sort
  17228. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17229. * @param transparent Specifies to activate blending if true
  17230. */
  17231. private static renderSorted;
  17232. /**
  17233. * Renders the submeshes in the order they were dispatched (no sort applied).
  17234. * @param subMeshes The submeshes to render
  17235. */
  17236. private static renderUnsorted;
  17237. /**
  17238. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17239. * are rendered back to front if in the same alpha index.
  17240. *
  17241. * @param a The first submesh
  17242. * @param b The second submesh
  17243. * @returns The result of the comparison
  17244. */
  17245. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  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.
  17249. *
  17250. * @param a The first submesh
  17251. * @param b The second submesh
  17252. * @returns The result of the comparison
  17253. */
  17254. static backToFrontSortCompare(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 front to back (prevent overdraw).
  17258. *
  17259. * @param a The first submesh
  17260. * @param b The second submesh
  17261. * @returns The result of the comparison
  17262. */
  17263. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17264. /**
  17265. * Resets the different lists of submeshes to prepare a new frame.
  17266. */
  17267. prepare(): void;
  17268. dispose(): void;
  17269. /**
  17270. * Inserts the submesh in its correct queue depending on its material.
  17271. * @param subMesh The submesh to dispatch
  17272. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17273. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17274. */
  17275. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17276. dispatchSprites(spriteManager: ISpriteManager): void;
  17277. dispatchParticles(particleSystem: IParticleSystem): void;
  17278. private _renderParticles;
  17279. private _renderSprites;
  17280. }
  17281. }
  17282. declare module "babylonjs/Rendering/renderingManager" {
  17283. import { Nullable } from "babylonjs/types";
  17284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17285. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17286. import { SmartArray } from "babylonjs/Misc/smartArray";
  17287. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17288. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17289. import { Material } from "babylonjs/Materials/material";
  17290. import { Scene } from "babylonjs/scene";
  17291. import { Camera } from "babylonjs/Cameras/camera";
  17292. /**
  17293. * Interface describing the different options available in the rendering manager
  17294. * regarding Auto Clear between groups.
  17295. */
  17296. export interface IRenderingManagerAutoClearSetup {
  17297. /**
  17298. * Defines whether or not autoclear is enable.
  17299. */
  17300. autoClear: boolean;
  17301. /**
  17302. * Defines whether or not to autoclear the depth buffer.
  17303. */
  17304. depth: boolean;
  17305. /**
  17306. * Defines whether or not to autoclear the stencil buffer.
  17307. */
  17308. stencil: boolean;
  17309. }
  17310. /**
  17311. * This class is used by the onRenderingGroupObservable
  17312. */
  17313. export class RenderingGroupInfo {
  17314. /**
  17315. * The Scene that being rendered
  17316. */
  17317. scene: Scene;
  17318. /**
  17319. * The camera currently used for the rendering pass
  17320. */
  17321. camera: Nullable<Camera>;
  17322. /**
  17323. * The ID of the renderingGroup being processed
  17324. */
  17325. renderingGroupId: number;
  17326. }
  17327. /**
  17328. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17329. * It is enable to manage the different groups as well as the different necessary sort functions.
  17330. * This should not be used directly aside of the few static configurations
  17331. */
  17332. export class RenderingManager {
  17333. /**
  17334. * The max id used for rendering groups (not included)
  17335. */
  17336. static MAX_RENDERINGGROUPS: number;
  17337. /**
  17338. * The min id used for rendering groups (included)
  17339. */
  17340. static MIN_RENDERINGGROUPS: number;
  17341. /**
  17342. * Used to globally prevent autoclearing scenes.
  17343. */
  17344. static AUTOCLEAR: boolean;
  17345. /**
  17346. * @hidden
  17347. */
  17348. _useSceneAutoClearSetup: boolean;
  17349. private _scene;
  17350. private _renderingGroups;
  17351. private _depthStencilBufferAlreadyCleaned;
  17352. private _autoClearDepthStencil;
  17353. private _customOpaqueSortCompareFn;
  17354. private _customAlphaTestSortCompareFn;
  17355. private _customTransparentSortCompareFn;
  17356. private _renderingGroupInfo;
  17357. /**
  17358. * Instantiates a new rendering group for a particular scene
  17359. * @param scene Defines the scene the groups belongs to
  17360. */
  17361. constructor(scene: Scene);
  17362. private _clearDepthStencilBuffer;
  17363. /**
  17364. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17365. * @hidden
  17366. */
  17367. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17368. /**
  17369. * Resets the different information of the group to prepare a new frame
  17370. * @hidden
  17371. */
  17372. reset(): void;
  17373. /**
  17374. * Dispose and release the group and its associated resources.
  17375. * @hidden
  17376. */
  17377. dispose(): void;
  17378. /**
  17379. * Clear the info related to rendering groups preventing retention points during dispose.
  17380. */
  17381. freeRenderingGroups(): void;
  17382. private _prepareRenderingGroup;
  17383. /**
  17384. * Add a sprite manager to the rendering manager in order to render it this frame.
  17385. * @param spriteManager Define the sprite manager to render
  17386. */
  17387. dispatchSprites(spriteManager: ISpriteManager): void;
  17388. /**
  17389. * Add a particle system to the rendering manager in order to render it this frame.
  17390. * @param particleSystem Define the particle system to render
  17391. */
  17392. dispatchParticles(particleSystem: IParticleSystem): void;
  17393. /**
  17394. * Add a submesh to the manager in order to render it this frame
  17395. * @param subMesh The submesh to dispatch
  17396. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17397. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17398. */
  17399. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17400. /**
  17401. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17402. * This allowed control for front to back rendering or reversly depending of the special needs.
  17403. *
  17404. * @param renderingGroupId The rendering group id corresponding to its index
  17405. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17406. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17407. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17408. */
  17409. 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;
  17410. /**
  17411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17412. *
  17413. * @param renderingGroupId The rendering group id corresponding to its index
  17414. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17415. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17416. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17417. */
  17418. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17419. /**
  17420. * Gets the current auto clear configuration for one rendering group of the rendering
  17421. * manager.
  17422. * @param index the rendering group index to get the information for
  17423. * @returns The auto clear setup for the requested rendering group
  17424. */
  17425. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17426. }
  17427. }
  17428. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17429. import { Observable } from "babylonjs/Misc/observable";
  17430. import { SmartArray } from "babylonjs/Misc/smartArray";
  17431. import { Nullable } from "babylonjs/types";
  17432. import { Camera } from "babylonjs/Cameras/camera";
  17433. import { Scene } from "babylonjs/scene";
  17434. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17435. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17437. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17438. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17439. import { Texture } from "babylonjs/Materials/Textures/texture";
  17440. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17441. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17442. import { Engine } from "babylonjs/Engines/engine";
  17443. /**
  17444. * This Helps creating a texture that will be created from a camera in your scene.
  17445. * It is basically a dynamic texture that could be used to create special effects for instance.
  17446. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17447. */
  17448. export class RenderTargetTexture extends Texture {
  17449. isCube: boolean;
  17450. /**
  17451. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17452. */
  17453. static readonly REFRESHRATE_RENDER_ONCE: number;
  17454. /**
  17455. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17456. */
  17457. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17458. /**
  17459. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17460. * the central point of your effect and can save a lot of performances.
  17461. */
  17462. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17463. /**
  17464. * Use this predicate to dynamically define the list of mesh you want to render.
  17465. * If set, the renderList property will be overwritten.
  17466. */
  17467. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17468. private _renderList;
  17469. /**
  17470. * Use this list to define the list of mesh you want to render.
  17471. */
  17472. renderList: Nullable<Array<AbstractMesh>>;
  17473. private _hookArray;
  17474. /**
  17475. * Define if particles should be rendered in your texture.
  17476. */
  17477. renderParticles: boolean;
  17478. /**
  17479. * Define if sprites should be rendered in your texture.
  17480. */
  17481. renderSprites: boolean;
  17482. /**
  17483. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17484. */
  17485. coordinatesMode: number;
  17486. /**
  17487. * Define the camera used to render the texture.
  17488. */
  17489. activeCamera: Nullable<Camera>;
  17490. /**
  17491. * Override the render function of the texture with your own one.
  17492. */
  17493. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17494. /**
  17495. * Define if camera post processes should be use while rendering the texture.
  17496. */
  17497. useCameraPostProcesses: boolean;
  17498. /**
  17499. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17500. */
  17501. ignoreCameraViewport: boolean;
  17502. private _postProcessManager;
  17503. private _postProcesses;
  17504. private _resizeObserver;
  17505. /**
  17506. * An event triggered when the texture is unbind.
  17507. */
  17508. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17509. /**
  17510. * An event triggered when the texture is unbind.
  17511. */
  17512. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17513. private _onAfterUnbindObserver;
  17514. /**
  17515. * Set a after unbind callback in the texture.
  17516. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17517. */
  17518. onAfterUnbind: () => void;
  17519. /**
  17520. * An event triggered before rendering the texture
  17521. */
  17522. onBeforeRenderObservable: Observable<number>;
  17523. private _onBeforeRenderObserver;
  17524. /**
  17525. * Set a before render callback in the texture.
  17526. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17527. */
  17528. onBeforeRender: (faceIndex: number) => void;
  17529. /**
  17530. * An event triggered after rendering the texture
  17531. */
  17532. onAfterRenderObservable: Observable<number>;
  17533. private _onAfterRenderObserver;
  17534. /**
  17535. * Set a after render callback in the texture.
  17536. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17537. */
  17538. onAfterRender: (faceIndex: number) => void;
  17539. /**
  17540. * An event triggered after the texture clear
  17541. */
  17542. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17543. private _onClearObserver;
  17544. /**
  17545. * Set a clear callback in the texture.
  17546. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17547. */
  17548. onClear: (Engine: Engine) => void;
  17549. /**
  17550. * Define the clear color of the Render Target if it should be different from the scene.
  17551. */
  17552. clearColor: Color4;
  17553. protected _size: number | {
  17554. width: number;
  17555. height: number;
  17556. };
  17557. protected _initialSizeParameter: number | {
  17558. width: number;
  17559. height: number;
  17560. } | {
  17561. ratio: number;
  17562. };
  17563. protected _sizeRatio: Nullable<number>;
  17564. /** @hidden */
  17565. _generateMipMaps: boolean;
  17566. protected _renderingManager: RenderingManager;
  17567. /** @hidden */
  17568. _waitingRenderList: string[];
  17569. protected _doNotChangeAspectRatio: boolean;
  17570. protected _currentRefreshId: number;
  17571. protected _refreshRate: number;
  17572. protected _textureMatrix: Matrix;
  17573. protected _samples: number;
  17574. protected _renderTargetOptions: RenderTargetCreationOptions;
  17575. /**
  17576. * Gets render target creation options that were used.
  17577. */
  17578. readonly renderTargetOptions: RenderTargetCreationOptions;
  17579. protected _engine: Engine;
  17580. protected _onRatioRescale(): void;
  17581. /**
  17582. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17583. * It must define where the camera used to render the texture is set
  17584. */
  17585. boundingBoxPosition: Vector3;
  17586. private _boundingBoxSize;
  17587. /**
  17588. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17589. * When defined, the cubemap will switch to local mode
  17590. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17591. * @example https://www.babylonjs-playground.com/#RNASML
  17592. */
  17593. boundingBoxSize: Vector3;
  17594. /**
  17595. * In case the RTT has been created with a depth texture, get the associated
  17596. * depth texture.
  17597. * Otherwise, return null.
  17598. */
  17599. depthStencilTexture: Nullable<InternalTexture>;
  17600. /**
  17601. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17602. * or used a shadow, depth texture...
  17603. * @param name The friendly name of the texture
  17604. * @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)
  17605. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17606. * @param generateMipMaps True if mip maps need to be generated after render.
  17607. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17608. * @param type The type of the buffer in the RTT (int, half float, float...)
  17609. * @param isCube True if a cube texture needs to be created
  17610. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17611. * @param generateDepthBuffer True to generate a depth buffer
  17612. * @param generateStencilBuffer True to generate a stencil buffer
  17613. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17614. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17615. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17616. */
  17617. constructor(name: string, size: number | {
  17618. width: number;
  17619. height: number;
  17620. } | {
  17621. ratio: number;
  17622. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17623. /**
  17624. * Creates a depth stencil texture.
  17625. * This is only available in WebGL 2 or with the depth texture extension available.
  17626. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17627. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17628. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17629. */
  17630. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17631. private _processSizeParameter;
  17632. /**
  17633. * Define the number of samples to use in case of MSAA.
  17634. * It defaults to one meaning no MSAA has been enabled.
  17635. */
  17636. samples: number;
  17637. /**
  17638. * Resets the refresh counter of the texture and start bak from scratch.
  17639. * Could be useful to regenerate the texture if it is setup to render only once.
  17640. */
  17641. resetRefreshCounter(): void;
  17642. /**
  17643. * Define the refresh rate of the texture or the rendering frequency.
  17644. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17645. */
  17646. refreshRate: number;
  17647. /**
  17648. * Adds a post process to the render target rendering passes.
  17649. * @param postProcess define the post process to add
  17650. */
  17651. addPostProcess(postProcess: PostProcess): void;
  17652. /**
  17653. * Clear all the post processes attached to the render target
  17654. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17655. */
  17656. clearPostProcesses(dispose?: boolean): void;
  17657. /**
  17658. * Remove one of the post process from the list of attached post processes to the texture
  17659. * @param postProcess define the post process to remove from the list
  17660. */
  17661. removePostProcess(postProcess: PostProcess): void;
  17662. /** @hidden */
  17663. _shouldRender(): boolean;
  17664. /**
  17665. * Gets the actual render size of the texture.
  17666. * @returns the width of the render size
  17667. */
  17668. getRenderSize(): number;
  17669. /**
  17670. * Gets the actual render width of the texture.
  17671. * @returns the width of the render size
  17672. */
  17673. getRenderWidth(): number;
  17674. /**
  17675. * Gets the actual render height of the texture.
  17676. * @returns the height of the render size
  17677. */
  17678. getRenderHeight(): number;
  17679. /**
  17680. * Get if the texture can be rescaled or not.
  17681. */
  17682. readonly canRescale: boolean;
  17683. /**
  17684. * Resize the texture using a ratio.
  17685. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17686. */
  17687. scale(ratio: number): void;
  17688. /**
  17689. * Get the texture reflection matrix used to rotate/transform the reflection.
  17690. * @returns the reflection matrix
  17691. */
  17692. getReflectionTextureMatrix(): Matrix;
  17693. /**
  17694. * Resize the texture to a new desired size.
  17695. * Be carrefull as it will recreate all the data in the new texture.
  17696. * @param size Define the new size. It can be:
  17697. * - a number for squared texture,
  17698. * - an object containing { width: number, height: number }
  17699. * - or an object containing a ratio { ratio: number }
  17700. */
  17701. resize(size: number | {
  17702. width: number;
  17703. height: number;
  17704. } | {
  17705. ratio: number;
  17706. }): void;
  17707. /**
  17708. * Renders all the objects from the render list into the texture.
  17709. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17710. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17711. */
  17712. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17713. private _bestReflectionRenderTargetDimension;
  17714. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17715. private renderToTarget;
  17716. /**
  17717. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17718. * This allowed control for front to back rendering or reversly depending of the special needs.
  17719. *
  17720. * @param renderingGroupId The rendering group id corresponding to its index
  17721. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17722. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17723. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17724. */
  17725. 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;
  17726. /**
  17727. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17728. *
  17729. * @param renderingGroupId The rendering group id corresponding to its index
  17730. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17731. */
  17732. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17733. /**
  17734. * Clones the texture.
  17735. * @returns the cloned texture
  17736. */
  17737. clone(): RenderTargetTexture;
  17738. /**
  17739. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17740. * @returns The JSON representation of the texture
  17741. */
  17742. serialize(): any;
  17743. /**
  17744. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17745. */
  17746. disposeFramebufferObjects(): void;
  17747. /**
  17748. * Dispose the texture and release its associated resources.
  17749. */
  17750. dispose(): void;
  17751. /** @hidden */
  17752. _rebuild(): void;
  17753. /**
  17754. * Clear the info related to rendering groups preventing retention point in material dispose.
  17755. */
  17756. freeRenderingGroups(): void;
  17757. }
  17758. }
  17759. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17760. import { Scene } from "babylonjs/scene";
  17761. import { Plane } from "babylonjs/Maths/math";
  17762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17763. /**
  17764. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17765. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17766. * You can then easily use it as a reflectionTexture on a flat surface.
  17767. * In case the surface is not a plane, please consider relying on reflection probes.
  17768. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17769. */
  17770. export class MirrorTexture extends RenderTargetTexture {
  17771. private scene;
  17772. /**
  17773. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17774. * 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.
  17775. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17776. */
  17777. mirrorPlane: Plane;
  17778. /**
  17779. * Define the blur ratio used to blur the reflection if needed.
  17780. */
  17781. blurRatio: number;
  17782. /**
  17783. * Define the adaptive blur kernel used to blur the reflection if needed.
  17784. * This will autocompute the closest best match for the `blurKernel`
  17785. */
  17786. adaptiveBlurKernel: number;
  17787. /**
  17788. * Define the blur kernel used to blur the reflection if needed.
  17789. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17790. */
  17791. blurKernel: number;
  17792. /**
  17793. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17794. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17795. */
  17796. blurKernelX: number;
  17797. /**
  17798. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17799. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17800. */
  17801. blurKernelY: number;
  17802. private _autoComputeBlurKernel;
  17803. protected _onRatioRescale(): void;
  17804. private _updateGammaSpace;
  17805. private _imageProcessingConfigChangeObserver;
  17806. private _transformMatrix;
  17807. private _mirrorMatrix;
  17808. private _savedViewMatrix;
  17809. private _blurX;
  17810. private _blurY;
  17811. private _adaptiveBlurKernel;
  17812. private _blurKernelX;
  17813. private _blurKernelY;
  17814. private _blurRatio;
  17815. /**
  17816. * Instantiates a Mirror Texture.
  17817. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17818. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17819. * You can then easily use it as a reflectionTexture on a flat surface.
  17820. * In case the surface is not a plane, please consider relying on reflection probes.
  17821. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17822. * @param name
  17823. * @param size
  17824. * @param scene
  17825. * @param generateMipMaps
  17826. * @param type
  17827. * @param samplingMode
  17828. * @param generateDepthBuffer
  17829. */
  17830. constructor(name: string, size: number | {
  17831. width: number;
  17832. height: number;
  17833. } | {
  17834. ratio: number;
  17835. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17836. private _preparePostProcesses;
  17837. /**
  17838. * Clone the mirror texture.
  17839. * @returns the cloned texture
  17840. */
  17841. clone(): MirrorTexture;
  17842. /**
  17843. * Serialize the texture to a JSON representation you could use in Parse later on
  17844. * @returns the serialized JSON representation
  17845. */
  17846. serialize(): any;
  17847. /**
  17848. * Dispose the texture and release its associated resources.
  17849. */
  17850. dispose(): void;
  17851. }
  17852. }
  17853. declare module "babylonjs/Materials/Textures/texture" {
  17854. import { Observable } from "babylonjs/Misc/observable";
  17855. import { Nullable } from "babylonjs/types";
  17856. import { Scene } from "babylonjs/scene";
  17857. import { Matrix } from "babylonjs/Maths/math";
  17858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17859. /**
  17860. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17861. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17862. */
  17863. export class Texture extends BaseTexture {
  17864. /** @hidden */
  17865. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17866. /** @hidden */
  17867. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17868. /** @hidden */
  17869. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17870. /** nearest is mag = nearest and min = nearest and mip = linear */
  17871. static readonly NEAREST_SAMPLINGMODE: number;
  17872. /** nearest is mag = nearest and min = nearest and mip = linear */
  17873. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17874. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17875. static readonly BILINEAR_SAMPLINGMODE: number;
  17876. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17877. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17878. /** Trilinear is mag = linear and min = linear and mip = linear */
  17879. static readonly TRILINEAR_SAMPLINGMODE: number;
  17880. /** Trilinear is mag = linear and min = linear and mip = linear */
  17881. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17882. /** mag = nearest and min = nearest and mip = nearest */
  17883. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17884. /** mag = nearest and min = linear and mip = nearest */
  17885. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17886. /** mag = nearest and min = linear and mip = linear */
  17887. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17888. /** mag = nearest and min = linear and mip = none */
  17889. static readonly NEAREST_LINEAR: number;
  17890. /** mag = nearest and min = nearest and mip = none */
  17891. static readonly NEAREST_NEAREST: number;
  17892. /** mag = linear and min = nearest and mip = nearest */
  17893. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17894. /** mag = linear and min = nearest and mip = linear */
  17895. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17896. /** mag = linear and min = linear and mip = none */
  17897. static readonly LINEAR_LINEAR: number;
  17898. /** mag = linear and min = nearest and mip = none */
  17899. static readonly LINEAR_NEAREST: number;
  17900. /** Explicit coordinates mode */
  17901. static readonly EXPLICIT_MODE: number;
  17902. /** Spherical coordinates mode */
  17903. static readonly SPHERICAL_MODE: number;
  17904. /** Planar coordinates mode */
  17905. static readonly PLANAR_MODE: number;
  17906. /** Cubic coordinates mode */
  17907. static readonly CUBIC_MODE: number;
  17908. /** Projection coordinates mode */
  17909. static readonly PROJECTION_MODE: number;
  17910. /** Inverse Cubic coordinates mode */
  17911. static readonly SKYBOX_MODE: number;
  17912. /** Inverse Cubic coordinates mode */
  17913. static readonly INVCUBIC_MODE: number;
  17914. /** Equirectangular coordinates mode */
  17915. static readonly EQUIRECTANGULAR_MODE: number;
  17916. /** Equirectangular Fixed coordinates mode */
  17917. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17918. /** Equirectangular Fixed Mirrored coordinates mode */
  17919. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17920. /** Texture is not repeating outside of 0..1 UVs */
  17921. static readonly CLAMP_ADDRESSMODE: number;
  17922. /** Texture is repeating outside of 0..1 UVs */
  17923. static readonly WRAP_ADDRESSMODE: number;
  17924. /** Texture is repeating and mirrored */
  17925. static readonly MIRROR_ADDRESSMODE: number;
  17926. /**
  17927. * 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
  17928. */
  17929. static UseSerializedUrlIfAny: boolean;
  17930. /**
  17931. * Define the url of the texture.
  17932. */
  17933. url: Nullable<string>;
  17934. /**
  17935. * Define an offset on the texture to offset the u coordinates of the UVs
  17936. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17937. */
  17938. uOffset: number;
  17939. /**
  17940. * Define an offset on the texture to offset the v coordinates of the UVs
  17941. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17942. */
  17943. vOffset: number;
  17944. /**
  17945. * Define an offset on the texture to scale the u coordinates of the UVs
  17946. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17947. */
  17948. uScale: number;
  17949. /**
  17950. * Define an offset on the texture to scale the v coordinates of the UVs
  17951. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17952. */
  17953. vScale: number;
  17954. /**
  17955. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17956. * @see http://doc.babylonjs.com/how_to/more_materials
  17957. */
  17958. uAng: number;
  17959. /**
  17960. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17961. * @see http://doc.babylonjs.com/how_to/more_materials
  17962. */
  17963. vAng: number;
  17964. /**
  17965. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17966. * @see http://doc.babylonjs.com/how_to/more_materials
  17967. */
  17968. wAng: number;
  17969. /**
  17970. * Defines the center of rotation (U)
  17971. */
  17972. uRotationCenter: number;
  17973. /**
  17974. * Defines the center of rotation (V)
  17975. */
  17976. vRotationCenter: number;
  17977. /**
  17978. * Defines the center of rotation (W)
  17979. */
  17980. wRotationCenter: number;
  17981. /**
  17982. * Are mip maps generated for this texture or not.
  17983. */
  17984. readonly noMipmap: boolean;
  17985. private _noMipmap;
  17986. /** @hidden */
  17987. _invertY: boolean;
  17988. private _rowGenerationMatrix;
  17989. private _cachedTextureMatrix;
  17990. private _projectionModeMatrix;
  17991. private _t0;
  17992. private _t1;
  17993. private _t2;
  17994. private _cachedUOffset;
  17995. private _cachedVOffset;
  17996. private _cachedUScale;
  17997. private _cachedVScale;
  17998. private _cachedUAng;
  17999. private _cachedVAng;
  18000. private _cachedWAng;
  18001. private _cachedProjectionMatrixId;
  18002. private _cachedCoordinatesMode;
  18003. /** @hidden */
  18004. protected _initialSamplingMode: number;
  18005. /** @hidden */
  18006. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18007. private _deleteBuffer;
  18008. protected _format: Nullable<number>;
  18009. private _delayedOnLoad;
  18010. private _delayedOnError;
  18011. /**
  18012. * Observable triggered once the texture has been loaded.
  18013. */
  18014. onLoadObservable: Observable<Texture>;
  18015. protected _isBlocking: boolean;
  18016. /**
  18017. * Is the texture preventing material to render while loading.
  18018. * If false, a default texture will be used instead of the loading one during the preparation step.
  18019. */
  18020. isBlocking: boolean;
  18021. /**
  18022. * Get the current sampling mode associated with the texture.
  18023. */
  18024. readonly samplingMode: number;
  18025. /**
  18026. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18027. */
  18028. readonly invertY: boolean;
  18029. /**
  18030. * Instantiates a new texture.
  18031. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18032. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18033. * @param url define the url of the picture to load as a texture
  18034. * @param scene define the scene the texture will belong to
  18035. * @param noMipmap define if the texture will require mip maps or not
  18036. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18037. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18038. * @param onLoad define a callback triggered when the texture has been loaded
  18039. * @param onError define a callback triggered when an error occurred during the loading session
  18040. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18041. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18042. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18043. */
  18044. 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);
  18045. /**
  18046. * Update the url (and optional buffer) of this texture if url was null during construction.
  18047. * @param url the url of the texture
  18048. * @param buffer the buffer of the texture (defaults to null)
  18049. * @param onLoad callback called when the texture is loaded (defaults to null)
  18050. */
  18051. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18052. /**
  18053. * Finish the loading sequence of a texture flagged as delayed load.
  18054. * @hidden
  18055. */
  18056. delayLoad(): void;
  18057. private _prepareRowForTextureGeneration;
  18058. /**
  18059. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18060. * @returns the transform matrix of the texture.
  18061. */
  18062. getTextureMatrix(): Matrix;
  18063. /**
  18064. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18065. * @returns The reflection texture transform
  18066. */
  18067. getReflectionTextureMatrix(): Matrix;
  18068. /**
  18069. * Clones the texture.
  18070. * @returns the cloned texture
  18071. */
  18072. clone(): Texture;
  18073. /**
  18074. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18075. * @returns The JSON representation of the texture
  18076. */
  18077. serialize(): any;
  18078. /**
  18079. * Get the current class name of the texture useful for serialization or dynamic coding.
  18080. * @returns "Texture"
  18081. */
  18082. getClassName(): string;
  18083. /**
  18084. * Dispose the texture and release its associated resources.
  18085. */
  18086. dispose(): void;
  18087. /**
  18088. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18089. * @param parsedTexture Define the JSON representation of the texture
  18090. * @param scene Define the scene the parsed texture should be instantiated in
  18091. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18092. * @returns The parsed texture if successful
  18093. */
  18094. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18095. /**
  18096. * Creates a texture from its base 64 representation.
  18097. * @param data Define the base64 payload without the data: prefix
  18098. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18099. * @param scene Define the scene the texture should belong to
  18100. * @param noMipmap Forces the texture to not create mip map information if true
  18101. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18102. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18103. * @param onLoad define a callback triggered when the texture has been loaded
  18104. * @param onError define a callback triggered when an error occurred during the loading session
  18105. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18106. * @returns the created texture
  18107. */
  18108. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18109. /**
  18110. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18111. * @param data Define the base64 payload without the data: prefix
  18112. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18113. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18114. * @param scene Define the scene the texture should belong to
  18115. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18116. * @param noMipmap Forces the texture to not create mip map information if true
  18117. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18118. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18119. * @param onLoad define a callback triggered when the texture has been loaded
  18120. * @param onError define a callback triggered when an error occurred during the loading session
  18121. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18122. * @returns the created texture
  18123. */
  18124. 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;
  18125. }
  18126. }
  18127. declare module "babylonjs/Materials/shaderMaterial" {
  18128. import { Scene } from "babylonjs/scene";
  18129. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  18130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18131. import { Mesh } from "babylonjs/Meshes/mesh";
  18132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18133. import { Texture } from "babylonjs/Materials/Textures/texture";
  18134. import { Material } from "babylonjs/Materials/material";
  18135. /**
  18136. * Defines the options associated with the creation of a shader material.
  18137. */
  18138. export interface IShaderMaterialOptions {
  18139. /**
  18140. * Does the material work in alpha blend mode
  18141. */
  18142. needAlphaBlending: boolean;
  18143. /**
  18144. * Does the material work in alpha test mode
  18145. */
  18146. needAlphaTesting: boolean;
  18147. /**
  18148. * The list of attribute names used in the shader
  18149. */
  18150. attributes: string[];
  18151. /**
  18152. * The list of unifrom names used in the shader
  18153. */
  18154. uniforms: string[];
  18155. /**
  18156. * The list of UBO names used in the shader
  18157. */
  18158. uniformBuffers: string[];
  18159. /**
  18160. * The list of sampler names used in the shader
  18161. */
  18162. samplers: string[];
  18163. /**
  18164. * The list of defines used in the shader
  18165. */
  18166. defines: string[];
  18167. }
  18168. /**
  18169. * 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.
  18170. *
  18171. * This returned material effects how the mesh will look based on the code in the shaders.
  18172. *
  18173. * @see http://doc.babylonjs.com/how_to/shader_material
  18174. */
  18175. export class ShaderMaterial extends Material {
  18176. private _shaderPath;
  18177. private _options;
  18178. private _textures;
  18179. private _textureArrays;
  18180. private _floats;
  18181. private _ints;
  18182. private _floatsArrays;
  18183. private _colors3;
  18184. private _colors3Arrays;
  18185. private _colors4;
  18186. private _vectors2;
  18187. private _vectors3;
  18188. private _vectors4;
  18189. private _matrices;
  18190. private _matrices3x3;
  18191. private _matrices2x2;
  18192. private _vectors2Arrays;
  18193. private _vectors3Arrays;
  18194. private _cachedWorldViewMatrix;
  18195. private _renderId;
  18196. /**
  18197. * Instantiate a new shader material.
  18198. * 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.
  18199. * This returned material effects how the mesh will look based on the code in the shaders.
  18200. * @see http://doc.babylonjs.com/how_to/shader_material
  18201. * @param name Define the name of the material in the scene
  18202. * @param scene Define the scene the material belongs to
  18203. * @param shaderPath Defines the route to the shader code in one of three ways:
  18204. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18205. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18206. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18207. * @param options Define the options used to create the shader
  18208. */
  18209. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18210. /**
  18211. * Gets the current class name of the material e.g. "ShaderMaterial"
  18212. * Mainly use in serialization.
  18213. * @returns the class name
  18214. */
  18215. getClassName(): string;
  18216. /**
  18217. * Specifies if the material will require alpha blending
  18218. * @returns a boolean specifying if alpha blending is needed
  18219. */
  18220. needAlphaBlending(): boolean;
  18221. /**
  18222. * Specifies if this material should be rendered in alpha test mode
  18223. * @returns a boolean specifying if an alpha test is needed.
  18224. */
  18225. needAlphaTesting(): boolean;
  18226. private _checkUniform;
  18227. /**
  18228. * Set a texture in the shader.
  18229. * @param name Define the name of the uniform samplers as defined in the shader
  18230. * @param texture Define the texture to bind to this sampler
  18231. * @return the material itself allowing "fluent" like uniform updates
  18232. */
  18233. setTexture(name: string, texture: Texture): ShaderMaterial;
  18234. /**
  18235. * Set a texture array in the shader.
  18236. * @param name Define the name of the uniform sampler array as defined in the shader
  18237. * @param textures Define the list of textures to bind to this sampler
  18238. * @return the material itself allowing "fluent" like uniform updates
  18239. */
  18240. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18241. /**
  18242. * Set a float in the shader.
  18243. * @param name Define the name of the uniform as defined in the shader
  18244. * @param value Define the value to give to the uniform
  18245. * @return the material itself allowing "fluent" like uniform updates
  18246. */
  18247. setFloat(name: string, value: number): ShaderMaterial;
  18248. /**
  18249. * Set a int in the shader.
  18250. * @param name Define the name of the uniform as defined in the shader
  18251. * @param value Define the value to give to the uniform
  18252. * @return the material itself allowing "fluent" like uniform updates
  18253. */
  18254. setInt(name: string, value: number): ShaderMaterial;
  18255. /**
  18256. * Set an array of floats in the shader.
  18257. * @param name Define the name of the uniform as defined in the shader
  18258. * @param value Define the value to give to the uniform
  18259. * @return the material itself allowing "fluent" like uniform updates
  18260. */
  18261. setFloats(name: string, value: number[]): ShaderMaterial;
  18262. /**
  18263. * Set a vec3 in the shader from a Color3.
  18264. * @param name Define the name of the uniform as defined in the shader
  18265. * @param value Define the value to give to the uniform
  18266. * @return the material itself allowing "fluent" like uniform updates
  18267. */
  18268. setColor3(name: string, value: Color3): ShaderMaterial;
  18269. /**
  18270. * Set a vec3 array in the shader from a Color3 array.
  18271. * @param name Define the name of the uniform as defined in the shader
  18272. * @param value Define the value to give to the uniform
  18273. * @return the material itself allowing "fluent" like uniform updates
  18274. */
  18275. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18276. /**
  18277. * Set a vec4 in the shader from a Color4.
  18278. * @param name Define the name of the uniform as defined in the shader
  18279. * @param value Define the value to give to the uniform
  18280. * @return the material itself allowing "fluent" like uniform updates
  18281. */
  18282. setColor4(name: string, value: Color4): ShaderMaterial;
  18283. /**
  18284. * Set a vec2 in the shader from a Vector2.
  18285. * @param name Define the name of the uniform as defined in the shader
  18286. * @param value Define the value to give to the uniform
  18287. * @return the material itself allowing "fluent" like uniform updates
  18288. */
  18289. setVector2(name: string, value: Vector2): ShaderMaterial;
  18290. /**
  18291. * Set a vec3 in the shader from a Vector3.
  18292. * @param name Define the name of the uniform as defined in the shader
  18293. * @param value Define the value to give to the uniform
  18294. * @return the material itself allowing "fluent" like uniform updates
  18295. */
  18296. setVector3(name: string, value: Vector3): ShaderMaterial;
  18297. /**
  18298. * Set a vec4 in the shader from a Vector4.
  18299. * @param name Define the name of the uniform as defined in the shader
  18300. * @param value Define the value to give to the uniform
  18301. * @return the material itself allowing "fluent" like uniform updates
  18302. */
  18303. setVector4(name: string, value: Vector4): ShaderMaterial;
  18304. /**
  18305. * Set a mat4 in the shader from a Matrix.
  18306. * @param name Define the name of the uniform as defined in the shader
  18307. * @param value Define the value to give to the uniform
  18308. * @return the material itself allowing "fluent" like uniform updates
  18309. */
  18310. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18311. /**
  18312. * Set a mat3 in the shader from a Float32Array.
  18313. * @param name Define the name of the uniform as defined in the shader
  18314. * @param value Define the value to give to the uniform
  18315. * @return the material itself allowing "fluent" like uniform updates
  18316. */
  18317. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18318. /**
  18319. * Set a mat2 in the shader from a Float32Array.
  18320. * @param name Define the name of the uniform as defined in the shader
  18321. * @param value Define the value to give to the uniform
  18322. * @return the material itself allowing "fluent" like uniform updates
  18323. */
  18324. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18325. /**
  18326. * Set a vec2 array in the shader from a number array.
  18327. * @param name Define the name of the uniform as defined in the shader
  18328. * @param value Define the value to give to the uniform
  18329. * @return the material itself allowing "fluent" like uniform updates
  18330. */
  18331. setArray2(name: string, value: number[]): ShaderMaterial;
  18332. /**
  18333. * Set a vec3 array in the shader from a number array.
  18334. * @param name Define the name of the uniform as defined in the shader
  18335. * @param value Define the value to give to the uniform
  18336. * @return the material itself allowing "fluent" like uniform updates
  18337. */
  18338. setArray3(name: string, value: number[]): ShaderMaterial;
  18339. private _checkCache;
  18340. /**
  18341. * Checks if the material is ready to render the requested mesh
  18342. * @param mesh Define the mesh to render
  18343. * @param useInstances Define whether or not the material is used with instances
  18344. * @returns true if ready, otherwise false
  18345. */
  18346. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18347. /**
  18348. * Binds the world matrix to the material
  18349. * @param world defines the world transformation matrix
  18350. */
  18351. bindOnlyWorldMatrix(world: Matrix): void;
  18352. /**
  18353. * Binds the material to the mesh
  18354. * @param world defines the world transformation matrix
  18355. * @param mesh defines the mesh to bind the material to
  18356. */
  18357. bind(world: Matrix, mesh?: Mesh): void;
  18358. /**
  18359. * Gets the active textures from the material
  18360. * @returns an array of textures
  18361. */
  18362. getActiveTextures(): BaseTexture[];
  18363. /**
  18364. * Specifies if the material uses a texture
  18365. * @param texture defines the texture to check against the material
  18366. * @returns a boolean specifying if the material uses the texture
  18367. */
  18368. hasTexture(texture: BaseTexture): boolean;
  18369. /**
  18370. * Makes a duplicate of the material, and gives it a new name
  18371. * @param name defines the new name for the duplicated material
  18372. * @returns the cloned material
  18373. */
  18374. clone(name: string): ShaderMaterial;
  18375. /**
  18376. * Disposes the material
  18377. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18378. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18379. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18380. */
  18381. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18382. /**
  18383. * Serializes this material in a JSON representation
  18384. * @returns the serialized material object
  18385. */
  18386. serialize(): any;
  18387. /**
  18388. * Creates a shader material from parsed shader material data
  18389. * @param source defines the JSON represnetation of the material
  18390. * @param scene defines the hosting scene
  18391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18392. * @returns a new material
  18393. */
  18394. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18395. }
  18396. }
  18397. declare module "babylonjs/Shaders/color.fragment" {
  18398. /** @hidden */
  18399. export var colorPixelShader: {
  18400. name: string;
  18401. shader: string;
  18402. };
  18403. }
  18404. declare module "babylonjs/Shaders/color.vertex" {
  18405. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  18406. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  18407. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  18408. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  18409. /** @hidden */
  18410. export var colorVertexShader: {
  18411. name: string;
  18412. shader: string;
  18413. };
  18414. }
  18415. declare module "babylonjs/Meshes/linesMesh" {
  18416. import { Nullable } from "babylonjs/types";
  18417. import { Scene } from "babylonjs/scene";
  18418. import { Color3 } from "babylonjs/Maths/math";
  18419. import { Node } from "babylonjs/node";
  18420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18421. import { Mesh } from "babylonjs/Meshes/mesh";
  18422. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  18423. import { Effect } from "babylonjs/Materials/effect";
  18424. import { Material } from "babylonjs/Materials/material";
  18425. import "babylonjs/Shaders/color.fragment";
  18426. import "babylonjs/Shaders/color.vertex";
  18427. /**
  18428. * Line mesh
  18429. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18430. */
  18431. export class LinesMesh extends Mesh {
  18432. /**
  18433. * If vertex color should be applied to the mesh
  18434. */
  18435. useVertexColor?: boolean | undefined;
  18436. /**
  18437. * If vertex alpha should be applied to the mesh
  18438. */
  18439. useVertexAlpha?: boolean | undefined;
  18440. /**
  18441. * Color of the line (Default: White)
  18442. */
  18443. color: Color3;
  18444. /**
  18445. * Alpha of the line (Default: 1)
  18446. */
  18447. alpha: number;
  18448. /**
  18449. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18450. * This margin is expressed in world space coordinates, so its value may vary.
  18451. * Default value is 0.1
  18452. */
  18453. intersectionThreshold: number;
  18454. private _colorShader;
  18455. /**
  18456. * Creates a new LinesMesh
  18457. * @param name defines the name
  18458. * @param scene defines the hosting scene
  18459. * @param parent defines the parent mesh if any
  18460. * @param source defines the optional source LinesMesh used to clone data from
  18461. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18462. * When false, achieved by calling a clone(), also passing False.
  18463. * This will make creation of children, recursive.
  18464. * @param useVertexColor defines if this LinesMesh supports vertex color
  18465. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18466. */
  18467. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18468. /**
  18469. * If vertex color should be applied to the mesh
  18470. */
  18471. useVertexColor?: boolean | undefined,
  18472. /**
  18473. * If vertex alpha should be applied to the mesh
  18474. */
  18475. useVertexAlpha?: boolean | undefined);
  18476. /**
  18477. * Returns the string "LineMesh"
  18478. */
  18479. getClassName(): string;
  18480. /**
  18481. * @hidden
  18482. */
  18483. /**
  18484. * @hidden
  18485. */
  18486. material: Material;
  18487. /**
  18488. * @hidden
  18489. */
  18490. readonly checkCollisions: boolean;
  18491. /** @hidden */
  18492. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18493. /** @hidden */
  18494. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18495. /**
  18496. * Disposes of the line mesh
  18497. * @param doNotRecurse If children should be disposed
  18498. */
  18499. dispose(doNotRecurse?: boolean): void;
  18500. /**
  18501. * Returns a new LineMesh object cloned from the current one.
  18502. */
  18503. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18504. /**
  18505. * Creates a new InstancedLinesMesh object from the mesh model.
  18506. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18507. * @param name defines the name of the new instance
  18508. * @returns a new InstancedLinesMesh
  18509. */
  18510. createInstance(name: string): InstancedLinesMesh;
  18511. }
  18512. /**
  18513. * Creates an instance based on a source LinesMesh
  18514. */
  18515. export class InstancedLinesMesh extends InstancedMesh {
  18516. /**
  18517. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18518. * This margin is expressed in world space coordinates, so its value may vary.
  18519. * Initilized with the intersectionThreshold value of the source LinesMesh
  18520. */
  18521. intersectionThreshold: number;
  18522. constructor(name: string, source: LinesMesh);
  18523. /**
  18524. * Returns the string "InstancedLinesMesh".
  18525. */
  18526. getClassName(): string;
  18527. }
  18528. }
  18529. declare module "babylonjs/Meshes/groundMesh" {
  18530. import { Scene } from "babylonjs/scene";
  18531. import { Vector3 } from "babylonjs/Maths/math";
  18532. import { Mesh } from "babylonjs/Meshes/mesh";
  18533. /**
  18534. * Mesh representing the gorund
  18535. */
  18536. export class GroundMesh extends Mesh {
  18537. /** If octree should be generated */
  18538. generateOctree: boolean;
  18539. private _heightQuads;
  18540. /** @hidden */
  18541. _subdivisionsX: number;
  18542. /** @hidden */
  18543. _subdivisionsY: number;
  18544. /** @hidden */
  18545. _width: number;
  18546. /** @hidden */
  18547. _height: number;
  18548. /** @hidden */
  18549. _minX: number;
  18550. /** @hidden */
  18551. _maxX: number;
  18552. /** @hidden */
  18553. _minZ: number;
  18554. /** @hidden */
  18555. _maxZ: number;
  18556. constructor(name: string, scene: Scene);
  18557. /**
  18558. * "GroundMesh"
  18559. * @returns "GroundMesh"
  18560. */
  18561. getClassName(): string;
  18562. /**
  18563. * The minimum of x and y subdivisions
  18564. */
  18565. readonly subdivisions: number;
  18566. /**
  18567. * X subdivisions
  18568. */
  18569. readonly subdivisionsX: number;
  18570. /**
  18571. * Y subdivisions
  18572. */
  18573. readonly subdivisionsY: number;
  18574. /**
  18575. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18576. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18577. * @param chunksCount the number of subdivisions for x and y
  18578. * @param octreeBlocksSize (Default: 32)
  18579. */
  18580. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18581. /**
  18582. * Returns a height (y) value in the Worl system :
  18583. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18584. * @param x x coordinate
  18585. * @param z z coordinate
  18586. * @returns the ground y position if (x, z) are outside the ground surface.
  18587. */
  18588. getHeightAtCoordinates(x: number, z: number): number;
  18589. /**
  18590. * Returns a normalized vector (Vector3) orthogonal to the ground
  18591. * at the ground coordinates (x, z) expressed in the World system.
  18592. * @param x x coordinate
  18593. * @param z z coordinate
  18594. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18595. */
  18596. getNormalAtCoordinates(x: number, z: number): Vector3;
  18597. /**
  18598. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18599. * at the ground coordinates (x, z) expressed in the World system.
  18600. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18601. * @param x x coordinate
  18602. * @param z z coordinate
  18603. * @param ref vector to store the result
  18604. * @returns the GroundMesh.
  18605. */
  18606. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18607. /**
  18608. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18609. * if the ground has been updated.
  18610. * This can be used in the render loop.
  18611. * @returns the GroundMesh.
  18612. */
  18613. updateCoordinateHeights(): GroundMesh;
  18614. private _getFacetAt;
  18615. private _initHeightQuads;
  18616. private _computeHeightQuads;
  18617. /**
  18618. * Serializes this ground mesh
  18619. * @param serializationObject object to write serialization to
  18620. */
  18621. serialize(serializationObject: any): void;
  18622. /**
  18623. * Parses a serialized ground mesh
  18624. * @param parsedMesh the serialized mesh
  18625. * @param scene the scene to create the ground mesh in
  18626. * @returns the created ground mesh
  18627. */
  18628. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18629. }
  18630. }
  18631. declare module "babylonjs/Physics/physicsJoint" {
  18632. import { Vector3 } from "babylonjs/Maths/math";
  18633. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18634. /**
  18635. * Interface for Physics-Joint data
  18636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18637. */
  18638. export interface PhysicsJointData {
  18639. /**
  18640. * The main pivot of the joint
  18641. */
  18642. mainPivot?: Vector3;
  18643. /**
  18644. * The connected pivot of the joint
  18645. */
  18646. connectedPivot?: Vector3;
  18647. /**
  18648. * The main axis of the joint
  18649. */
  18650. mainAxis?: Vector3;
  18651. /**
  18652. * The connected axis of the joint
  18653. */
  18654. connectedAxis?: Vector3;
  18655. /**
  18656. * The collision of the joint
  18657. */
  18658. collision?: boolean;
  18659. /**
  18660. * Native Oimo/Cannon/Energy data
  18661. */
  18662. nativeParams?: any;
  18663. }
  18664. /**
  18665. * This is a holder class for the physics joint created by the physics plugin
  18666. * It holds a set of functions to control the underlying joint
  18667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18668. */
  18669. export class PhysicsJoint {
  18670. /**
  18671. * The type of the physics joint
  18672. */
  18673. type: number;
  18674. /**
  18675. * The data for the physics joint
  18676. */
  18677. jointData: PhysicsJointData;
  18678. private _physicsJoint;
  18679. protected _physicsPlugin: IPhysicsEnginePlugin;
  18680. /**
  18681. * Initializes the physics joint
  18682. * @param type The type of the physics joint
  18683. * @param jointData The data for the physics joint
  18684. */
  18685. constructor(
  18686. /**
  18687. * The type of the physics joint
  18688. */
  18689. type: number,
  18690. /**
  18691. * The data for the physics joint
  18692. */
  18693. jointData: PhysicsJointData);
  18694. /**
  18695. * Gets the physics joint
  18696. */
  18697. /**
  18698. * Sets the physics joint
  18699. */
  18700. physicsJoint: any;
  18701. /**
  18702. * Sets the physics plugin
  18703. */
  18704. physicsPlugin: IPhysicsEnginePlugin;
  18705. /**
  18706. * Execute a function that is physics-plugin specific.
  18707. * @param {Function} func the function that will be executed.
  18708. * It accepts two parameters: the physics world and the physics joint
  18709. */
  18710. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18711. /**
  18712. * Distance-Joint type
  18713. */
  18714. static DistanceJoint: number;
  18715. /**
  18716. * Hinge-Joint type
  18717. */
  18718. static HingeJoint: number;
  18719. /**
  18720. * Ball-and-Socket joint type
  18721. */
  18722. static BallAndSocketJoint: number;
  18723. /**
  18724. * Wheel-Joint type
  18725. */
  18726. static WheelJoint: number;
  18727. /**
  18728. * Slider-Joint type
  18729. */
  18730. static SliderJoint: number;
  18731. /**
  18732. * Prismatic-Joint type
  18733. */
  18734. static PrismaticJoint: number;
  18735. /**
  18736. * Universal-Joint type
  18737. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18738. */
  18739. static UniversalJoint: number;
  18740. /**
  18741. * Hinge-Joint 2 type
  18742. */
  18743. static Hinge2Joint: number;
  18744. /**
  18745. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18746. */
  18747. static PointToPointJoint: number;
  18748. /**
  18749. * Spring-Joint type
  18750. */
  18751. static SpringJoint: number;
  18752. /**
  18753. * Lock-Joint type
  18754. */
  18755. static LockJoint: number;
  18756. }
  18757. /**
  18758. * A class representing a physics distance joint
  18759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18760. */
  18761. export class DistanceJoint extends PhysicsJoint {
  18762. /**
  18763. *
  18764. * @param jointData The data for the Distance-Joint
  18765. */
  18766. constructor(jointData: DistanceJointData);
  18767. /**
  18768. * Update the predefined distance.
  18769. * @param maxDistance The maximum preferred distance
  18770. * @param minDistance The minimum preferred distance
  18771. */
  18772. updateDistance(maxDistance: number, minDistance?: number): void;
  18773. }
  18774. /**
  18775. * Represents a Motor-Enabled Joint
  18776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18777. */
  18778. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18779. /**
  18780. * Initializes the Motor-Enabled Joint
  18781. * @param type The type of the joint
  18782. * @param jointData The physica joint data for the joint
  18783. */
  18784. constructor(type: number, jointData: PhysicsJointData);
  18785. /**
  18786. * Set the motor values.
  18787. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18788. * @param force the force to apply
  18789. * @param maxForce max force for this motor.
  18790. */
  18791. setMotor(force?: number, maxForce?: number): void;
  18792. /**
  18793. * Set the motor's limits.
  18794. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18795. * @param upperLimit The upper limit of the motor
  18796. * @param lowerLimit The lower limit of the motor
  18797. */
  18798. setLimit(upperLimit: number, lowerLimit?: number): void;
  18799. }
  18800. /**
  18801. * This class represents a single physics Hinge-Joint
  18802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18803. */
  18804. export class HingeJoint extends MotorEnabledJoint {
  18805. /**
  18806. * Initializes the Hinge-Joint
  18807. * @param jointData The joint data for the Hinge-Joint
  18808. */
  18809. constructor(jointData: PhysicsJointData);
  18810. /**
  18811. * Set the motor values.
  18812. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18813. * @param {number} force the force to apply
  18814. * @param {number} maxForce max force for this motor.
  18815. */
  18816. setMotor(force?: number, maxForce?: number): void;
  18817. /**
  18818. * Set the motor's limits.
  18819. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18820. * @param upperLimit The upper limit of the motor
  18821. * @param lowerLimit The lower limit of the motor
  18822. */
  18823. setLimit(upperLimit: number, lowerLimit?: number): void;
  18824. }
  18825. /**
  18826. * This class represents a dual hinge physics joint (same as wheel joint)
  18827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18828. */
  18829. export class Hinge2Joint extends MotorEnabledJoint {
  18830. /**
  18831. * Initializes the Hinge2-Joint
  18832. * @param jointData The joint data for the Hinge2-Joint
  18833. */
  18834. constructor(jointData: PhysicsJointData);
  18835. /**
  18836. * Set the motor values.
  18837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18838. * @param {number} force the force to apply
  18839. * @param {number} maxForce max force for this motor.
  18840. * @param {motorIndex} the motor's index, 0 or 1.
  18841. */
  18842. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18843. /**
  18844. * Set the motor limits.
  18845. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18846. * @param {number} upperLimit the upper limit
  18847. * @param {number} lowerLimit lower limit
  18848. * @param {motorIndex} the motor's index, 0 or 1.
  18849. */
  18850. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18851. }
  18852. /**
  18853. * Interface for a motor enabled joint
  18854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18855. */
  18856. export interface IMotorEnabledJoint {
  18857. /**
  18858. * Physics joint
  18859. */
  18860. physicsJoint: any;
  18861. /**
  18862. * Sets the motor of the motor-enabled joint
  18863. * @param force The force of the motor
  18864. * @param maxForce The maximum force of the motor
  18865. * @param motorIndex The index of the motor
  18866. */
  18867. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18868. /**
  18869. * Sets the limit of the motor
  18870. * @param upperLimit The upper limit of the motor
  18871. * @param lowerLimit The lower limit of the motor
  18872. * @param motorIndex The index of the motor
  18873. */
  18874. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18875. }
  18876. /**
  18877. * Joint data for a Distance-Joint
  18878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18879. */
  18880. export interface DistanceJointData extends PhysicsJointData {
  18881. /**
  18882. * Max distance the 2 joint objects can be apart
  18883. */
  18884. maxDistance: number;
  18885. }
  18886. /**
  18887. * Joint data from a spring joint
  18888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18889. */
  18890. export interface SpringJointData extends PhysicsJointData {
  18891. /**
  18892. * Length of the spring
  18893. */
  18894. length: number;
  18895. /**
  18896. * Stiffness of the spring
  18897. */
  18898. stiffness: number;
  18899. /**
  18900. * Damping of the spring
  18901. */
  18902. damping: number;
  18903. /** this callback will be called when applying the force to the impostors. */
  18904. forceApplicationCallback: () => void;
  18905. }
  18906. }
  18907. declare module "babylonjs/Physics/IPhysicsEngine" {
  18908. import { Nullable } from "babylonjs/types";
  18909. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18911. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18912. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18913. /**
  18914. * Interface used to describe a physics joint
  18915. */
  18916. export interface PhysicsImpostorJoint {
  18917. /** Defines the main impostor to which the joint is linked */
  18918. mainImpostor: PhysicsImpostor;
  18919. /** Defines the impostor that is connected to the main impostor using this joint */
  18920. connectedImpostor: PhysicsImpostor;
  18921. /** Defines the joint itself */
  18922. joint: PhysicsJoint;
  18923. }
  18924. /** @hidden */
  18925. export interface IPhysicsEnginePlugin {
  18926. world: any;
  18927. name: string;
  18928. setGravity(gravity: Vector3): void;
  18929. setTimeStep(timeStep: number): void;
  18930. getTimeStep(): number;
  18931. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18932. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18933. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18934. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18935. removePhysicsBody(impostor: PhysicsImpostor): void;
  18936. generateJoint(joint: PhysicsImpostorJoint): void;
  18937. removeJoint(joint: PhysicsImpostorJoint): void;
  18938. isSupported(): boolean;
  18939. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18940. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18941. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18942. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18943. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18944. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18945. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18946. getBodyMass(impostor: PhysicsImpostor): number;
  18947. getBodyFriction(impostor: PhysicsImpostor): number;
  18948. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18949. getBodyRestitution(impostor: PhysicsImpostor): number;
  18950. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18951. sleepBody(impostor: PhysicsImpostor): void;
  18952. wakeUpBody(impostor: PhysicsImpostor): void;
  18953. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18954. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18955. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18956. getRadius(impostor: PhysicsImpostor): number;
  18957. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18958. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18959. dispose(): void;
  18960. }
  18961. /**
  18962. * Interface used to define a physics engine
  18963. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18964. */
  18965. export interface IPhysicsEngine {
  18966. /**
  18967. * Gets the gravity vector used by the simulation
  18968. */
  18969. gravity: Vector3;
  18970. /**
  18971. * Sets the gravity vector used by the simulation
  18972. * @param gravity defines the gravity vector to use
  18973. */
  18974. setGravity(gravity: Vector3): void;
  18975. /**
  18976. * Set the time step of the physics engine.
  18977. * Default is 1/60.
  18978. * To slow it down, enter 1/600 for example.
  18979. * To speed it up, 1/30
  18980. * @param newTimeStep the new timestep to apply to this world.
  18981. */
  18982. setTimeStep(newTimeStep: number): void;
  18983. /**
  18984. * Get the time step of the physics engine.
  18985. * @returns the current time step
  18986. */
  18987. getTimeStep(): number;
  18988. /**
  18989. * Release all resources
  18990. */
  18991. dispose(): void;
  18992. /**
  18993. * Gets the name of the current physics plugin
  18994. * @returns the name of the plugin
  18995. */
  18996. getPhysicsPluginName(): string;
  18997. /**
  18998. * Adding a new impostor for the impostor tracking.
  18999. * This will be done by the impostor itself.
  19000. * @param impostor the impostor to add
  19001. */
  19002. addImpostor(impostor: PhysicsImpostor): void;
  19003. /**
  19004. * Remove an impostor from the engine.
  19005. * This impostor and its mesh will not longer be updated by the physics engine.
  19006. * @param impostor the impostor to remove
  19007. */
  19008. removeImpostor(impostor: PhysicsImpostor): void;
  19009. /**
  19010. * Add a joint to the physics engine
  19011. * @param mainImpostor defines the main impostor to which the joint is added.
  19012. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19013. * @param joint defines the joint that will connect both impostors.
  19014. */
  19015. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19016. /**
  19017. * Removes a joint from the simulation
  19018. * @param mainImpostor defines the impostor used with the joint
  19019. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19020. * @param joint defines the joint to remove
  19021. */
  19022. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19023. /**
  19024. * Gets the current plugin used to run the simulation
  19025. * @returns current plugin
  19026. */
  19027. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19028. /**
  19029. * Gets the list of physic impostors
  19030. * @returns an array of PhysicsImpostor
  19031. */
  19032. getImpostors(): Array<PhysicsImpostor>;
  19033. /**
  19034. * Gets the impostor for a physics enabled object
  19035. * @param object defines the object impersonated by the impostor
  19036. * @returns the PhysicsImpostor or null if not found
  19037. */
  19038. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19039. /**
  19040. * Gets the impostor for a physics body object
  19041. * @param body defines physics body used by the impostor
  19042. * @returns the PhysicsImpostor or null if not found
  19043. */
  19044. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19045. /**
  19046. * Called by the scene. No need to call it.
  19047. * @param delta defines the timespam between frames
  19048. */
  19049. _step(delta: number): void;
  19050. }
  19051. }
  19052. declare module "babylonjs/Physics/physicsImpostor" {
  19053. import { Nullable, IndicesArray } from "babylonjs/types";
  19054. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19055. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19057. import { Scene } from "babylonjs/scene";
  19058. import { Bone } from "babylonjs/Bones/bone";
  19059. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19060. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19061. /**
  19062. * The interface for the physics imposter parameters
  19063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19064. */
  19065. export interface PhysicsImpostorParameters {
  19066. /**
  19067. * The mass of the physics imposter
  19068. */
  19069. mass: number;
  19070. /**
  19071. * The friction of the physics imposter
  19072. */
  19073. friction?: number;
  19074. /**
  19075. * The coefficient of restitution of the physics imposter
  19076. */
  19077. restitution?: number;
  19078. /**
  19079. * The native options of the physics imposter
  19080. */
  19081. nativeOptions?: any;
  19082. /**
  19083. * Specifies if the parent should be ignored
  19084. */
  19085. ignoreParent?: boolean;
  19086. /**
  19087. * Specifies if bi-directional transformations should be disabled
  19088. */
  19089. disableBidirectionalTransformation?: boolean;
  19090. }
  19091. /**
  19092. * Interface for a physics-enabled object
  19093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19094. */
  19095. export interface IPhysicsEnabledObject {
  19096. /**
  19097. * The position of the physics-enabled object
  19098. */
  19099. position: Vector3;
  19100. /**
  19101. * The rotation of the physics-enabled object
  19102. */
  19103. rotationQuaternion: Nullable<Quaternion>;
  19104. /**
  19105. * The scale of the physics-enabled object
  19106. */
  19107. scaling: Vector3;
  19108. /**
  19109. * The rotation of the physics-enabled object
  19110. */
  19111. rotation?: Vector3;
  19112. /**
  19113. * The parent of the physics-enabled object
  19114. */
  19115. parent?: any;
  19116. /**
  19117. * The bounding info of the physics-enabled object
  19118. * @returns The bounding info of the physics-enabled object
  19119. */
  19120. getBoundingInfo(): BoundingInfo;
  19121. /**
  19122. * Computes the world matrix
  19123. * @param force Specifies if the world matrix should be computed by force
  19124. * @returns A world matrix
  19125. */
  19126. computeWorldMatrix(force: boolean): Matrix;
  19127. /**
  19128. * Gets the world matrix
  19129. * @returns A world matrix
  19130. */
  19131. getWorldMatrix?(): Matrix;
  19132. /**
  19133. * Gets the child meshes
  19134. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19135. * @returns An array of abstract meshes
  19136. */
  19137. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19138. /**
  19139. * Gets the vertex data
  19140. * @param kind The type of vertex data
  19141. * @returns A nullable array of numbers, or a float32 array
  19142. */
  19143. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19144. /**
  19145. * Gets the indices from the mesh
  19146. * @returns A nullable array of index arrays
  19147. */
  19148. getIndices?(): Nullable<IndicesArray>;
  19149. /**
  19150. * Gets the scene from the mesh
  19151. * @returns the indices array or null
  19152. */
  19153. getScene?(): Scene;
  19154. /**
  19155. * Gets the absolute position from the mesh
  19156. * @returns the absolute position
  19157. */
  19158. getAbsolutePosition(): Vector3;
  19159. /**
  19160. * Gets the absolute pivot point from the mesh
  19161. * @returns the absolute pivot point
  19162. */
  19163. getAbsolutePivotPoint(): Vector3;
  19164. /**
  19165. * Rotates the mesh
  19166. * @param axis The axis of rotation
  19167. * @param amount The amount of rotation
  19168. * @param space The space of the rotation
  19169. * @returns The rotation transform node
  19170. */
  19171. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19172. /**
  19173. * Translates the mesh
  19174. * @param axis The axis of translation
  19175. * @param distance The distance of translation
  19176. * @param space The space of the translation
  19177. * @returns The transform node
  19178. */
  19179. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19180. /**
  19181. * Sets the absolute position of the mesh
  19182. * @param absolutePosition The absolute position of the mesh
  19183. * @returns The transform node
  19184. */
  19185. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19186. /**
  19187. * Gets the class name of the mesh
  19188. * @returns The class name
  19189. */
  19190. getClassName(): string;
  19191. }
  19192. /**
  19193. * Represents a physics imposter
  19194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19195. */
  19196. export class PhysicsImpostor {
  19197. /**
  19198. * The physics-enabled object used as the physics imposter
  19199. */
  19200. object: IPhysicsEnabledObject;
  19201. /**
  19202. * The type of the physics imposter
  19203. */
  19204. type: number;
  19205. private _options;
  19206. private _scene?;
  19207. /**
  19208. * The default object size of the imposter
  19209. */
  19210. static DEFAULT_OBJECT_SIZE: Vector3;
  19211. /**
  19212. * The identity quaternion of the imposter
  19213. */
  19214. static IDENTITY_QUATERNION: Quaternion;
  19215. /** @hidden */
  19216. _pluginData: any;
  19217. private _physicsEngine;
  19218. private _physicsBody;
  19219. private _bodyUpdateRequired;
  19220. private _onBeforePhysicsStepCallbacks;
  19221. private _onAfterPhysicsStepCallbacks;
  19222. /** @hidden */
  19223. _onPhysicsCollideCallbacks: Array<{
  19224. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19225. otherImpostors: Array<PhysicsImpostor>;
  19226. }>;
  19227. private _deltaPosition;
  19228. private _deltaRotation;
  19229. private _deltaRotationConjugated;
  19230. private _parent;
  19231. private _isDisposed;
  19232. private static _tmpVecs;
  19233. private static _tmpQuat;
  19234. /**
  19235. * Specifies if the physics imposter is disposed
  19236. */
  19237. readonly isDisposed: boolean;
  19238. /**
  19239. * Gets the mass of the physics imposter
  19240. */
  19241. mass: number;
  19242. /**
  19243. * Gets the coefficient of friction
  19244. */
  19245. /**
  19246. * Sets the coefficient of friction
  19247. */
  19248. friction: number;
  19249. /**
  19250. * Gets the coefficient of restitution
  19251. */
  19252. /**
  19253. * Sets the coefficient of restitution
  19254. */
  19255. restitution: number;
  19256. /**
  19257. * The unique id of the physics imposter
  19258. * set by the physics engine when adding this impostor to the array
  19259. */
  19260. uniqueId: number;
  19261. private _joints;
  19262. /**
  19263. * Initializes the physics imposter
  19264. * @param object The physics-enabled object used as the physics imposter
  19265. * @param type The type of the physics imposter
  19266. * @param _options The options for the physics imposter
  19267. * @param _scene The Babylon scene
  19268. */
  19269. constructor(
  19270. /**
  19271. * The physics-enabled object used as the physics imposter
  19272. */
  19273. object: IPhysicsEnabledObject,
  19274. /**
  19275. * The type of the physics imposter
  19276. */
  19277. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19278. /**
  19279. * This function will completly initialize this impostor.
  19280. * It will create a new body - but only if this mesh has no parent.
  19281. * If it has, this impostor will not be used other than to define the impostor
  19282. * of the child mesh.
  19283. * @hidden
  19284. */
  19285. _init(): void;
  19286. private _getPhysicsParent;
  19287. /**
  19288. * Should a new body be generated.
  19289. * @returns boolean specifying if body initialization is required
  19290. */
  19291. isBodyInitRequired(): boolean;
  19292. /**
  19293. * Sets the updated scaling
  19294. * @param updated Specifies if the scaling is updated
  19295. */
  19296. setScalingUpdated(): void;
  19297. /**
  19298. * Force a regeneration of this or the parent's impostor's body.
  19299. * Use under cautious - This will remove all joints already implemented.
  19300. */
  19301. forceUpdate(): void;
  19302. /**
  19303. * Gets the body that holds this impostor. Either its own, or its parent.
  19304. */
  19305. /**
  19306. * Set the physics body. Used mainly by the physics engine/plugin
  19307. */
  19308. physicsBody: any;
  19309. /**
  19310. * Get the parent of the physics imposter
  19311. * @returns Physics imposter or null
  19312. */
  19313. /**
  19314. * Sets the parent of the physics imposter
  19315. */
  19316. parent: Nullable<PhysicsImpostor>;
  19317. /**
  19318. * Resets the update flags
  19319. */
  19320. resetUpdateFlags(): void;
  19321. /**
  19322. * Gets the object extend size
  19323. * @returns the object extend size
  19324. */
  19325. getObjectExtendSize(): Vector3;
  19326. /**
  19327. * Gets the object center
  19328. * @returns The object center
  19329. */
  19330. getObjectCenter(): Vector3;
  19331. /**
  19332. * Get a specific parametes from the options parameter
  19333. * @param paramName The object parameter name
  19334. * @returns The object parameter
  19335. */
  19336. getParam(paramName: string): any;
  19337. /**
  19338. * Sets a specific parameter in the options given to the physics plugin
  19339. * @param paramName The parameter name
  19340. * @param value The value of the parameter
  19341. */
  19342. setParam(paramName: string, value: number): void;
  19343. /**
  19344. * Specifically change the body's mass option. Won't recreate the physics body object
  19345. * @param mass The mass of the physics imposter
  19346. */
  19347. setMass(mass: number): void;
  19348. /**
  19349. * Gets the linear velocity
  19350. * @returns linear velocity or null
  19351. */
  19352. getLinearVelocity(): Nullable<Vector3>;
  19353. /**
  19354. * Sets the linear velocity
  19355. * @param velocity linear velocity or null
  19356. */
  19357. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19358. /**
  19359. * Gets the angular velocity
  19360. * @returns angular velocity or null
  19361. */
  19362. getAngularVelocity(): Nullable<Vector3>;
  19363. /**
  19364. * Sets the angular velocity
  19365. * @param velocity The velocity or null
  19366. */
  19367. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19368. /**
  19369. * Execute a function with the physics plugin native code
  19370. * Provide a function the will have two variables - the world object and the physics body object
  19371. * @param func The function to execute with the physics plugin native code
  19372. */
  19373. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19374. /**
  19375. * Register a function that will be executed before the physics world is stepping forward
  19376. * @param func The function to execute before the physics world is stepped forward
  19377. */
  19378. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19379. /**
  19380. * Unregister a function that will be executed before the physics world is stepping forward
  19381. * @param func The function to execute before the physics world is stepped forward
  19382. */
  19383. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19384. /**
  19385. * Register a function that will be executed after the physics step
  19386. * @param func The function to execute after physics step
  19387. */
  19388. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19389. /**
  19390. * Unregisters a function that will be executed after the physics step
  19391. * @param func The function to execute after physics step
  19392. */
  19393. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19394. /**
  19395. * register a function that will be executed when this impostor collides against a different body
  19396. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19397. * @param func Callback that is executed on collision
  19398. */
  19399. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19400. /**
  19401. * Unregisters the physics imposter on contact
  19402. * @param collideAgainst The physics object to collide against
  19403. * @param func Callback to execute on collision
  19404. */
  19405. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19406. private _tmpQuat;
  19407. private _tmpQuat2;
  19408. /**
  19409. * Get the parent rotation
  19410. * @returns The parent rotation
  19411. */
  19412. getParentsRotation(): Quaternion;
  19413. /**
  19414. * this function is executed by the physics engine.
  19415. */
  19416. beforeStep: () => void;
  19417. /**
  19418. * this function is executed by the physics engine
  19419. */
  19420. afterStep: () => void;
  19421. /**
  19422. * Legacy collision detection event support
  19423. */
  19424. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19425. /**
  19426. * event and body object due to cannon's event-based architecture.
  19427. */
  19428. onCollide: (e: {
  19429. body: any;
  19430. }) => void;
  19431. /**
  19432. * Apply a force
  19433. * @param force The force to apply
  19434. * @param contactPoint The contact point for the force
  19435. * @returns The physics imposter
  19436. */
  19437. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19438. /**
  19439. * Apply an impulse
  19440. * @param force The impulse force
  19441. * @param contactPoint The contact point for the impulse force
  19442. * @returns The physics imposter
  19443. */
  19444. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19445. /**
  19446. * A help function to create a joint
  19447. * @param otherImpostor A physics imposter used to create a joint
  19448. * @param jointType The type of joint
  19449. * @param jointData The data for the joint
  19450. * @returns The physics imposter
  19451. */
  19452. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19453. /**
  19454. * Add a joint to this impostor with a different impostor
  19455. * @param otherImpostor A physics imposter used to add a joint
  19456. * @param joint The joint to add
  19457. * @returns The physics imposter
  19458. */
  19459. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19460. /**
  19461. * Will keep this body still, in a sleep mode.
  19462. * @returns the physics imposter
  19463. */
  19464. sleep(): PhysicsImpostor;
  19465. /**
  19466. * Wake the body up.
  19467. * @returns The physics imposter
  19468. */
  19469. wakeUp(): PhysicsImpostor;
  19470. /**
  19471. * Clones the physics imposter
  19472. * @param newObject The physics imposter clones to this physics-enabled object
  19473. * @returns A nullable physics imposter
  19474. */
  19475. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19476. /**
  19477. * Disposes the physics imposter
  19478. */
  19479. dispose(): void;
  19480. /**
  19481. * Sets the delta position
  19482. * @param position The delta position amount
  19483. */
  19484. setDeltaPosition(position: Vector3): void;
  19485. /**
  19486. * Sets the delta rotation
  19487. * @param rotation The delta rotation amount
  19488. */
  19489. setDeltaRotation(rotation: Quaternion): void;
  19490. /**
  19491. * Gets the box size of the physics imposter and stores the result in the input parameter
  19492. * @param result Stores the box size
  19493. * @returns The physics imposter
  19494. */
  19495. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19496. /**
  19497. * Gets the radius of the physics imposter
  19498. * @returns Radius of the physics imposter
  19499. */
  19500. getRadius(): number;
  19501. /**
  19502. * Sync a bone with this impostor
  19503. * @param bone The bone to sync to the impostor.
  19504. * @param boneMesh The mesh that the bone is influencing.
  19505. * @param jointPivot The pivot of the joint / bone in local space.
  19506. * @param distToJoint Optional distance from the impostor to the joint.
  19507. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19508. */
  19509. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19510. /**
  19511. * Sync impostor to a bone
  19512. * @param bone The bone that the impostor will be synced to.
  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. * @param boneAxis Optional vector3 axis the bone is aligned with
  19518. */
  19519. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19520. /**
  19521. * No-Imposter type
  19522. */
  19523. static NoImpostor: number;
  19524. /**
  19525. * Sphere-Imposter type
  19526. */
  19527. static SphereImpostor: number;
  19528. /**
  19529. * Box-Imposter type
  19530. */
  19531. static BoxImpostor: number;
  19532. /**
  19533. * Plane-Imposter type
  19534. */
  19535. static PlaneImpostor: number;
  19536. /**
  19537. * Mesh-imposter type
  19538. */
  19539. static MeshImpostor: number;
  19540. /**
  19541. * Cylinder-Imposter type
  19542. */
  19543. static CylinderImpostor: number;
  19544. /**
  19545. * Particle-Imposter type
  19546. */
  19547. static ParticleImpostor: number;
  19548. /**
  19549. * Heightmap-Imposter type
  19550. */
  19551. static HeightmapImpostor: number;
  19552. }
  19553. }
  19554. declare module "babylonjs/Meshes/mesh" {
  19555. import { Observable } from "babylonjs/Misc/observable";
  19556. import { IAnimatable } from "babylonjs/Misc/tools";
  19557. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19558. import { Camera } from "babylonjs/Cameras/camera";
  19559. import { Scene } from "babylonjs/scene";
  19560. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19561. import { Engine } from "babylonjs/Engines/engine";
  19562. import { Node } from "babylonjs/node";
  19563. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19564. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19565. import { Buffer } from "babylonjs/Meshes/buffer";
  19566. import { Geometry } from "babylonjs/Meshes/geometry";
  19567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19569. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19570. import { Effect } from "babylonjs/Materials/effect";
  19571. import { Material } from "babylonjs/Materials/material";
  19572. import { Skeleton } from "babylonjs/Bones/skeleton";
  19573. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19574. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19575. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19576. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19577. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19578. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  19579. /**
  19580. * Class used to represent a specific level of detail of a mesh
  19581. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19582. */
  19583. export class MeshLODLevel {
  19584. /** Defines the distance where this level should star being displayed */
  19585. distance: number;
  19586. /** Defines the mesh to use to render this level */
  19587. mesh: Nullable<Mesh>;
  19588. /**
  19589. * Creates a new LOD level
  19590. * @param distance defines the distance where this level should star being displayed
  19591. * @param mesh defines the mesh to use to render this level
  19592. */
  19593. constructor(
  19594. /** Defines the distance where this level should star being displayed */
  19595. distance: number,
  19596. /** Defines the mesh to use to render this level */
  19597. mesh: Nullable<Mesh>);
  19598. }
  19599. /**
  19600. * @hidden
  19601. **/
  19602. export class _CreationDataStorage {
  19603. closePath?: boolean;
  19604. closeArray?: boolean;
  19605. idx: number[];
  19606. dashSize: number;
  19607. gapSize: number;
  19608. path3D: Path3D;
  19609. pathArray: Vector3[][];
  19610. arc: number;
  19611. radius: number;
  19612. cap: number;
  19613. tessellation: number;
  19614. }
  19615. /**
  19616. * @hidden
  19617. **/
  19618. class _InstanceDataStorage {
  19619. visibleInstances: any;
  19620. renderIdForInstances: number[];
  19621. batchCache: _InstancesBatch;
  19622. instancesBufferSize: number;
  19623. instancesBuffer: Nullable<Buffer>;
  19624. instancesData: Float32Array;
  19625. overridenInstanceCount: number;
  19626. }
  19627. /**
  19628. * @hidden
  19629. **/
  19630. export class _InstancesBatch {
  19631. mustReturn: boolean;
  19632. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19633. renderSelf: boolean[];
  19634. }
  19635. /**
  19636. * Class used to represent renderable models
  19637. */
  19638. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19639. /**
  19640. * Mesh side orientation : usually the external or front surface
  19641. */
  19642. static readonly FRONTSIDE: number;
  19643. /**
  19644. * Mesh side orientation : usually the internal or back surface
  19645. */
  19646. static readonly BACKSIDE: number;
  19647. /**
  19648. * Mesh side orientation : both internal and external or front and back surfaces
  19649. */
  19650. static readonly DOUBLESIDE: number;
  19651. /**
  19652. * Mesh side orientation : by default, `FRONTSIDE`
  19653. */
  19654. static readonly DEFAULTSIDE: number;
  19655. /**
  19656. * Mesh cap setting : no cap
  19657. */
  19658. static readonly NO_CAP: number;
  19659. /**
  19660. * Mesh cap setting : one cap at the beginning of the mesh
  19661. */
  19662. static readonly CAP_START: number;
  19663. /**
  19664. * Mesh cap setting : one cap at the end of the mesh
  19665. */
  19666. static readonly CAP_END: number;
  19667. /**
  19668. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19669. */
  19670. static readonly CAP_ALL: number;
  19671. /**
  19672. * Gets the default side orientation.
  19673. * @param orientation the orientation to value to attempt to get
  19674. * @returns the default orientation
  19675. * @hidden
  19676. */
  19677. static _GetDefaultSideOrientation(orientation?: number): number;
  19678. private _onBeforeRenderObservable;
  19679. private _onBeforeBindObservable;
  19680. private _onAfterRenderObservable;
  19681. private _onBeforeDrawObservable;
  19682. /**
  19683. * An event triggered before rendering the mesh
  19684. */
  19685. readonly onBeforeRenderObservable: Observable<Mesh>;
  19686. /**
  19687. * An event triggered before binding the mesh
  19688. */
  19689. readonly onBeforeBindObservable: Observable<Mesh>;
  19690. /**
  19691. * An event triggered after rendering the mesh
  19692. */
  19693. readonly onAfterRenderObservable: Observable<Mesh>;
  19694. /**
  19695. * An event triggered before drawing the mesh
  19696. */
  19697. readonly onBeforeDrawObservable: Observable<Mesh>;
  19698. private _onBeforeDrawObserver;
  19699. /**
  19700. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19701. */
  19702. onBeforeDraw: () => void;
  19703. /**
  19704. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19705. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19706. */
  19707. delayLoadState: number;
  19708. /**
  19709. * Gets the list of instances created from this mesh
  19710. * it is not supposed to be modified manually.
  19711. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19712. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19713. */
  19714. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19715. /**
  19716. * Gets the file containing delay loading data for this mesh
  19717. */
  19718. delayLoadingFile: string;
  19719. /** @hidden */
  19720. _binaryInfo: any;
  19721. private _LODLevels;
  19722. /**
  19723. * User defined function used to change how LOD level selection is done
  19724. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19725. */
  19726. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19727. private _morphTargetManager;
  19728. /**
  19729. * Gets or sets the morph target manager
  19730. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19731. */
  19732. morphTargetManager: Nullable<MorphTargetManager>;
  19733. /** @hidden */
  19734. _creationDataStorage: Nullable<_CreationDataStorage>;
  19735. /** @hidden */
  19736. _geometry: Nullable<Geometry>;
  19737. /** @hidden */
  19738. _delayInfo: Array<string>;
  19739. /** @hidden */
  19740. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19741. /** @hidden */
  19742. _instanceDataStorage: _InstanceDataStorage;
  19743. private _effectiveMaterial;
  19744. /** @hidden */
  19745. _shouldGenerateFlatShading: boolean;
  19746. private _preActivateId;
  19747. /** @hidden */
  19748. _originalBuilderSideOrientation: number;
  19749. /**
  19750. * Use this property to change the original side orientation defined at construction time
  19751. */
  19752. overrideMaterialSideOrientation: Nullable<number>;
  19753. private _areNormalsFrozen;
  19754. private _sourcePositions;
  19755. private _sourceNormals;
  19756. private _source;
  19757. private meshMap;
  19758. /**
  19759. * Gets the source mesh (the one used to clone this one from)
  19760. */
  19761. readonly source: Nullable<Mesh>;
  19762. /**
  19763. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19764. */
  19765. isUnIndexed: boolean;
  19766. /**
  19767. * @constructor
  19768. * @param name The value used by scene.getMeshByName() to do a lookup.
  19769. * @param scene The scene to add this mesh to.
  19770. * @param parent The parent of this mesh, if it has one
  19771. * @param source An optional Mesh from which geometry is shared, cloned.
  19772. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19773. * When false, achieved by calling a clone(), also passing False.
  19774. * This will make creation of children, recursive.
  19775. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19776. */
  19777. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19778. /**
  19779. * Gets the class name
  19780. * @returns the string "Mesh".
  19781. */
  19782. getClassName(): string;
  19783. /** @hidden */
  19784. readonly _isMesh: boolean;
  19785. /**
  19786. * Returns a description of this mesh
  19787. * @param fullDetails define if full details about this mesh must be used
  19788. * @returns a descriptive string representing this mesh
  19789. */
  19790. toString(fullDetails?: boolean): string;
  19791. /** @hidden */
  19792. _unBindEffect(): void;
  19793. /**
  19794. * Gets a boolean indicating if this mesh has LOD
  19795. */
  19796. readonly hasLODLevels: boolean;
  19797. /**
  19798. * Gets the list of MeshLODLevel associated with the current mesh
  19799. * @returns an array of MeshLODLevel
  19800. */
  19801. getLODLevels(): MeshLODLevel[];
  19802. private _sortLODLevels;
  19803. /**
  19804. * Add a mesh as LOD level triggered at the given distance.
  19805. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19806. * @param distance The distance from the center of the object to show this level
  19807. * @param mesh The mesh to be added as LOD level (can be null)
  19808. * @return This mesh (for chaining)
  19809. */
  19810. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19811. /**
  19812. * Returns the LOD level mesh at the passed distance or null if not found.
  19813. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19814. * @param distance The distance from the center of the object to show this level
  19815. * @returns a Mesh or `null`
  19816. */
  19817. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19818. /**
  19819. * Remove a mesh from the LOD array
  19820. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19821. * @param mesh defines the mesh to be removed
  19822. * @return This mesh (for chaining)
  19823. */
  19824. removeLODLevel(mesh: Mesh): Mesh;
  19825. /**
  19826. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19827. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19828. * @param camera defines the camera to use to compute distance
  19829. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19830. * @return This mesh (for chaining)
  19831. */
  19832. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19833. /**
  19834. * Gets the mesh internal Geometry object
  19835. */
  19836. readonly geometry: Nullable<Geometry>;
  19837. /**
  19838. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19839. * @returns the total number of vertices
  19840. */
  19841. getTotalVertices(): number;
  19842. /**
  19843. * Returns the content of an associated vertex buffer
  19844. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19845. * - VertexBuffer.PositionKind
  19846. * - VertexBuffer.UVKind
  19847. * - VertexBuffer.UV2Kind
  19848. * - VertexBuffer.UV3Kind
  19849. * - VertexBuffer.UV4Kind
  19850. * - VertexBuffer.UV5Kind
  19851. * - VertexBuffer.UV6Kind
  19852. * - VertexBuffer.ColorKind
  19853. * - VertexBuffer.MatricesIndicesKind
  19854. * - VertexBuffer.MatricesIndicesExtraKind
  19855. * - VertexBuffer.MatricesWeightsKind
  19856. * - VertexBuffer.MatricesWeightsExtraKind
  19857. * @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
  19858. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19859. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19860. */
  19861. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19862. /**
  19863. * Returns the mesh VertexBuffer object from the requested `kind`
  19864. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19865. * - VertexBuffer.PositionKind
  19866. * - VertexBuffer.UVKind
  19867. * - VertexBuffer.UV2Kind
  19868. * - VertexBuffer.UV3Kind
  19869. * - VertexBuffer.UV4Kind
  19870. * - VertexBuffer.UV5Kind
  19871. * - VertexBuffer.UV6Kind
  19872. * - VertexBuffer.ColorKind
  19873. * - VertexBuffer.MatricesIndicesKind
  19874. * - VertexBuffer.MatricesIndicesExtraKind
  19875. * - VertexBuffer.MatricesWeightsKind
  19876. * - VertexBuffer.MatricesWeightsExtraKind
  19877. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19878. */
  19879. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19880. /**
  19881. * Tests if a specific vertex buffer is associated with this mesh
  19882. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19883. * - VertexBuffer.PositionKind
  19884. * - VertexBuffer.UVKind
  19885. * - VertexBuffer.UV2Kind
  19886. * - VertexBuffer.UV3Kind
  19887. * - VertexBuffer.UV4Kind
  19888. * - VertexBuffer.UV5Kind
  19889. * - VertexBuffer.UV6Kind
  19890. * - VertexBuffer.ColorKind
  19891. * - VertexBuffer.MatricesIndicesKind
  19892. * - VertexBuffer.MatricesIndicesExtraKind
  19893. * - VertexBuffer.MatricesWeightsKind
  19894. * - VertexBuffer.MatricesWeightsExtraKind
  19895. * @returns a boolean
  19896. */
  19897. isVerticesDataPresent(kind: string): boolean;
  19898. /**
  19899. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19900. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19901. * - VertexBuffer.PositionKind
  19902. * - VertexBuffer.UVKind
  19903. * - VertexBuffer.UV2Kind
  19904. * - VertexBuffer.UV3Kind
  19905. * - VertexBuffer.UV4Kind
  19906. * - VertexBuffer.UV5Kind
  19907. * - VertexBuffer.UV6Kind
  19908. * - VertexBuffer.ColorKind
  19909. * - VertexBuffer.MatricesIndicesKind
  19910. * - VertexBuffer.MatricesIndicesExtraKind
  19911. * - VertexBuffer.MatricesWeightsKind
  19912. * - VertexBuffer.MatricesWeightsExtraKind
  19913. * @returns a boolean
  19914. */
  19915. isVertexBufferUpdatable(kind: string): boolean;
  19916. /**
  19917. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19918. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19919. * - VertexBuffer.PositionKind
  19920. * - VertexBuffer.UVKind
  19921. * - VertexBuffer.UV2Kind
  19922. * - VertexBuffer.UV3Kind
  19923. * - VertexBuffer.UV4Kind
  19924. * - VertexBuffer.UV5Kind
  19925. * - VertexBuffer.UV6Kind
  19926. * - VertexBuffer.ColorKind
  19927. * - VertexBuffer.MatricesIndicesKind
  19928. * - VertexBuffer.MatricesIndicesExtraKind
  19929. * - VertexBuffer.MatricesWeightsKind
  19930. * - VertexBuffer.MatricesWeightsExtraKind
  19931. * @returns an array of strings
  19932. */
  19933. getVerticesDataKinds(): string[];
  19934. /**
  19935. * Returns a positive integer : the total number of indices in this mesh geometry.
  19936. * @returns the numner of indices or zero if the mesh has no geometry.
  19937. */
  19938. getTotalIndices(): number;
  19939. /**
  19940. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19941. * @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.
  19942. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19943. * @returns the indices array or an empty array if the mesh has no geometry
  19944. */
  19945. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19946. readonly isBlocked: boolean;
  19947. /**
  19948. * Determine if the current mesh is ready to be rendered
  19949. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19950. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19951. * @returns true if all associated assets are ready (material, textures, shaders)
  19952. */
  19953. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19954. /**
  19955. * 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.
  19956. */
  19957. readonly areNormalsFrozen: boolean;
  19958. /**
  19959. * 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.
  19960. * @returns the current mesh
  19961. */
  19962. freezeNormals(): Mesh;
  19963. /**
  19964. * 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
  19965. * @returns the current mesh
  19966. */
  19967. unfreezeNormals(): Mesh;
  19968. /**
  19969. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19970. */
  19971. overridenInstanceCount: number;
  19972. /** @hidden */
  19973. _preActivate(): Mesh;
  19974. /** @hidden */
  19975. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19976. /** @hidden */
  19977. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19978. /**
  19979. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19980. * This means the mesh underlying bounding box and sphere are recomputed.
  19981. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19982. * @returns the current mesh
  19983. */
  19984. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19985. /** @hidden */
  19986. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19987. /**
  19988. * This function will subdivide the mesh into multiple submeshes
  19989. * @param count defines the expected number of submeshes
  19990. */
  19991. subdivide(count: number): void;
  19992. /**
  19993. * Copy a FloatArray into a specific associated vertex buffer
  19994. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19995. * - VertexBuffer.PositionKind
  19996. * - VertexBuffer.UVKind
  19997. * - VertexBuffer.UV2Kind
  19998. * - VertexBuffer.UV3Kind
  19999. * - VertexBuffer.UV4Kind
  20000. * - VertexBuffer.UV5Kind
  20001. * - VertexBuffer.UV6Kind
  20002. * - VertexBuffer.ColorKind
  20003. * - VertexBuffer.MatricesIndicesKind
  20004. * - VertexBuffer.MatricesIndicesExtraKind
  20005. * - VertexBuffer.MatricesWeightsKind
  20006. * - VertexBuffer.MatricesWeightsExtraKind
  20007. * @param data defines the data source
  20008. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20009. * @param stride defines the data stride size (can be null)
  20010. * @returns the current mesh
  20011. */
  20012. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20013. /**
  20014. * Flags an associated vertex buffer as updatable
  20015. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20016. * - VertexBuffer.PositionKind
  20017. * - VertexBuffer.UVKind
  20018. * - VertexBuffer.UV2Kind
  20019. * - VertexBuffer.UV3Kind
  20020. * - VertexBuffer.UV4Kind
  20021. * - VertexBuffer.UV5Kind
  20022. * - VertexBuffer.UV6Kind
  20023. * - VertexBuffer.ColorKind
  20024. * - VertexBuffer.MatricesIndicesKind
  20025. * - VertexBuffer.MatricesIndicesExtraKind
  20026. * - VertexBuffer.MatricesWeightsKind
  20027. * - VertexBuffer.MatricesWeightsExtraKind
  20028. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20029. */
  20030. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20031. /**
  20032. * Sets the mesh global Vertex Buffer
  20033. * @param buffer defines the buffer to use
  20034. * @returns the current mesh
  20035. */
  20036. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20037. /**
  20038. * Update a specific associated vertex buffer
  20039. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20040. * - VertexBuffer.PositionKind
  20041. * - VertexBuffer.UVKind
  20042. * - VertexBuffer.UV2Kind
  20043. * - VertexBuffer.UV3Kind
  20044. * - VertexBuffer.UV4Kind
  20045. * - VertexBuffer.UV5Kind
  20046. * - VertexBuffer.UV6Kind
  20047. * - VertexBuffer.ColorKind
  20048. * - VertexBuffer.MatricesIndicesKind
  20049. * - VertexBuffer.MatricesIndicesExtraKind
  20050. * - VertexBuffer.MatricesWeightsKind
  20051. * - VertexBuffer.MatricesWeightsExtraKind
  20052. * @param data defines the data source
  20053. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20054. * @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)
  20055. * @returns the current mesh
  20056. */
  20057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20058. /**
  20059. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20060. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20061. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20062. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20063. * @returns the current mesh
  20064. */
  20065. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20066. /**
  20067. * Creates a un-shared specific occurence of the geometry for the mesh.
  20068. * @returns the current mesh
  20069. */
  20070. makeGeometryUnique(): Mesh;
  20071. /**
  20072. * Set the index buffer of this mesh
  20073. * @param indices defines the source data
  20074. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20075. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20076. * @returns the current mesh
  20077. */
  20078. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20079. /**
  20080. * Update the current index buffer
  20081. * @param indices defines the source data
  20082. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20083. * @returns the current mesh
  20084. */
  20085. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20086. /**
  20087. * Invert the geometry to move from a right handed system to a left handed one.
  20088. * @returns the current mesh
  20089. */
  20090. toLeftHanded(): Mesh;
  20091. /** @hidden */
  20092. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20093. /** @hidden */
  20094. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20095. /**
  20096. * Registers for this mesh a javascript function called just before the rendering process
  20097. * @param func defines the function to call before rendering this mesh
  20098. * @returns the current mesh
  20099. */
  20100. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20101. /**
  20102. * Disposes a previously registered javascript function called before the rendering
  20103. * @param func defines the function to remove
  20104. * @returns the current mesh
  20105. */
  20106. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20107. /**
  20108. * Registers for this mesh a javascript function called just after the rendering is complete
  20109. * @param func defines the function to call after rendering this mesh
  20110. * @returns the current mesh
  20111. */
  20112. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20113. /**
  20114. * Disposes a previously registered javascript function called after the rendering.
  20115. * @param func defines the function to remove
  20116. * @returns the current mesh
  20117. */
  20118. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20119. /** @hidden */
  20120. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20121. /** @hidden */
  20122. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20123. /** @hidden */
  20124. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20125. /**
  20126. * 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
  20127. * @param subMesh defines the subMesh to render
  20128. * @param enableAlphaMode defines if alpha mode can be changed
  20129. * @returns the current mesh
  20130. */
  20131. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20132. private _onBeforeDraw;
  20133. /**
  20134. * Renormalize the mesh and patch it up if there are no weights
  20135. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20136. * However in the case of zero weights then we set just a single influence to 1.
  20137. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20138. */
  20139. cleanMatrixWeights(): void;
  20140. private normalizeSkinFourWeights;
  20141. private normalizeSkinWeightsAndExtra;
  20142. /**
  20143. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20144. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20145. * the user know there was an issue with importing the mesh
  20146. * @returns a validation object with skinned, valid and report string
  20147. */
  20148. validateSkinning(): {
  20149. skinned: boolean;
  20150. valid: boolean;
  20151. report: string;
  20152. };
  20153. /** @hidden */
  20154. _checkDelayState(): Mesh;
  20155. private _queueLoad;
  20156. /**
  20157. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20158. * A mesh is in the frustum if its bounding box intersects the frustum
  20159. * @param frustumPlanes defines the frustum to test
  20160. * @returns true if the mesh is in the frustum planes
  20161. */
  20162. isInFrustum(frustumPlanes: Plane[]): boolean;
  20163. /**
  20164. * Sets the mesh material by the material or multiMaterial `id` property
  20165. * @param id is a string identifying the material or the multiMaterial
  20166. * @returns the current mesh
  20167. */
  20168. setMaterialByID(id: string): Mesh;
  20169. /**
  20170. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20171. * @returns an array of IAnimatable
  20172. */
  20173. getAnimatables(): IAnimatable[];
  20174. /**
  20175. * Modifies the mesh geometry according to the passed transformation matrix.
  20176. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20177. * The mesh normals are modified using the same transformation.
  20178. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20179. * @param transform defines the transform matrix to use
  20180. * @see http://doc.babylonjs.com/resources/baking_transformations
  20181. * @returns the current mesh
  20182. */
  20183. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20184. /**
  20185. * Modifies the mesh geometry according to its own current World Matrix.
  20186. * The mesh World Matrix is then reset.
  20187. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20188. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20189. * @see http://doc.babylonjs.com/resources/baking_transformations
  20190. * @returns the current mesh
  20191. */
  20192. bakeCurrentTransformIntoVertices(): Mesh;
  20193. /** @hidden */
  20194. readonly _positions: Nullable<Vector3[]>;
  20195. /** @hidden */
  20196. _resetPointsArrayCache(): Mesh;
  20197. /** @hidden */
  20198. _generatePointsArray(): boolean;
  20199. /**
  20200. * Returns a new Mesh object generated from the current mesh properties.
  20201. * This method must not get confused with createInstance()
  20202. * @param name is a string, the name given to the new mesh
  20203. * @param newParent can be any Node object (default `null`)
  20204. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20205. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20206. * @returns a new mesh
  20207. */
  20208. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20209. /**
  20210. * Releases resources associated with this mesh.
  20211. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20212. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20213. */
  20214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20215. /**
  20216. * Modifies the mesh geometry according to a displacement map.
  20217. * 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.
  20218. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20219. * @param url is a string, the URL from the image file is to be downloaded.
  20220. * @param minHeight is the lower limit of the displacement.
  20221. * @param maxHeight is the upper limit of the displacement.
  20222. * @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.
  20223. * @param uvOffset is an optional vector2 used to offset UV.
  20224. * @param uvScale is an optional vector2 used to scale UV.
  20225. * @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.
  20226. * @returns the Mesh.
  20227. */
  20228. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20229. /**
  20230. * Modifies the mesh geometry according to a displacementMap buffer.
  20231. * 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.
  20232. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20233. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20234. * @param heightMapWidth is the width of the buffer image.
  20235. * @param heightMapHeight is the height of the buffer image.
  20236. * @param minHeight is the lower limit of the displacement.
  20237. * @param maxHeight is the upper limit of the displacement.
  20238. * @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.
  20239. * @param uvOffset is an optional vector2 used to offset UV.
  20240. * @param uvScale is an optional vector2 used to scale UV.
  20241. * @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.
  20242. * @returns the Mesh.
  20243. */
  20244. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20245. /**
  20246. * Modify the mesh to get a flat shading rendering.
  20247. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20248. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20249. * @returns current mesh
  20250. */
  20251. convertToFlatShadedMesh(): Mesh;
  20252. /**
  20253. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20254. * In other words, more vertices, no more indices and a single bigger VBO.
  20255. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20256. * @returns current mesh
  20257. */
  20258. convertToUnIndexedMesh(): Mesh;
  20259. /**
  20260. * Inverses facet orientations.
  20261. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20262. * @param flipNormals will also inverts the normals
  20263. * @returns current mesh
  20264. */
  20265. flipFaces(flipNormals?: boolean): Mesh;
  20266. /** @hidden */
  20267. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20268. /** @hidden */
  20269. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20270. /**
  20271. * Creates a new InstancedMesh object from the mesh model.
  20272. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20273. * @param name defines the name of the new instance
  20274. * @returns a new InstancedMesh
  20275. */
  20276. createInstance(name: string): InstancedMesh;
  20277. /**
  20278. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20279. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20280. * @returns the current mesh
  20281. */
  20282. synchronizeInstances(): Mesh;
  20283. /**
  20284. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20285. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20286. * This should be used together with the simplification to avoid disappearing triangles.
  20287. * @param successCallback an optional success callback to be called after the optimization finished.
  20288. * @returns the current mesh
  20289. */
  20290. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20291. /**
  20292. * Serialize current mesh
  20293. * @param serializationObject defines the object which will receive the serialization data
  20294. */
  20295. serialize(serializationObject: any): void;
  20296. /** @hidden */
  20297. _syncGeometryWithMorphTargetManager(): void;
  20298. /** @hidden */
  20299. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20300. /**
  20301. * Returns a new Mesh object parsed from the source provided.
  20302. * @param parsedMesh is the source
  20303. * @param scene defines the hosting scene
  20304. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20305. * @returns a new Mesh
  20306. */
  20307. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20308. /**
  20309. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20310. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20311. * @param name defines the name of the mesh to create
  20312. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20313. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20314. * @param closePath creates a seam between the first and the last points of each path of the path array
  20315. * @param offset is taken in account only if the `pathArray` is containing a single path
  20316. * @param scene defines the hosting scene
  20317. * @param updatable defines if the mesh must be flagged as updatable
  20318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20319. * @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)
  20320. * @returns a new Mesh
  20321. */
  20322. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20323. /**
  20324. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20325. * @param name defines the name of the mesh to create
  20326. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20327. * @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
  20328. * @param scene defines the hosting scene
  20329. * @param updatable defines if the mesh must be flagged as updatable
  20330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20331. * @returns a new Mesh
  20332. */
  20333. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20334. /**
  20335. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20336. * @param name defines the name of the mesh to create
  20337. * @param size sets the size (float) of each box side (default 1)
  20338. * @param scene defines the hosting scene
  20339. * @param updatable defines if the mesh must be flagged as updatable
  20340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20341. * @returns a new Mesh
  20342. */
  20343. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20344. /**
  20345. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20346. * @param name defines the name of the mesh to create
  20347. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20348. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20349. * @param scene defines the hosting scene
  20350. * @param updatable defines if the mesh must be flagged as updatable
  20351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20352. * @returns a new Mesh
  20353. */
  20354. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20355. /**
  20356. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20357. * @param name defines the name of the mesh to create
  20358. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20359. * @param diameterTop set the top cap diameter (floats, default 1)
  20360. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20361. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20362. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20363. * @param scene defines the hosting scene
  20364. * @param updatable defines if the mesh must be flagged as updatable
  20365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20366. * @returns a new Mesh
  20367. */
  20368. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20369. /**
  20370. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20371. * @param name defines the name of the mesh to create
  20372. * @param diameter sets the diameter size (float) of the torus (default 1)
  20373. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20374. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20375. * @param scene defines the hosting scene
  20376. * @param updatable defines if the mesh must be flagged as updatable
  20377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20378. * @returns a new Mesh
  20379. */
  20380. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20381. /**
  20382. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20383. * @param name defines the name of the mesh to create
  20384. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20385. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20386. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20387. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20388. * @param p the number of windings on X axis (positive integers, default 2)
  20389. * @param q the number of windings on Y axis (positive integers, default 3)
  20390. * @param scene defines the hosting scene
  20391. * @param updatable defines if the mesh must be flagged as updatable
  20392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20393. * @returns a new Mesh
  20394. */
  20395. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20396. /**
  20397. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20398. * @param name defines the name of the mesh to create
  20399. * @param points is an array successive Vector3
  20400. * @param scene defines the hosting scene
  20401. * @param updatable defines if the mesh must be flagged as updatable
  20402. * @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).
  20403. * @returns a new Mesh
  20404. */
  20405. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20406. /**
  20407. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20408. * @param name defines the name of the mesh to create
  20409. * @param points is an array successive Vector3
  20410. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20411. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20412. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20413. * @param scene defines the hosting scene
  20414. * @param updatable defines if the mesh must be flagged as updatable
  20415. * @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)
  20416. * @returns a new Mesh
  20417. */
  20418. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20419. /**
  20420. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20421. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20422. * 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.
  20423. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20424. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20425. * Remember you can only change the shape positions, not their number when updating a polygon.
  20426. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20427. * @param name defines the name of the mesh to create
  20428. * @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
  20429. * @param scene defines the hosting scene
  20430. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20431. * @param updatable defines if the mesh must be flagged as updatable
  20432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20433. * @param earcutInjection can be used to inject your own earcut reference
  20434. * @returns a new Mesh
  20435. */
  20436. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20437. /**
  20438. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20440. * @param name defines the name of the mesh to create
  20441. * @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
  20442. * @param depth defines the height of extrusion
  20443. * @param scene defines the hosting scene
  20444. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20445. * @param updatable defines if the mesh must be flagged as updatable
  20446. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20447. * @param earcutInjection can be used to inject your own earcut reference
  20448. * @returns a new Mesh
  20449. */
  20450. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20451. /**
  20452. * Creates an extruded shape mesh.
  20453. * 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
  20454. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20455. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20456. * @param name defines the name of the mesh to create
  20457. * @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
  20458. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20459. * @param scale is the value to scale the shape
  20460. * @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
  20461. * @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
  20462. * @param scene defines the hosting scene
  20463. * @param updatable defines if the mesh must be flagged as updatable
  20464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20465. * @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)
  20466. * @returns a new Mesh
  20467. */
  20468. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20469. /**
  20470. * Creates an custom extruded shape mesh.
  20471. * The custom extrusion is a parametric shape.
  20472. * It has no predefined shape. Its final shape will depend on the input parameters.
  20473. * Please consider using the same method from the MeshBuilder class instead
  20474. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20475. * @param name defines the name of the mesh to create
  20476. * @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
  20477. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20478. * @param scaleFunction is a custom Javascript function called on each path point
  20479. * @param rotationFunction is a custom Javascript function called on each path point
  20480. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20481. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20482. * @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
  20483. * @param scene defines the hosting scene
  20484. * @param updatable defines if the mesh must be flagged as updatable
  20485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20486. * @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)
  20487. * @returns a new Mesh
  20488. */
  20489. 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;
  20490. /**
  20491. * Creates lathe mesh.
  20492. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20493. * Please consider using the same method from the MeshBuilder class instead
  20494. * @param name defines the name of the mesh to create
  20495. * @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
  20496. * @param radius is the radius value of the lathe
  20497. * @param tessellation is the side number of the lathe.
  20498. * @param scene defines the hosting scene
  20499. * @param updatable defines if the mesh must be flagged as updatable
  20500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20501. * @returns a new Mesh
  20502. */
  20503. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20504. /**
  20505. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20506. * @param name defines the name of the mesh to create
  20507. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20508. * @param scene defines the hosting scene
  20509. * @param updatable defines if the mesh must be flagged as updatable
  20510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20511. * @returns a new Mesh
  20512. */
  20513. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20514. /**
  20515. * Creates a ground mesh.
  20516. * Please consider using the same method from the MeshBuilder class instead
  20517. * @param name defines the name of the mesh to create
  20518. * @param width set the width of the ground
  20519. * @param height set the height of the ground
  20520. * @param subdivisions sets the number of subdivisions per side
  20521. * @param scene defines the hosting scene
  20522. * @param updatable defines if the mesh must be flagged as updatable
  20523. * @returns a new Mesh
  20524. */
  20525. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20526. /**
  20527. * Creates a tiled ground mesh.
  20528. * Please consider using the same method from the MeshBuilder class instead
  20529. * @param name defines the name of the mesh to create
  20530. * @param xmin set the ground minimum X coordinate
  20531. * @param zmin set the ground minimum Y coordinate
  20532. * @param xmax set the ground maximum X coordinate
  20533. * @param zmax set the ground maximum Z coordinate
  20534. * @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
  20535. * @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
  20536. * @param scene defines the hosting scene
  20537. * @param updatable defines if the mesh must be flagged as updatable
  20538. * @returns a new Mesh
  20539. */
  20540. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20541. w: number;
  20542. h: number;
  20543. }, precision: {
  20544. w: number;
  20545. h: number;
  20546. }, scene: Scene, updatable?: boolean): Mesh;
  20547. /**
  20548. * Creates a ground mesh from a height map.
  20549. * Please consider using the same method from the MeshBuilder class instead
  20550. * @see http://doc.babylonjs.com/babylon101/height_map
  20551. * @param name defines the name of the mesh to create
  20552. * @param url sets the URL of the height map image resource
  20553. * @param width set the ground width size
  20554. * @param height set the ground height size
  20555. * @param subdivisions sets the number of subdivision per side
  20556. * @param minHeight is the minimum altitude on the ground
  20557. * @param maxHeight is the maximum altitude on the ground
  20558. * @param scene defines the hosting scene
  20559. * @param updatable defines if the mesh must be flagged as updatable
  20560. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20561. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20562. * @returns a new Mesh
  20563. */
  20564. 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;
  20565. /**
  20566. * Creates a tube mesh.
  20567. * The tube is a parametric shape.
  20568. * It has no predefined shape. Its final shape will depend on the input parameters.
  20569. * Please consider using the same method from the MeshBuilder class instead
  20570. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20571. * @param name defines the name of the mesh to create
  20572. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20573. * @param radius sets the tube radius size
  20574. * @param tessellation is the number of sides on the tubular surface
  20575. * @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
  20576. * @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
  20577. * @param scene defines the hosting scene
  20578. * @param updatable defines if the mesh must be flagged as updatable
  20579. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20580. * @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)
  20581. * @returns a new Mesh
  20582. */
  20583. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20584. (i: number, distance: number): number;
  20585. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20586. /**
  20587. * Creates a polyhedron mesh.
  20588. * Please consider using the same method from the MeshBuilder class instead.
  20589. * * 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
  20590. * * The parameter `size` (positive float, default 1) sets the polygon size
  20591. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20592. * * 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`
  20593. * * 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
  20594. * * 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)`)
  20595. * * 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
  20596. * * 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
  20597. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20598. * * If you create a double-sided mesh, you can choose what parts of 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
  20599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20600. * @param name defines the name of the mesh to create
  20601. * @param options defines the options used to create the mesh
  20602. * @param scene defines the hosting scene
  20603. * @returns a new Mesh
  20604. */
  20605. static CreatePolyhedron(name: string, options: {
  20606. type?: number;
  20607. size?: number;
  20608. sizeX?: number;
  20609. sizeY?: number;
  20610. sizeZ?: number;
  20611. custom?: any;
  20612. faceUV?: Vector4[];
  20613. faceColors?: Color4[];
  20614. updatable?: boolean;
  20615. sideOrientation?: number;
  20616. }, scene: Scene): Mesh;
  20617. /**
  20618. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20619. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20620. * * 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`)
  20621. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20622. * * 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
  20623. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20624. * * If you create a double-sided mesh, you can choose what parts of 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
  20625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20626. * @param name defines the name of the mesh
  20627. * @param options defines the options used to create the mesh
  20628. * @param scene defines the hosting scene
  20629. * @returns a new Mesh
  20630. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20631. */
  20632. static CreateIcoSphere(name: string, options: {
  20633. radius?: number;
  20634. flat?: boolean;
  20635. subdivisions?: number;
  20636. sideOrientation?: number;
  20637. updatable?: boolean;
  20638. }, scene: Scene): Mesh;
  20639. /**
  20640. * Creates a decal mesh.
  20641. * Please consider using the same method from the MeshBuilder class instead.
  20642. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20643. * @param name defines the name of the mesh
  20644. * @param sourceMesh defines the mesh receiving the decal
  20645. * @param position sets the position of the decal in world coordinates
  20646. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20647. * @param size sets the decal scaling
  20648. * @param angle sets the angle to rotate the decal
  20649. * @returns a new Mesh
  20650. */
  20651. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20652. /**
  20653. * Prepare internal position array for software CPU skinning
  20654. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20655. */
  20656. setPositionsForCPUSkinning(): Float32Array;
  20657. /**
  20658. * Prepare internal normal array for software CPU skinning
  20659. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20660. */
  20661. setNormalsForCPUSkinning(): Float32Array;
  20662. /**
  20663. * Updates the vertex buffer by applying transformation from the bones
  20664. * @param skeleton defines the skeleton to apply to current mesh
  20665. * @returns the current mesh
  20666. */
  20667. applySkeleton(skeleton: Skeleton): Mesh;
  20668. /**
  20669. * 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
  20670. * @param meshes defines the list of meshes to scan
  20671. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20672. */
  20673. static MinMax(meshes: AbstractMesh[]): {
  20674. min: Vector3;
  20675. max: Vector3;
  20676. };
  20677. /**
  20678. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20679. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20680. * @returns a vector3
  20681. */
  20682. static Center(meshesOrMinMaxVector: {
  20683. min: Vector3;
  20684. max: Vector3;
  20685. } | AbstractMesh[]): Vector3;
  20686. /**
  20687. * Merge the array of meshes into a single mesh for performance reasons.
  20688. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20689. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20690. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20691. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20692. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20693. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  20694. * @returns a new mesh
  20695. */
  20696. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  20697. /** @hidden */
  20698. addInstance(instance: InstancedMesh): void;
  20699. /** @hidden */
  20700. removeInstance(instance: InstancedMesh): void;
  20701. }
  20702. }
  20703. declare module "babylonjs/Materials/material" {
  20704. import { IAnimatable } from "babylonjs/Misc/tools";
  20705. import { SmartArray } from "babylonjs/Misc/smartArray";
  20706. import { Observable } from "babylonjs/Misc/observable";
  20707. import { Nullable } from "babylonjs/types";
  20708. import { Scene } from "babylonjs/scene";
  20709. import { Matrix } from "babylonjs/Maths/math";
  20710. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20712. import { Mesh } from "babylonjs/Meshes/mesh";
  20713. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20714. import { Effect } from "babylonjs/Materials/effect";
  20715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20716. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20717. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20718. import { Animation } from "babylonjs/Animations/animation";
  20719. /**
  20720. * Base class for the main features of a material in Babylon.js
  20721. */
  20722. export class Material implements IAnimatable {
  20723. /**
  20724. * Returns the triangle fill mode
  20725. */
  20726. static readonly TriangleFillMode: number;
  20727. /**
  20728. * Returns the wireframe mode
  20729. */
  20730. static readonly WireFrameFillMode: number;
  20731. /**
  20732. * Returns the point fill mode
  20733. */
  20734. static readonly PointFillMode: number;
  20735. /**
  20736. * Returns the point list draw mode
  20737. */
  20738. static readonly PointListDrawMode: number;
  20739. /**
  20740. * Returns the line list draw mode
  20741. */
  20742. static readonly LineListDrawMode: number;
  20743. /**
  20744. * Returns the line loop draw mode
  20745. */
  20746. static readonly LineLoopDrawMode: number;
  20747. /**
  20748. * Returns the line strip draw mode
  20749. */
  20750. static readonly LineStripDrawMode: number;
  20751. /**
  20752. * Returns the triangle strip draw mode
  20753. */
  20754. static readonly TriangleStripDrawMode: number;
  20755. /**
  20756. * Returns the triangle fan draw mode
  20757. */
  20758. static readonly TriangleFanDrawMode: number;
  20759. /**
  20760. * Stores the clock-wise side orientation
  20761. */
  20762. static readonly ClockWiseSideOrientation: number;
  20763. /**
  20764. * Stores the counter clock-wise side orientation
  20765. */
  20766. static readonly CounterClockWiseSideOrientation: number;
  20767. /**
  20768. * The dirty texture flag value
  20769. */
  20770. static readonly TextureDirtyFlag: number;
  20771. /**
  20772. * The dirty light flag value
  20773. */
  20774. static readonly LightDirtyFlag: number;
  20775. /**
  20776. * The dirty fresnel flag value
  20777. */
  20778. static readonly FresnelDirtyFlag: number;
  20779. /**
  20780. * The dirty attribute flag value
  20781. */
  20782. static readonly AttributesDirtyFlag: number;
  20783. /**
  20784. * The dirty misc flag value
  20785. */
  20786. static readonly MiscDirtyFlag: number;
  20787. /**
  20788. * The all dirty flag value
  20789. */
  20790. static readonly AllDirtyFlag: number;
  20791. /**
  20792. * The ID of the material
  20793. */
  20794. id: string;
  20795. /**
  20796. * Gets or sets the unique id of the material
  20797. */
  20798. uniqueId: number;
  20799. /**
  20800. * The name of the material
  20801. */
  20802. name: string;
  20803. /**
  20804. * Gets or sets user defined metadata
  20805. */
  20806. metadata: any;
  20807. /**
  20808. * For internal use only. Please do not use.
  20809. */
  20810. reservedDataStore: any;
  20811. /**
  20812. * Specifies if the ready state should be checked on each call
  20813. */
  20814. checkReadyOnEveryCall: boolean;
  20815. /**
  20816. * Specifies if the ready state should be checked once
  20817. */
  20818. checkReadyOnlyOnce: boolean;
  20819. /**
  20820. * The state of the material
  20821. */
  20822. state: string;
  20823. /**
  20824. * The alpha value of the material
  20825. */
  20826. protected _alpha: number;
  20827. /**
  20828. * Sets the alpha value of the material
  20829. */
  20830. /**
  20831. * Gets the alpha value of the material
  20832. */
  20833. alpha: number;
  20834. /**
  20835. * Specifies if back face culling is enabled
  20836. */
  20837. protected _backFaceCulling: boolean;
  20838. /**
  20839. * Sets the back-face culling state
  20840. */
  20841. /**
  20842. * Gets the back-face culling state
  20843. */
  20844. backFaceCulling: boolean;
  20845. /**
  20846. * Stores the value for side orientation
  20847. */
  20848. sideOrientation: number;
  20849. /**
  20850. * Callback triggered when the material is compiled
  20851. */
  20852. onCompiled: (effect: Effect) => void;
  20853. /**
  20854. * Callback triggered when an error occurs
  20855. */
  20856. onError: (effect: Effect, errors: string) => void;
  20857. /**
  20858. * Callback triggered to get the render target textures
  20859. */
  20860. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20861. /**
  20862. * Gets a boolean indicating that current material needs to register RTT
  20863. */
  20864. readonly hasRenderTargetTextures: boolean;
  20865. /**
  20866. * Specifies if the material should be serialized
  20867. */
  20868. doNotSerialize: boolean;
  20869. /**
  20870. * @hidden
  20871. */
  20872. _storeEffectOnSubMeshes: boolean;
  20873. /**
  20874. * Stores the animations for the material
  20875. */
  20876. animations: Array<Animation>;
  20877. /**
  20878. * An event triggered when the material is disposed
  20879. */
  20880. onDisposeObservable: Observable<Material>;
  20881. /**
  20882. * An observer which watches for dispose events
  20883. */
  20884. private _onDisposeObserver;
  20885. private _onUnBindObservable;
  20886. /**
  20887. * Called during a dispose event
  20888. */
  20889. onDispose: () => void;
  20890. private _onBindObservable;
  20891. /**
  20892. * An event triggered when the material is bound
  20893. */
  20894. readonly onBindObservable: Observable<AbstractMesh>;
  20895. /**
  20896. * An observer which watches for bind events
  20897. */
  20898. private _onBindObserver;
  20899. /**
  20900. * Called during a bind event
  20901. */
  20902. onBind: (Mesh: AbstractMesh) => void;
  20903. /**
  20904. * An event triggered when the material is unbound
  20905. */
  20906. readonly onUnBindObservable: Observable<Material>;
  20907. /**
  20908. * Stores the value of the alpha mode
  20909. */
  20910. private _alphaMode;
  20911. /**
  20912. * Sets the value of the alpha mode.
  20913. *
  20914. * | Value | Type | Description |
  20915. * | --- | --- | --- |
  20916. * | 0 | ALPHA_DISABLE | |
  20917. * | 1 | ALPHA_ADD | |
  20918. * | 2 | ALPHA_COMBINE | |
  20919. * | 3 | ALPHA_SUBTRACT | |
  20920. * | 4 | ALPHA_MULTIPLY | |
  20921. * | 5 | ALPHA_MAXIMIZED | |
  20922. * | 6 | ALPHA_ONEONE | |
  20923. * | 7 | ALPHA_PREMULTIPLIED | |
  20924. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20925. * | 9 | ALPHA_INTERPOLATE | |
  20926. * | 10 | ALPHA_SCREENMODE | |
  20927. *
  20928. */
  20929. /**
  20930. * Gets the value of the alpha mode
  20931. */
  20932. alphaMode: number;
  20933. /**
  20934. * Stores the state of the need depth pre-pass value
  20935. */
  20936. private _needDepthPrePass;
  20937. /**
  20938. * Sets the need depth pre-pass value
  20939. */
  20940. /**
  20941. * Gets the depth pre-pass value
  20942. */
  20943. needDepthPrePass: boolean;
  20944. /**
  20945. * Specifies if depth writing should be disabled
  20946. */
  20947. disableDepthWrite: boolean;
  20948. /**
  20949. * Specifies if depth writing should be forced
  20950. */
  20951. forceDepthWrite: boolean;
  20952. /**
  20953. * Specifies if there should be a separate pass for culling
  20954. */
  20955. separateCullingPass: boolean;
  20956. /**
  20957. * Stores the state specifing if fog should be enabled
  20958. */
  20959. private _fogEnabled;
  20960. /**
  20961. * Sets the state for enabling fog
  20962. */
  20963. /**
  20964. * Gets the value of the fog enabled state
  20965. */
  20966. fogEnabled: boolean;
  20967. /**
  20968. * Stores the size of points
  20969. */
  20970. pointSize: number;
  20971. /**
  20972. * Stores the z offset value
  20973. */
  20974. zOffset: number;
  20975. /**
  20976. * Gets a value specifying if wireframe mode is enabled
  20977. */
  20978. /**
  20979. * Sets the state of wireframe mode
  20980. */
  20981. wireframe: boolean;
  20982. /**
  20983. * Gets the value specifying if point clouds are enabled
  20984. */
  20985. /**
  20986. * Sets the state of point cloud mode
  20987. */
  20988. pointsCloud: boolean;
  20989. /**
  20990. * Gets the material fill mode
  20991. */
  20992. /**
  20993. * Sets the material fill mode
  20994. */
  20995. fillMode: number;
  20996. /**
  20997. * @hidden
  20998. * Stores the effects for the material
  20999. */
  21000. _effect: Nullable<Effect>;
  21001. /**
  21002. * @hidden
  21003. * Specifies if the material was previously ready
  21004. */
  21005. _wasPreviouslyReady: boolean;
  21006. /**
  21007. * Specifies if uniform buffers should be used
  21008. */
  21009. private _useUBO;
  21010. /**
  21011. * Stores a reference to the scene
  21012. */
  21013. private _scene;
  21014. /**
  21015. * Stores the fill mode state
  21016. */
  21017. private _fillMode;
  21018. /**
  21019. * Specifies if the depth write state should be cached
  21020. */
  21021. private _cachedDepthWriteState;
  21022. /**
  21023. * Stores the uniform buffer
  21024. */
  21025. protected _uniformBuffer: UniformBuffer;
  21026. /** @hidden */
  21027. _indexInSceneMaterialArray: number;
  21028. /** @hidden */
  21029. meshMap: Nullable<{
  21030. [id: string]: AbstractMesh | undefined;
  21031. }>;
  21032. /**
  21033. * Creates a material instance
  21034. * @param name defines the name of the material
  21035. * @param scene defines the scene to reference
  21036. * @param doNotAdd specifies if the material should be added to the scene
  21037. */
  21038. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21039. /**
  21040. * Returns a string representation of the current material
  21041. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21042. * @returns a string with material information
  21043. */
  21044. toString(fullDetails?: boolean): string;
  21045. /**
  21046. * Gets the class name of the material
  21047. * @returns a string with the class name of the material
  21048. */
  21049. getClassName(): string;
  21050. /**
  21051. * Specifies if updates for the material been locked
  21052. */
  21053. readonly isFrozen: boolean;
  21054. /**
  21055. * Locks updates for the material
  21056. */
  21057. freeze(): void;
  21058. /**
  21059. * Unlocks updates for the material
  21060. */
  21061. unfreeze(): void;
  21062. /**
  21063. * Specifies if the material is ready to be used
  21064. * @param mesh defines the mesh to check
  21065. * @param useInstances specifies if instances should be used
  21066. * @returns a boolean indicating if the material is ready to be used
  21067. */
  21068. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21069. /**
  21070. * Specifies that the submesh is ready to be used
  21071. * @param mesh defines the mesh to check
  21072. * @param subMesh defines which submesh to check
  21073. * @param useInstances specifies that instances should be used
  21074. * @returns a boolean indicating that the submesh is ready or not
  21075. */
  21076. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21077. /**
  21078. * Returns the material effect
  21079. * @returns the effect associated with the material
  21080. */
  21081. getEffect(): Nullable<Effect>;
  21082. /**
  21083. * Returns the current scene
  21084. * @returns a Scene
  21085. */
  21086. getScene(): Scene;
  21087. /**
  21088. * Specifies if the material will require alpha blending
  21089. * @returns a boolean specifying if alpha blending is needed
  21090. */
  21091. needAlphaBlending(): boolean;
  21092. /**
  21093. * Specifies if the mesh will require alpha blending
  21094. * @param mesh defines the mesh to check
  21095. * @returns a boolean specifying if alpha blending is needed for the mesh
  21096. */
  21097. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21098. /**
  21099. * Specifies if this material should be rendered in alpha test mode
  21100. * @returns a boolean specifying if an alpha test is needed.
  21101. */
  21102. needAlphaTesting(): boolean;
  21103. /**
  21104. * Gets the texture used for the alpha test
  21105. * @returns the texture to use for alpha testing
  21106. */
  21107. getAlphaTestTexture(): Nullable<BaseTexture>;
  21108. /**
  21109. * Marks the material to indicate that it needs to be re-calculated
  21110. */
  21111. markDirty(): void;
  21112. /** @hidden */
  21113. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21114. /**
  21115. * Binds the material to the mesh
  21116. * @param world defines the world transformation matrix
  21117. * @param mesh defines the mesh to bind the material to
  21118. */
  21119. bind(world: Matrix, mesh?: Mesh): void;
  21120. /**
  21121. * Binds the submesh to the material
  21122. * @param world defines the world transformation matrix
  21123. * @param mesh defines the mesh containing the submesh
  21124. * @param subMesh defines the submesh to bind the material to
  21125. */
  21126. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21127. /**
  21128. * Binds the world matrix to the material
  21129. * @param world defines the world transformation matrix
  21130. */
  21131. bindOnlyWorldMatrix(world: Matrix): void;
  21132. /**
  21133. * Binds the scene's uniform buffer to the effect.
  21134. * @param effect defines the effect to bind to the scene uniform buffer
  21135. * @param sceneUbo defines the uniform buffer storing scene data
  21136. */
  21137. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21138. /**
  21139. * Binds the view matrix to the effect
  21140. * @param effect defines the effect to bind the view matrix to
  21141. */
  21142. bindView(effect: Effect): void;
  21143. /**
  21144. * Binds the view projection matrix to the effect
  21145. * @param effect defines the effect to bind the view projection matrix to
  21146. */
  21147. bindViewProjection(effect: Effect): void;
  21148. /**
  21149. * Specifies if material alpha testing should be turned on for the mesh
  21150. * @param mesh defines the mesh to check
  21151. */
  21152. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21153. /**
  21154. * Processes to execute after binding the material to a mesh
  21155. * @param mesh defines the rendered mesh
  21156. */
  21157. protected _afterBind(mesh?: Mesh): void;
  21158. /**
  21159. * Unbinds the material from the mesh
  21160. */
  21161. unbind(): void;
  21162. /**
  21163. * Gets the active textures from the material
  21164. * @returns an array of textures
  21165. */
  21166. getActiveTextures(): BaseTexture[];
  21167. /**
  21168. * Specifies if the material uses a texture
  21169. * @param texture defines the texture to check against the material
  21170. * @returns a boolean specifying if the material uses the texture
  21171. */
  21172. hasTexture(texture: BaseTexture): boolean;
  21173. /**
  21174. * Makes a duplicate of the material, and gives it a new name
  21175. * @param name defines the new name for the duplicated material
  21176. * @returns the cloned material
  21177. */
  21178. clone(name: string): Nullable<Material>;
  21179. /**
  21180. * Gets the meshes bound to the material
  21181. * @returns an array of meshes bound to the material
  21182. */
  21183. getBindedMeshes(): AbstractMesh[];
  21184. /**
  21185. * Force shader compilation
  21186. * @param mesh defines the mesh associated with this material
  21187. * @param onCompiled defines a function to execute once the material is compiled
  21188. * @param options defines the options to configure the compilation
  21189. */
  21190. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21191. clipPlane: boolean;
  21192. }>): void;
  21193. /**
  21194. * Force shader compilation
  21195. * @param mesh defines the mesh that will use this material
  21196. * @param options defines additional options for compiling the shaders
  21197. * @returns a promise that resolves when the compilation completes
  21198. */
  21199. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21200. clipPlane: boolean;
  21201. }>): Promise<void>;
  21202. private static readonly _ImageProcessingDirtyCallBack;
  21203. private static readonly _TextureDirtyCallBack;
  21204. private static readonly _FresnelDirtyCallBack;
  21205. private static readonly _MiscDirtyCallBack;
  21206. private static readonly _LightsDirtyCallBack;
  21207. private static readonly _AttributeDirtyCallBack;
  21208. private static _FresnelAndMiscDirtyCallBack;
  21209. private static _TextureAndMiscDirtyCallBack;
  21210. private static readonly _DirtyCallbackArray;
  21211. private static readonly _RunDirtyCallBacks;
  21212. /**
  21213. * Marks a define in the material to indicate that it needs to be re-computed
  21214. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21215. */
  21216. markAsDirty(flag: number): void;
  21217. /**
  21218. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21219. * @param func defines a function which checks material defines against the submeshes
  21220. */
  21221. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21222. /**
  21223. * Indicates that image processing needs to be re-calculated for all submeshes
  21224. */
  21225. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21226. /**
  21227. * Indicates that textures need to be re-calculated for all submeshes
  21228. */
  21229. protected _markAllSubMeshesAsTexturesDirty(): void;
  21230. /**
  21231. * Indicates that fresnel needs to be re-calculated for all submeshes
  21232. */
  21233. protected _markAllSubMeshesAsFresnelDirty(): void;
  21234. /**
  21235. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21236. */
  21237. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21238. /**
  21239. * Indicates that lights need to be re-calculated for all submeshes
  21240. */
  21241. protected _markAllSubMeshesAsLightsDirty(): void;
  21242. /**
  21243. * Indicates that attributes need to be re-calculated for all submeshes
  21244. */
  21245. protected _markAllSubMeshesAsAttributesDirty(): void;
  21246. /**
  21247. * Indicates that misc needs to be re-calculated for all submeshes
  21248. */
  21249. protected _markAllSubMeshesAsMiscDirty(): void;
  21250. /**
  21251. * Indicates that textures and misc need to be re-calculated for all submeshes
  21252. */
  21253. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21254. /**
  21255. * Disposes the material
  21256. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21257. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21258. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21259. */
  21260. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21261. /** @hidden */
  21262. private releaseVertexArrayObject;
  21263. /**
  21264. * Serializes this material
  21265. * @returns the serialized material object
  21266. */
  21267. serialize(): any;
  21268. /**
  21269. * Creates a material from parsed material data
  21270. * @param parsedMaterial defines parsed material data
  21271. * @param scene defines the hosting scene
  21272. * @param rootUrl defines the root URL to use to load textures
  21273. * @returns a new material
  21274. */
  21275. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21276. }
  21277. }
  21278. declare module "babylonjs/Meshes/subMesh" {
  21279. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21280. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21281. import { Engine } from "babylonjs/Engines/engine";
  21282. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21283. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21284. import { Effect } from "babylonjs/Materials/effect";
  21285. import { Collider } from "babylonjs/Collisions/collider";
  21286. import { Material } from "babylonjs/Materials/material";
  21287. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21289. import { Mesh } from "babylonjs/Meshes/mesh";
  21290. import { Ray } from "babylonjs/Culling/ray";
  21291. /**
  21292. * Base class for submeshes
  21293. */
  21294. export class BaseSubMesh {
  21295. /** @hidden */
  21296. _materialDefines: Nullable<MaterialDefines>;
  21297. /** @hidden */
  21298. _materialEffect: Nullable<Effect>;
  21299. /**
  21300. * Gets associated effect
  21301. */
  21302. readonly effect: Nullable<Effect>;
  21303. /**
  21304. * Sets associated effect (effect used to render this submesh)
  21305. * @param effect defines the effect to associate with
  21306. * @param defines defines the set of defines used to compile this effect
  21307. */
  21308. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21309. }
  21310. /**
  21311. * Defines a subdivision inside a mesh
  21312. */
  21313. export class SubMesh extends BaseSubMesh implements ICullable {
  21314. /** the material index to use */
  21315. materialIndex: number;
  21316. /** vertex index start */
  21317. verticesStart: number;
  21318. /** vertices count */
  21319. verticesCount: number;
  21320. /** index start */
  21321. indexStart: number;
  21322. /** indices count */
  21323. indexCount: number;
  21324. /** @hidden */
  21325. _linesIndexCount: number;
  21326. private _mesh;
  21327. private _renderingMesh;
  21328. private _boundingInfo;
  21329. private _linesIndexBuffer;
  21330. /** @hidden */
  21331. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21332. /** @hidden */
  21333. _trianglePlanes: Plane[];
  21334. /** @hidden */
  21335. _lastColliderTransformMatrix: Matrix;
  21336. /** @hidden */
  21337. _renderId: number;
  21338. /** @hidden */
  21339. _alphaIndex: number;
  21340. /** @hidden */
  21341. _distanceToCamera: number;
  21342. /** @hidden */
  21343. _id: number;
  21344. private _currentMaterial;
  21345. /**
  21346. * Add a new submesh to a mesh
  21347. * @param materialIndex defines the material index to use
  21348. * @param verticesStart defines vertex index start
  21349. * @param verticesCount defines vertices count
  21350. * @param indexStart defines index start
  21351. * @param indexCount defines indices count
  21352. * @param mesh defines the parent mesh
  21353. * @param renderingMesh defines an optional rendering mesh
  21354. * @param createBoundingBox defines if bounding box should be created for this submesh
  21355. * @returns the new submesh
  21356. */
  21357. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21358. /**
  21359. * Creates a new submesh
  21360. * @param materialIndex defines the material index to use
  21361. * @param verticesStart defines vertex index start
  21362. * @param verticesCount defines vertices count
  21363. * @param indexStart defines index start
  21364. * @param indexCount defines indices count
  21365. * @param mesh defines the parent mesh
  21366. * @param renderingMesh defines an optional rendering mesh
  21367. * @param createBoundingBox defines if bounding box should be created for this submesh
  21368. */
  21369. constructor(
  21370. /** the material index to use */
  21371. materialIndex: number,
  21372. /** vertex index start */
  21373. verticesStart: number,
  21374. /** vertices count */
  21375. verticesCount: number,
  21376. /** index start */
  21377. indexStart: number,
  21378. /** indices count */
  21379. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21380. /**
  21381. * Returns true if this submesh covers the entire parent mesh
  21382. * @ignorenaming
  21383. */
  21384. readonly IsGlobal: boolean;
  21385. /**
  21386. * Returns the submesh BoudingInfo object
  21387. * @returns current bounding info (or mesh's one if the submesh is global)
  21388. */
  21389. getBoundingInfo(): BoundingInfo;
  21390. /**
  21391. * Sets the submesh BoundingInfo
  21392. * @param boundingInfo defines the new bounding info to use
  21393. * @returns the SubMesh
  21394. */
  21395. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21396. /**
  21397. * Returns the mesh of the current submesh
  21398. * @return the parent mesh
  21399. */
  21400. getMesh(): AbstractMesh;
  21401. /**
  21402. * Returns the rendering mesh of the submesh
  21403. * @returns the rendering mesh (could be different from parent mesh)
  21404. */
  21405. getRenderingMesh(): Mesh;
  21406. /**
  21407. * Returns the submesh material
  21408. * @returns null or the current material
  21409. */
  21410. getMaterial(): Nullable<Material>;
  21411. /**
  21412. * Sets a new updated BoundingInfo object to the submesh
  21413. * @returns the SubMesh
  21414. */
  21415. refreshBoundingInfo(): SubMesh;
  21416. /** @hidden */
  21417. _checkCollision(collider: Collider): boolean;
  21418. /**
  21419. * Updates the submesh BoundingInfo
  21420. * @param world defines the world matrix to use to update the bounding info
  21421. * @returns the submesh
  21422. */
  21423. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21424. /**
  21425. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21426. * @param frustumPlanes defines the frustum planes
  21427. * @returns true if the submesh is intersecting with the frustum
  21428. */
  21429. isInFrustum(frustumPlanes: Plane[]): boolean;
  21430. /**
  21431. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21432. * @param frustumPlanes defines the frustum planes
  21433. * @returns true if the submesh is inside the frustum
  21434. */
  21435. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21436. /**
  21437. * Renders the submesh
  21438. * @param enableAlphaMode defines if alpha needs to be used
  21439. * @returns the submesh
  21440. */
  21441. render(enableAlphaMode: boolean): SubMesh;
  21442. /**
  21443. * @hidden
  21444. */
  21445. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21446. /**
  21447. * Checks if the submesh intersects with a ray
  21448. * @param ray defines the ray to test
  21449. * @returns true is the passed ray intersects the submesh bounding box
  21450. */
  21451. canIntersects(ray: Ray): boolean;
  21452. /**
  21453. * Intersects current submesh with a ray
  21454. * @param ray defines the ray to test
  21455. * @param positions defines mesh's positions array
  21456. * @param indices defines mesh's indices array
  21457. * @param fastCheck defines if only bounding info should be used
  21458. * @returns intersection info or null if no intersection
  21459. */
  21460. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21461. /** @hidden */
  21462. private _intersectLines;
  21463. /** @hidden */
  21464. private _intersectTriangles;
  21465. /** @hidden */
  21466. _rebuild(): void;
  21467. /**
  21468. * Creates a new submesh from the passed mesh
  21469. * @param newMesh defines the new hosting mesh
  21470. * @param newRenderingMesh defines an optional rendering mesh
  21471. * @returns the new submesh
  21472. */
  21473. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21474. /**
  21475. * Release associated resources
  21476. */
  21477. dispose(): void;
  21478. /**
  21479. * Gets the class name
  21480. * @returns the string "SubMesh".
  21481. */
  21482. getClassName(): string;
  21483. /**
  21484. * Creates a new submesh from indices data
  21485. * @param materialIndex the index of the main mesh material
  21486. * @param startIndex the index where to start the copy in the mesh indices array
  21487. * @param indexCount the number of indices to copy then from the startIndex
  21488. * @param mesh the main mesh to create the submesh from
  21489. * @param renderingMesh the optional rendering mesh
  21490. * @returns a new submesh
  21491. */
  21492. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21493. }
  21494. }
  21495. declare module "babylonjs/Meshes/geometry" {
  21496. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21497. import { Scene } from "babylonjs/scene";
  21498. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21499. import { Engine } from "babylonjs/Engines/engine";
  21500. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21501. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21502. import { Effect } from "babylonjs/Materials/effect";
  21503. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21504. import { Mesh } from "babylonjs/Meshes/mesh";
  21505. /**
  21506. * Class used to store geometry data (vertex buffers + index buffer)
  21507. */
  21508. export class Geometry implements IGetSetVerticesData {
  21509. /**
  21510. * Gets or sets the ID of the geometry
  21511. */
  21512. id: string;
  21513. /**
  21514. * Gets or sets the unique ID of the geometry
  21515. */
  21516. uniqueId: number;
  21517. /**
  21518. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21519. */
  21520. delayLoadState: number;
  21521. /**
  21522. * Gets the file containing the data to load when running in delay load state
  21523. */
  21524. delayLoadingFile: Nullable<string>;
  21525. /**
  21526. * Callback called when the geometry is updated
  21527. */
  21528. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21529. private _scene;
  21530. private _engine;
  21531. private _meshes;
  21532. private _totalVertices;
  21533. /** @hidden */
  21534. _indices: IndicesArray;
  21535. /** @hidden */
  21536. _vertexBuffers: {
  21537. [key: string]: VertexBuffer;
  21538. };
  21539. private _isDisposed;
  21540. private _extend;
  21541. private _boundingBias;
  21542. /** @hidden */
  21543. _delayInfo: Array<string>;
  21544. private _indexBuffer;
  21545. private _indexBufferIsUpdatable;
  21546. /** @hidden */
  21547. _boundingInfo: Nullable<BoundingInfo>;
  21548. /** @hidden */
  21549. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21550. /** @hidden */
  21551. _softwareSkinningFrameId: number;
  21552. private _vertexArrayObjects;
  21553. private _updatable;
  21554. /** @hidden */
  21555. _positions: Nullable<Vector3[]>;
  21556. /**
  21557. * 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
  21558. */
  21559. /**
  21560. * 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
  21561. */
  21562. boundingBias: Vector2;
  21563. /**
  21564. * Static function used to attach a new empty geometry to a mesh
  21565. * @param mesh defines the mesh to attach the geometry to
  21566. * @returns the new Geometry
  21567. */
  21568. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21569. /**
  21570. * Creates a new geometry
  21571. * @param id defines the unique ID
  21572. * @param scene defines the hosting scene
  21573. * @param vertexData defines the VertexData used to get geometry data
  21574. * @param updatable defines if geometry must be updatable (false by default)
  21575. * @param mesh defines the mesh that will be associated with the geometry
  21576. */
  21577. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21578. /**
  21579. * Gets the current extend of the geometry
  21580. */
  21581. readonly extend: {
  21582. minimum: Vector3;
  21583. maximum: Vector3;
  21584. };
  21585. /**
  21586. * Gets the hosting scene
  21587. * @returns the hosting Scene
  21588. */
  21589. getScene(): Scene;
  21590. /**
  21591. * Gets the hosting engine
  21592. * @returns the hosting Engine
  21593. */
  21594. getEngine(): Engine;
  21595. /**
  21596. * Defines if the geometry is ready to use
  21597. * @returns true if the geometry is ready to be used
  21598. */
  21599. isReady(): boolean;
  21600. /**
  21601. * Gets a value indicating that the geometry should not be serialized
  21602. */
  21603. readonly doNotSerialize: boolean;
  21604. /** @hidden */
  21605. _rebuild(): void;
  21606. /**
  21607. * Affects all geometry data in one call
  21608. * @param vertexData defines the geometry data
  21609. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21610. */
  21611. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21612. /**
  21613. * Set specific vertex data
  21614. * @param kind defines the data kind (Position, normal, etc...)
  21615. * @param data defines the vertex data to use
  21616. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21617. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21618. */
  21619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21620. /**
  21621. * Removes a specific vertex data
  21622. * @param kind defines the data kind (Position, normal, etc...)
  21623. */
  21624. removeVerticesData(kind: string): void;
  21625. /**
  21626. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21627. * @param buffer defines the vertex buffer to use
  21628. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21629. */
  21630. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21631. /**
  21632. * Update a specific vertex buffer
  21633. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21634. * It will do nothing if the buffer is not updatable
  21635. * @param kind defines the data kind (Position, normal, etc...)
  21636. * @param data defines the data to use
  21637. * @param offset defines the offset in the target buffer where to store the data
  21638. * @param useBytes set to true if the offset is in bytes
  21639. */
  21640. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21641. /**
  21642. * Update a specific vertex buffer
  21643. * This function will create a new buffer if the current one is not updatable
  21644. * @param kind defines the data kind (Position, normal, etc...)
  21645. * @param data defines the data to use
  21646. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21647. */
  21648. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21649. private _updateBoundingInfo;
  21650. /** @hidden */
  21651. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21652. /**
  21653. * Gets total number of vertices
  21654. * @returns the total number of vertices
  21655. */
  21656. getTotalVertices(): number;
  21657. /**
  21658. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21659. * @param kind defines the data kind (Position, normal, etc...)
  21660. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21662. * @returns a float array containing vertex data
  21663. */
  21664. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21665. /**
  21666. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21667. * @param kind defines the data kind (Position, normal, etc...)
  21668. * @returns true if the vertex buffer with the specified kind is updatable
  21669. */
  21670. isVertexBufferUpdatable(kind: string): boolean;
  21671. /**
  21672. * Gets a specific vertex buffer
  21673. * @param kind defines the data kind (Position, normal, etc...)
  21674. * @returns a VertexBuffer
  21675. */
  21676. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21677. /**
  21678. * Returns all vertex buffers
  21679. * @return an object holding all vertex buffers indexed by kind
  21680. */
  21681. getVertexBuffers(): Nullable<{
  21682. [key: string]: VertexBuffer;
  21683. }>;
  21684. /**
  21685. * Gets a boolean indicating if specific vertex buffer is present
  21686. * @param kind defines the data kind (Position, normal, etc...)
  21687. * @returns true if data is present
  21688. */
  21689. isVerticesDataPresent(kind: string): boolean;
  21690. /**
  21691. * Gets a list of all attached data kinds (Position, normal, etc...)
  21692. * @returns a list of string containing all kinds
  21693. */
  21694. getVerticesDataKinds(): string[];
  21695. /**
  21696. * Update index buffer
  21697. * @param indices defines the indices to store in the index buffer
  21698. * @param offset defines the offset in the target buffer where to store the data
  21699. */
  21700. updateIndices(indices: IndicesArray, offset?: number): void;
  21701. /**
  21702. * Creates a new index buffer
  21703. * @param indices defines the indices to store in the index buffer
  21704. * @param totalVertices defines the total number of vertices (could be null)
  21705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21706. */
  21707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21708. /**
  21709. * Return the total number of indices
  21710. * @returns the total number of indices
  21711. */
  21712. getTotalIndices(): number;
  21713. /**
  21714. * Gets the index buffer array
  21715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21717. * @returns the index buffer array
  21718. */
  21719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21720. /**
  21721. * Gets the index buffer
  21722. * @return the index buffer
  21723. */
  21724. getIndexBuffer(): Nullable<WebGLBuffer>;
  21725. /** @hidden */
  21726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21727. /**
  21728. * Release the associated resources for a specific mesh
  21729. * @param mesh defines the source mesh
  21730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21731. */
  21732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21733. /**
  21734. * Apply current geometry to a given mesh
  21735. * @param mesh defines the mesh to apply geometry to
  21736. */
  21737. applyToMesh(mesh: Mesh): void;
  21738. private _updateExtend;
  21739. private _applyToMesh;
  21740. private notifyUpdate;
  21741. /**
  21742. * Load the geometry if it was flagged as delay loaded
  21743. * @param scene defines the hosting scene
  21744. * @param onLoaded defines a callback called when the geometry is loaded
  21745. */
  21746. load(scene: Scene, onLoaded?: () => void): void;
  21747. private _queueLoad;
  21748. /**
  21749. * Invert the geometry to move from a right handed system to a left handed one.
  21750. */
  21751. toLeftHanded(): void;
  21752. /** @hidden */
  21753. _resetPointsArrayCache(): void;
  21754. /** @hidden */
  21755. _generatePointsArray(): boolean;
  21756. /**
  21757. * Gets a value indicating if the geometry is disposed
  21758. * @returns true if the geometry was disposed
  21759. */
  21760. isDisposed(): boolean;
  21761. private _disposeVertexArrayObjects;
  21762. /**
  21763. * Free all associated resources
  21764. */
  21765. dispose(): void;
  21766. /**
  21767. * Clone the current geometry into a new geometry
  21768. * @param id defines the unique ID of the new geometry
  21769. * @returns a new geometry object
  21770. */
  21771. copy(id: string): Geometry;
  21772. /**
  21773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21774. * @return a JSON representation of the current geometry data (without the vertices data)
  21775. */
  21776. serialize(): any;
  21777. private toNumberArray;
  21778. /**
  21779. * Serialize all vertices data into a JSON oject
  21780. * @returns a JSON representation of the current geometry data
  21781. */
  21782. serializeVerticeData(): any;
  21783. /**
  21784. * Extracts a clone of a mesh geometry
  21785. * @param mesh defines the source mesh
  21786. * @param id defines the unique ID of the new geometry object
  21787. * @returns the new geometry object
  21788. */
  21789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21790. /**
  21791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21793. * Be aware Math.random() could cause collisions, but:
  21794. * "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"
  21795. * @returns a string containing a new GUID
  21796. */
  21797. static RandomId(): string;
  21798. /** @hidden */
  21799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21800. private static _CleanMatricesWeights;
  21801. /**
  21802. * Create a new geometry from persisted data (Using .babylon file format)
  21803. * @param parsedVertexData defines the persisted data
  21804. * @param scene defines the hosting scene
  21805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21806. * @returns the new geometry object
  21807. */
  21808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21809. }
  21810. }
  21811. declare module "babylonjs/Meshes/mesh.vertexData" {
  21812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21813. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  21814. import { Geometry } from "babylonjs/Meshes/geometry";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. /**
  21817. * Define an interface for all classes that will get and set the data on vertices
  21818. */
  21819. export interface IGetSetVerticesData {
  21820. /**
  21821. * Gets a boolean indicating if specific vertex data is present
  21822. * @param kind defines the vertex data kind to use
  21823. * @returns true is data kind is present
  21824. */
  21825. isVerticesDataPresent(kind: string): boolean;
  21826. /**
  21827. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21828. * @param kind defines the data kind (Position, normal, etc...)
  21829. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21830. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21831. * @returns a float array containing vertex data
  21832. */
  21833. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21834. /**
  21835. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21836. * @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.
  21837. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21838. * @returns the indices array or an empty array if the mesh has no geometry
  21839. */
  21840. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21841. /**
  21842. * Set specific vertex data
  21843. * @param kind defines the data kind (Position, normal, etc...)
  21844. * @param data defines the vertex data to use
  21845. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21846. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21847. */
  21848. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21849. /**
  21850. * Update a specific associated vertex buffer
  21851. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21852. * - VertexBuffer.PositionKind
  21853. * - VertexBuffer.UVKind
  21854. * - VertexBuffer.UV2Kind
  21855. * - VertexBuffer.UV3Kind
  21856. * - VertexBuffer.UV4Kind
  21857. * - VertexBuffer.UV5Kind
  21858. * - VertexBuffer.UV6Kind
  21859. * - VertexBuffer.ColorKind
  21860. * - VertexBuffer.MatricesIndicesKind
  21861. * - VertexBuffer.MatricesIndicesExtraKind
  21862. * - VertexBuffer.MatricesWeightsKind
  21863. * - VertexBuffer.MatricesWeightsExtraKind
  21864. * @param data defines the data source
  21865. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21866. * @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)
  21867. */
  21868. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21869. /**
  21870. * Creates a new index buffer
  21871. * @param indices defines the indices to store in the index buffer
  21872. * @param totalVertices defines the total number of vertices (could be null)
  21873. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21874. */
  21875. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21876. }
  21877. /**
  21878. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21879. */
  21880. export class VertexData {
  21881. /**
  21882. * Mesh side orientation : usually the external or front surface
  21883. */
  21884. static readonly FRONTSIDE: number;
  21885. /**
  21886. * Mesh side orientation : usually the internal or back surface
  21887. */
  21888. static readonly BACKSIDE: number;
  21889. /**
  21890. * Mesh side orientation : both internal and external or front and back surfaces
  21891. */
  21892. static readonly DOUBLESIDE: number;
  21893. /**
  21894. * Mesh side orientation : by default, `FRONTSIDE`
  21895. */
  21896. static readonly DEFAULTSIDE: number;
  21897. /**
  21898. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21899. */
  21900. positions: Nullable<FloatArray>;
  21901. /**
  21902. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21903. */
  21904. normals: Nullable<FloatArray>;
  21905. /**
  21906. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21907. */
  21908. tangents: Nullable<FloatArray>;
  21909. /**
  21910. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21911. */
  21912. uvs: Nullable<FloatArray>;
  21913. /**
  21914. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21915. */
  21916. uvs2: Nullable<FloatArray>;
  21917. /**
  21918. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21919. */
  21920. uvs3: Nullable<FloatArray>;
  21921. /**
  21922. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21923. */
  21924. uvs4: Nullable<FloatArray>;
  21925. /**
  21926. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21927. */
  21928. uvs5: Nullable<FloatArray>;
  21929. /**
  21930. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21931. */
  21932. uvs6: Nullable<FloatArray>;
  21933. /**
  21934. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21935. */
  21936. colors: Nullable<FloatArray>;
  21937. /**
  21938. * 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).
  21939. */
  21940. matricesIndices: Nullable<FloatArray>;
  21941. /**
  21942. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21943. */
  21944. matricesWeights: Nullable<FloatArray>;
  21945. /**
  21946. * An array extending the number of possible indices
  21947. */
  21948. matricesIndicesExtra: Nullable<FloatArray>;
  21949. /**
  21950. * An array extending the number of possible weights when the number of indices is extended
  21951. */
  21952. matricesWeightsExtra: Nullable<FloatArray>;
  21953. /**
  21954. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21955. */
  21956. indices: Nullable<IndicesArray>;
  21957. /**
  21958. * Uses the passed data array to set the set the values for the specified kind of data
  21959. * @param data a linear array of floating numbers
  21960. * @param kind the type of data that is being set, eg positions, colors etc
  21961. */
  21962. set(data: FloatArray, kind: string): void;
  21963. /**
  21964. * Associates the vertexData to the passed Mesh.
  21965. * Sets it as updatable or not (default `false`)
  21966. * @param mesh the mesh the vertexData is applied to
  21967. * @param updatable when used and having the value true allows new data to update the vertexData
  21968. * @returns the VertexData
  21969. */
  21970. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21971. /**
  21972. * Associates the vertexData to the passed Geometry.
  21973. * Sets it as updatable or not (default `false`)
  21974. * @param geometry the geometry the vertexData is applied to
  21975. * @param updatable when used and having the value true allows new data to update the vertexData
  21976. * @returns VertexData
  21977. */
  21978. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21979. /**
  21980. * Updates the associated mesh
  21981. * @param mesh the mesh to be updated
  21982. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21983. * @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
  21984. * @returns VertexData
  21985. */
  21986. updateMesh(mesh: Mesh): VertexData;
  21987. /**
  21988. * Updates the associated geometry
  21989. * @param geometry the geometry to be updated
  21990. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21991. * @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
  21992. * @returns VertexData.
  21993. */
  21994. updateGeometry(geometry: Geometry): VertexData;
  21995. private _applyTo;
  21996. private _update;
  21997. /**
  21998. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21999. * @param matrix the transforming matrix
  22000. * @returns the VertexData
  22001. */
  22002. transform(matrix: Matrix): VertexData;
  22003. /**
  22004. * Merges the passed VertexData into the current one
  22005. * @param other the VertexData to be merged into the current one
  22006. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22007. * @returns the modified VertexData
  22008. */
  22009. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22010. private _mergeElement;
  22011. private _validate;
  22012. /**
  22013. * Serializes the VertexData
  22014. * @returns a serialized object
  22015. */
  22016. serialize(): any;
  22017. /**
  22018. * Extracts the vertexData from a mesh
  22019. * @param mesh the mesh from which to extract the VertexData
  22020. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22021. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22022. * @returns the object VertexData associated to the passed mesh
  22023. */
  22024. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22025. /**
  22026. * Extracts the vertexData from the geometry
  22027. * @param geometry the geometry from which to extract the VertexData
  22028. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22029. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22030. * @returns the object VertexData associated to the passed mesh
  22031. */
  22032. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22033. private static _ExtractFrom;
  22034. /**
  22035. * Creates the VertexData for a Ribbon
  22036. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22037. * * pathArray array of paths, each of which an array of successive Vector3
  22038. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22039. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22040. * * 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
  22041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22042. * * 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)
  22043. * * 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)
  22044. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22045. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22046. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22047. * @returns the VertexData of the ribbon
  22048. */
  22049. static CreateRibbon(options: {
  22050. pathArray: Vector3[][];
  22051. closeArray?: boolean;
  22052. closePath?: boolean;
  22053. offset?: number;
  22054. sideOrientation?: number;
  22055. frontUVs?: Vector4;
  22056. backUVs?: Vector4;
  22057. invertUV?: boolean;
  22058. uvs?: Vector2[];
  22059. colors?: Color4[];
  22060. }): VertexData;
  22061. /**
  22062. * Creates the VertexData for a box
  22063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22064. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22065. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22066. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22067. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22068. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22069. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22071. * * 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)
  22072. * * 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)
  22073. * @returns the VertexData of the box
  22074. */
  22075. static CreateBox(options: {
  22076. size?: number;
  22077. width?: number;
  22078. height?: number;
  22079. depth?: number;
  22080. faceUV?: Vector4[];
  22081. faceColors?: Color4[];
  22082. sideOrientation?: number;
  22083. frontUVs?: Vector4;
  22084. backUVs?: Vector4;
  22085. }): VertexData;
  22086. /**
  22087. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22089. * * segments sets the number of horizontal strips optional, default 32
  22090. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22091. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22092. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22093. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22094. * * 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
  22095. * * 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
  22096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22097. * * 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)
  22098. * * 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)
  22099. * @returns the VertexData of the ellipsoid
  22100. */
  22101. static CreateSphere(options: {
  22102. segments?: number;
  22103. diameter?: number;
  22104. diameterX?: number;
  22105. diameterY?: number;
  22106. diameterZ?: number;
  22107. arc?: number;
  22108. slice?: number;
  22109. sideOrientation?: number;
  22110. frontUVs?: Vector4;
  22111. backUVs?: Vector4;
  22112. }): VertexData;
  22113. /**
  22114. * Creates the VertexData for a cylinder, cone or prism
  22115. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22116. * * height sets the height (y direction) of the cylinder, optional, default 2
  22117. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22118. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22119. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22120. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22121. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22122. * * 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
  22123. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22124. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22125. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22126. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22128. * * 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)
  22129. * * 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)
  22130. * @returns the VertexData of the cylinder, cone or prism
  22131. */
  22132. static CreateCylinder(options: {
  22133. height?: number;
  22134. diameterTop?: number;
  22135. diameterBottom?: number;
  22136. diameter?: number;
  22137. tessellation?: number;
  22138. subdivisions?: number;
  22139. arc?: number;
  22140. faceColors?: Color4[];
  22141. faceUV?: Vector4[];
  22142. hasRings?: boolean;
  22143. enclose?: boolean;
  22144. sideOrientation?: number;
  22145. frontUVs?: Vector4;
  22146. backUVs?: Vector4;
  22147. }): VertexData;
  22148. /**
  22149. * Creates the VertexData for a torus
  22150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22151. * * diameter the diameter of the torus, optional default 1
  22152. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22153. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22155. * * 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)
  22156. * * 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)
  22157. * @returns the VertexData of the torus
  22158. */
  22159. static CreateTorus(options: {
  22160. diameter?: number;
  22161. thickness?: number;
  22162. tessellation?: number;
  22163. sideOrientation?: number;
  22164. frontUVs?: Vector4;
  22165. backUVs?: Vector4;
  22166. }): VertexData;
  22167. /**
  22168. * Creates the VertexData of the LineSystem
  22169. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22170. * - lines an array of lines, each line being an array of successive Vector3
  22171. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22172. * @returns the VertexData of the LineSystem
  22173. */
  22174. static CreateLineSystem(options: {
  22175. lines: Vector3[][];
  22176. colors?: Nullable<Color4[][]>;
  22177. }): VertexData;
  22178. /**
  22179. * Create the VertexData for a DashedLines
  22180. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22181. * - points an array successive Vector3
  22182. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22183. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22184. * - dashNb the intended total number of dashes, optional, default 200
  22185. * @returns the VertexData for the DashedLines
  22186. */
  22187. static CreateDashedLines(options: {
  22188. points: Vector3[];
  22189. dashSize?: number;
  22190. gapSize?: number;
  22191. dashNb?: number;
  22192. }): VertexData;
  22193. /**
  22194. * Creates the VertexData for a Ground
  22195. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22196. * - width the width (x direction) of the ground, optional, default 1
  22197. * - height the height (z direction) of the ground, optional, default 1
  22198. * - subdivisions the number of subdivisions per side, optional, default 1
  22199. * @returns the VertexData of the Ground
  22200. */
  22201. static CreateGround(options: {
  22202. width?: number;
  22203. height?: number;
  22204. subdivisions?: number;
  22205. subdivisionsX?: number;
  22206. subdivisionsY?: number;
  22207. }): VertexData;
  22208. /**
  22209. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22210. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22211. * * xmin the ground minimum X coordinate, optional, default -1
  22212. * * zmin the ground minimum Z coordinate, optional, default -1
  22213. * * xmax the ground maximum X coordinate, optional, default 1
  22214. * * zmax the ground maximum Z coordinate, optional, default 1
  22215. * * 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}
  22216. * * 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}
  22217. * @returns the VertexData of the TiledGround
  22218. */
  22219. static CreateTiledGround(options: {
  22220. xmin: number;
  22221. zmin: number;
  22222. xmax: number;
  22223. zmax: number;
  22224. subdivisions?: {
  22225. w: number;
  22226. h: number;
  22227. };
  22228. precision?: {
  22229. w: number;
  22230. h: number;
  22231. };
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData of the Ground designed from a heightmap
  22235. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22236. * * width the width (x direction) of the ground
  22237. * * height the height (z direction) of the ground
  22238. * * subdivisions the number of subdivisions per side
  22239. * * minHeight the minimum altitude on the ground, optional, default 0
  22240. * * maxHeight the maximum altitude on the ground, optional default 1
  22241. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22242. * * buffer the array holding the image color data
  22243. * * bufferWidth the width of image
  22244. * * bufferHeight the height of image
  22245. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22246. * @returns the VertexData of the Ground designed from a heightmap
  22247. */
  22248. static CreateGroundFromHeightMap(options: {
  22249. width: number;
  22250. height: number;
  22251. subdivisions: number;
  22252. minHeight: number;
  22253. maxHeight: number;
  22254. colorFilter: Color3;
  22255. buffer: Uint8Array;
  22256. bufferWidth: number;
  22257. bufferHeight: number;
  22258. alphaFilter: number;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a Plane
  22262. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22263. * * size sets the width and height of the plane to the value of size, optional default 1
  22264. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22265. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * @returns the VertexData of the box
  22270. */
  22271. static CreatePlane(options: {
  22272. size?: number;
  22273. width?: number;
  22274. height?: number;
  22275. sideOrientation?: number;
  22276. frontUVs?: Vector4;
  22277. backUVs?: Vector4;
  22278. }): VertexData;
  22279. /**
  22280. * Creates the VertexData of the Disc or regular Polygon
  22281. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22282. * * radius the radius of the disc, optional default 0.5
  22283. * * tessellation the number of polygon sides, optional, default 64
  22284. * * 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
  22285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22286. * * 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)
  22287. * * 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)
  22288. * @returns the VertexData of the box
  22289. */
  22290. static CreateDisc(options: {
  22291. radius?: number;
  22292. tessellation?: number;
  22293. arc?: number;
  22294. sideOrientation?: number;
  22295. frontUVs?: Vector4;
  22296. backUVs?: Vector4;
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22300. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22301. * @param polygon a mesh built from polygonTriangulation.build()
  22302. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22303. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22304. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22305. * @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)
  22306. * @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)
  22307. * @returns the VertexData of the Polygon
  22308. */
  22309. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22310. /**
  22311. * Creates the VertexData of the IcoSphere
  22312. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22313. * * radius the radius of the IcoSphere, optional default 1
  22314. * * radiusX allows stretching in the x direction, optional, default radius
  22315. * * radiusY allows stretching in the y direction, optional, default radius
  22316. * * radiusZ allows stretching in the z direction, optional, default radius
  22317. * * flat when true creates a flat shaded mesh, optional, default true
  22318. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22320. * * 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)
  22321. * * 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)
  22322. * @returns the VertexData of the IcoSphere
  22323. */
  22324. static CreateIcoSphere(options: {
  22325. radius?: number;
  22326. radiusX?: number;
  22327. radiusY?: number;
  22328. radiusZ?: number;
  22329. flat?: boolean;
  22330. subdivisions?: number;
  22331. sideOrientation?: number;
  22332. frontUVs?: Vector4;
  22333. backUVs?: Vector4;
  22334. }): VertexData;
  22335. /**
  22336. * Creates the VertexData for a Polyhedron
  22337. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22338. * * type provided types are:
  22339. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22340. * * 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)
  22341. * * size the size of the IcoSphere, optional default 1
  22342. * * sizeX allows stretching in the x direction, optional, default size
  22343. * * sizeY allows stretching in the y direction, optional, default size
  22344. * * sizeZ allows stretching in the z direction, optional, default size
  22345. * * 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
  22346. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22347. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22348. * * flat when true creates a flat shaded mesh, optional, default true
  22349. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22351. * * 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)
  22352. * * 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)
  22353. * @returns the VertexData of the Polyhedron
  22354. */
  22355. static CreatePolyhedron(options: {
  22356. type?: number;
  22357. size?: number;
  22358. sizeX?: number;
  22359. sizeY?: number;
  22360. sizeZ?: number;
  22361. custom?: any;
  22362. faceUV?: Vector4[];
  22363. faceColors?: Color4[];
  22364. flat?: boolean;
  22365. sideOrientation?: number;
  22366. frontUVs?: Vector4;
  22367. backUVs?: Vector4;
  22368. }): VertexData;
  22369. /**
  22370. * Creates the VertexData for a TorusKnot
  22371. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22372. * * radius the radius of the torus knot, optional, default 2
  22373. * * tube the thickness of the tube, optional, default 0.5
  22374. * * radialSegments the number of sides on each tube segments, optional, default 32
  22375. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22376. * * p the number of windings around the z axis, optional, default 2
  22377. * * q the number of windings around the x axis, optional, default 3
  22378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22379. * * 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)
  22380. * * 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)
  22381. * @returns the VertexData of the Torus Knot
  22382. */
  22383. static CreateTorusKnot(options: {
  22384. radius?: number;
  22385. tube?: number;
  22386. radialSegments?: number;
  22387. tubularSegments?: number;
  22388. p?: number;
  22389. q?: number;
  22390. sideOrientation?: number;
  22391. frontUVs?: Vector4;
  22392. backUVs?: Vector4;
  22393. }): VertexData;
  22394. /**
  22395. * Compute normals for given positions and indices
  22396. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22397. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22398. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22399. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22400. * * facetNormals : optional array of facet normals (vector3)
  22401. * * facetPositions : optional array of facet positions (vector3)
  22402. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22403. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22404. * * bInfo : optional bounding info, required for facetPartitioning computation
  22405. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22406. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22407. * * useRightHandedSystem: optional boolean to for right handed system computation
  22408. * * depthSort : optional boolean to enable the facet depth sort computation
  22409. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22410. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22411. */
  22412. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22413. facetNormals?: any;
  22414. facetPositions?: any;
  22415. facetPartitioning?: any;
  22416. ratio?: number;
  22417. bInfo?: any;
  22418. bbSize?: Vector3;
  22419. subDiv?: any;
  22420. useRightHandedSystem?: boolean;
  22421. depthSort?: boolean;
  22422. distanceTo?: Vector3;
  22423. depthSortedFacets?: any;
  22424. }): void;
  22425. /** @hidden */
  22426. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22427. /**
  22428. * Applies VertexData created from the imported parameters to the geometry
  22429. * @param parsedVertexData the parsed data from an imported file
  22430. * @param geometry the geometry to apply the VertexData to
  22431. */
  22432. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22433. }
  22434. }
  22435. declare module "babylonjs/Meshes/Builders/discBuilder" {
  22436. import { Nullable } from "babylonjs/types";
  22437. import { Scene } from "babylonjs/scene";
  22438. import { Vector4 } from "babylonjs/Maths/math";
  22439. import { Mesh } from "babylonjs/Meshes/mesh";
  22440. /**
  22441. * Class containing static functions to help procedurally build meshes
  22442. */
  22443. export class DiscBuilder {
  22444. /**
  22445. * Creates a plane polygonal mesh. By default, this is a disc
  22446. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22447. * * 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
  22448. * * 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
  22449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22452. * @param name defines the name of the mesh
  22453. * @param options defines the options used to create the mesh
  22454. * @param scene defines the hosting scene
  22455. * @returns the plane polygonal mesh
  22456. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22457. */
  22458. static CreateDisc(name: string, options: {
  22459. radius?: number;
  22460. tessellation?: number;
  22461. arc?: number;
  22462. updatable?: boolean;
  22463. sideOrientation?: number;
  22464. frontUVs?: Vector4;
  22465. backUVs?: Vector4;
  22466. }, scene?: Nullable<Scene>): Mesh;
  22467. }
  22468. }
  22469. declare module "babylonjs/Particles/solidParticleSystem" {
  22470. import { Vector3 } from "babylonjs/Maths/math";
  22471. import { Mesh } from "babylonjs/Meshes/mesh";
  22472. import { Scene, IDisposable } from "babylonjs/scene";
  22473. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  22474. /**
  22475. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22476. *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.
  22477. * The SPS is also a particle system. It provides some methods to manage the particles.
  22478. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22479. *
  22480. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22481. */
  22482. export class SolidParticleSystem implements IDisposable {
  22483. /**
  22484. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22485. * Example : var p = SPS.particles[i];
  22486. */
  22487. particles: SolidParticle[];
  22488. /**
  22489. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22490. */
  22491. nbParticles: number;
  22492. /**
  22493. * If the particles must ever face the camera (default false). Useful for planar particles.
  22494. */
  22495. billboard: boolean;
  22496. /**
  22497. * Recompute normals when adding a shape
  22498. */
  22499. recomputeNormals: boolean;
  22500. /**
  22501. * This a counter ofr your own usage. It's not set by any SPS functions.
  22502. */
  22503. counter: number;
  22504. /**
  22505. * The SPS name. This name is also given to the underlying mesh.
  22506. */
  22507. name: string;
  22508. /**
  22509. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22510. */
  22511. mesh: Mesh;
  22512. /**
  22513. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22514. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22515. */
  22516. vars: any;
  22517. /**
  22518. * This array is populated when the SPS is set as 'pickable'.
  22519. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22520. * Each element of this array is an object `{idx: int, faceId: int}`.
  22521. * `idx` is the picked particle index in the `SPS.particles` array
  22522. * `faceId` is the picked face index counted within this particle.
  22523. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22524. */
  22525. pickedParticles: {
  22526. idx: number;
  22527. faceId: number;
  22528. }[];
  22529. /**
  22530. * This array is populated when `enableDepthSort` is set to true.
  22531. * Each element of this array is an instance of the class DepthSortedParticle.
  22532. */
  22533. depthSortedParticles: DepthSortedParticle[];
  22534. /**
  22535. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22536. * @hidden
  22537. */
  22538. _bSphereOnly: boolean;
  22539. /**
  22540. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22541. * @hidden
  22542. */
  22543. _bSphereRadiusFactor: number;
  22544. private _scene;
  22545. private _positions;
  22546. private _indices;
  22547. private _normals;
  22548. private _colors;
  22549. private _uvs;
  22550. private _indices32;
  22551. private _positions32;
  22552. private _normals32;
  22553. private _fixedNormal32;
  22554. private _colors32;
  22555. private _uvs32;
  22556. private _index;
  22557. private _updatable;
  22558. private _pickable;
  22559. private _isVisibilityBoxLocked;
  22560. private _alwaysVisible;
  22561. private _depthSort;
  22562. private _shapeCounter;
  22563. private _copy;
  22564. private _color;
  22565. private _computeParticleColor;
  22566. private _computeParticleTexture;
  22567. private _computeParticleRotation;
  22568. private _computeParticleVertex;
  22569. private _computeBoundingBox;
  22570. private _depthSortParticles;
  22571. private _camera;
  22572. private _mustUnrotateFixedNormals;
  22573. private _particlesIntersect;
  22574. private _needs32Bits;
  22575. /**
  22576. * Creates a SPS (Solid Particle System) object.
  22577. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22578. * @param scene (Scene) is the scene in which the SPS is added.
  22579. * @param options defines the options of the sps e.g.
  22580. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22581. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22582. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22583. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22584. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22585. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22586. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22587. */
  22588. constructor(name: string, scene: Scene, options?: {
  22589. updatable?: boolean;
  22590. isPickable?: boolean;
  22591. enableDepthSort?: boolean;
  22592. particleIntersection?: boolean;
  22593. boundingSphereOnly?: boolean;
  22594. bSphereRadiusFactor?: number;
  22595. });
  22596. /**
  22597. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22598. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22599. * @returns the created mesh
  22600. */
  22601. buildMesh(): Mesh;
  22602. /**
  22603. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22604. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22605. * Thus the particles generated from `digest()` have their property `position` set yet.
  22606. * @param mesh ( Mesh ) is the mesh to be digested
  22607. * @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
  22608. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22609. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22610. * @returns the current SPS
  22611. */
  22612. digest(mesh: Mesh, options?: {
  22613. facetNb?: number;
  22614. number?: number;
  22615. delta?: number;
  22616. }): SolidParticleSystem;
  22617. private _unrotateFixedNormals;
  22618. private _resetCopy;
  22619. private _meshBuilder;
  22620. private _posToShape;
  22621. private _uvsToShapeUV;
  22622. private _addParticle;
  22623. /**
  22624. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22625. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22626. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22627. * @param nb (positive integer) the number of particles to be created from this model
  22628. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22629. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22630. * @returns the number of shapes in the system
  22631. */
  22632. addShape(mesh: Mesh, nb: number, options?: {
  22633. positionFunction?: any;
  22634. vertexFunction?: any;
  22635. }): number;
  22636. private _rebuildParticle;
  22637. /**
  22638. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22639. * @returns the SPS.
  22640. */
  22641. rebuildMesh(): SolidParticleSystem;
  22642. /**
  22643. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22644. * This method calls `updateParticle()` for each particle of the SPS.
  22645. * For an animated SPS, it is usually called within the render loop.
  22646. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22647. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22648. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22649. * @returns the SPS.
  22650. */
  22651. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22652. /**
  22653. * Disposes the SPS.
  22654. */
  22655. dispose(): void;
  22656. /**
  22657. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22658. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22659. * @returns the SPS.
  22660. */
  22661. refreshVisibleSize(): SolidParticleSystem;
  22662. /**
  22663. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22664. * @param size the size (float) of the visibility box
  22665. * note : this doesn't lock the SPS mesh bounding box.
  22666. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22667. */
  22668. setVisibilityBox(size: number): void;
  22669. /**
  22670. * Gets whether the SPS as always visible or not
  22671. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22672. */
  22673. /**
  22674. * Sets the SPS as always visible or not
  22675. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22676. */
  22677. isAlwaysVisible: boolean;
  22678. /**
  22679. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22680. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22681. */
  22682. /**
  22683. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22684. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22685. */
  22686. isVisibilityBoxLocked: boolean;
  22687. /**
  22688. * Tells to `setParticles()` to compute the particle rotations or not.
  22689. * Default value : true. The SPS is faster when it's set to false.
  22690. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22691. */
  22692. /**
  22693. * Gets if `setParticles()` computes the particle rotations or not.
  22694. * Default value : true. The SPS is faster when it's set to false.
  22695. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22696. */
  22697. computeParticleRotation: boolean;
  22698. /**
  22699. * Tells to `setParticles()` to compute the particle colors or not.
  22700. * Default value : true. The SPS is faster when it's set to false.
  22701. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22702. */
  22703. /**
  22704. * Gets if `setParticles()` computes the particle colors or not.
  22705. * Default value : true. The SPS is faster when it's set to false.
  22706. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22707. */
  22708. computeParticleColor: boolean;
  22709. /**
  22710. * Gets if `setParticles()` computes the particle textures or not.
  22711. * Default value : true. The SPS is faster when it's set to false.
  22712. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22713. */
  22714. computeParticleTexture: boolean;
  22715. /**
  22716. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22717. * Default value : false. The SPS is faster when it's set to false.
  22718. * Note : the particle custom vertex positions aren't stored values.
  22719. */
  22720. /**
  22721. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22722. * Default value : false. The SPS is faster when it's set to false.
  22723. * Note : the particle custom vertex positions aren't stored values.
  22724. */
  22725. computeParticleVertex: boolean;
  22726. /**
  22727. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22728. */
  22729. /**
  22730. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22731. */
  22732. computeBoundingBox: boolean;
  22733. /**
  22734. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22735. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22736. * Default : `true`
  22737. */
  22738. /**
  22739. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22740. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22741. * Default : `true`
  22742. */
  22743. depthSortParticles: boolean;
  22744. /**
  22745. * This function does nothing. It may be overwritten to set all the particle first values.
  22746. * The SPS doesn't call this function, you may have to call it by your own.
  22747. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22748. */
  22749. initParticles(): void;
  22750. /**
  22751. * This function does nothing. It may be overwritten to recycle a particle.
  22752. * The SPS doesn't call this function, you may have to call it by your own.
  22753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22754. * @param particle The particle to recycle
  22755. * @returns the recycled particle
  22756. */
  22757. recycleParticle(particle: SolidParticle): SolidParticle;
  22758. /**
  22759. * Updates a particle : this function should be overwritten by the user.
  22760. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22761. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22762. * @example : just set a particle position or velocity and recycle conditions
  22763. * @param particle The particle to update
  22764. * @returns the updated particle
  22765. */
  22766. updateParticle(particle: SolidParticle): SolidParticle;
  22767. /**
  22768. * Updates a vertex of a particle : it can be overwritten by the user.
  22769. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22770. * @param particle the current particle
  22771. * @param vertex the current index of the current particle
  22772. * @param pt the index of the current vertex in the particle shape
  22773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22774. * @example : just set a vertex particle position
  22775. * @returns the updated vertex
  22776. */
  22777. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22778. /**
  22779. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22780. * This does nothing and may be overwritten by the user.
  22781. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22782. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22783. * @param update the boolean update value actually passed to setParticles()
  22784. */
  22785. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22786. /**
  22787. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22788. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22795. }
  22796. }
  22797. declare module "babylonjs/Particles/solidParticle" {
  22798. import { Nullable } from "babylonjs/types";
  22799. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  22800. import { Mesh } from "babylonjs/Meshes/mesh";
  22801. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22802. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  22803. /**
  22804. * Represents one particle of a solid particle system.
  22805. */
  22806. export class SolidParticle {
  22807. /**
  22808. * particle global index
  22809. */
  22810. idx: number;
  22811. /**
  22812. * The color of the particle
  22813. */
  22814. color: Nullable<Color4>;
  22815. /**
  22816. * The world space position of the particle.
  22817. */
  22818. position: Vector3;
  22819. /**
  22820. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22821. */
  22822. rotation: Vector3;
  22823. /**
  22824. * The world space rotation quaternion of the particle.
  22825. */
  22826. rotationQuaternion: Nullable<Quaternion>;
  22827. /**
  22828. * The scaling of the particle.
  22829. */
  22830. scaling: Vector3;
  22831. /**
  22832. * The uvs of the particle.
  22833. */
  22834. uvs: Vector4;
  22835. /**
  22836. * The current speed of the particle.
  22837. */
  22838. velocity: Vector3;
  22839. /**
  22840. * The pivot point in the particle local space.
  22841. */
  22842. pivot: Vector3;
  22843. /**
  22844. * Must the particle be translated from its pivot point in its local space ?
  22845. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22846. * Default : false
  22847. */
  22848. translateFromPivot: boolean;
  22849. /**
  22850. * Is the particle active or not ?
  22851. */
  22852. alive: boolean;
  22853. /**
  22854. * Is the particle visible or not ?
  22855. */
  22856. isVisible: boolean;
  22857. /**
  22858. * Index of this particle in the global "positions" array (Internal use)
  22859. * @hidden
  22860. */
  22861. _pos: number;
  22862. /**
  22863. * @hidden Index of this particle in the global "indices" array (Internal use)
  22864. */
  22865. _ind: number;
  22866. /**
  22867. * @hidden ModelShape of this particle (Internal use)
  22868. */
  22869. _model: ModelShape;
  22870. /**
  22871. * ModelShape id of this particle
  22872. */
  22873. shapeId: number;
  22874. /**
  22875. * Index of the particle in its shape id (Internal use)
  22876. */
  22877. idxInShape: number;
  22878. /**
  22879. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22880. */
  22881. _modelBoundingInfo: BoundingInfo;
  22882. /**
  22883. * @hidden Particle BoundingInfo object (Internal use)
  22884. */
  22885. _boundingInfo: BoundingInfo;
  22886. /**
  22887. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22888. */
  22889. _sps: SolidParticleSystem;
  22890. /**
  22891. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22892. */
  22893. _stillInvisible: boolean;
  22894. /**
  22895. * @hidden Last computed particle rotation matrix
  22896. */
  22897. _rotationMatrix: number[];
  22898. /**
  22899. * Parent particle Id, if any.
  22900. * Default null.
  22901. */
  22902. parentId: Nullable<number>;
  22903. /**
  22904. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22905. * The possible values are :
  22906. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22907. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22908. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22910. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22911. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22912. * */
  22913. cullingStrategy: number;
  22914. /**
  22915. * @hidden Internal global position in the SPS.
  22916. */
  22917. _globalPosition: Vector3;
  22918. /**
  22919. * Creates a Solid Particle object.
  22920. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22921. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22922. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22923. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22924. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22925. * @param shapeId (integer) is the model shape identifier in the SPS.
  22926. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22927. * @param sps defines the sps it is associated to
  22928. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22929. */
  22930. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22931. /**
  22932. * Legacy support, changed scale to scaling
  22933. */
  22934. /**
  22935. * Legacy support, changed scale to scaling
  22936. */
  22937. scale: Vector3;
  22938. /**
  22939. * Legacy support, changed quaternion to rotationQuaternion
  22940. */
  22941. /**
  22942. * Legacy support, changed quaternion to rotationQuaternion
  22943. */
  22944. quaternion: Nullable<Quaternion>;
  22945. /**
  22946. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22947. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22948. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22949. * @returns true if it intersects
  22950. */
  22951. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22952. /**
  22953. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22954. * A particle is in the frustum if its bounding box intersects the frustum
  22955. * @param frustumPlanes defines the frustum to test
  22956. * @returns true if the particle is in the frustum planes
  22957. */
  22958. isInFrustum(frustumPlanes: Plane[]): boolean;
  22959. /**
  22960. * get the rotation matrix of the particle
  22961. * @hidden
  22962. */
  22963. getRotationMatrix(m: Matrix): void;
  22964. }
  22965. /**
  22966. * Represents the shape of the model used by one particle of a solid particle system.
  22967. * SPS internal tool, don't use it manually.
  22968. */
  22969. export class ModelShape {
  22970. /**
  22971. * The shape id
  22972. * @hidden
  22973. */
  22974. shapeID: number;
  22975. /**
  22976. * flat array of model positions (internal use)
  22977. * @hidden
  22978. */
  22979. _shape: Vector3[];
  22980. /**
  22981. * flat array of model UVs (internal use)
  22982. * @hidden
  22983. */
  22984. _shapeUV: number[];
  22985. /**
  22986. * length of the shape in the model indices array (internal use)
  22987. * @hidden
  22988. */
  22989. _indicesLength: number;
  22990. /**
  22991. * Custom position function (internal use)
  22992. * @hidden
  22993. */
  22994. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22995. /**
  22996. * Custom vertex function (internal use)
  22997. * @hidden
  22998. */
  22999. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23000. /**
  23001. * 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.
  23002. * SPS internal tool, don't use it manually.
  23003. * @hidden
  23004. */
  23005. 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>);
  23006. }
  23007. /**
  23008. * Represents a Depth Sorted Particle in the solid particle system.
  23009. */
  23010. export class DepthSortedParticle {
  23011. /**
  23012. * Index of the particle in the "indices" array
  23013. */
  23014. ind: number;
  23015. /**
  23016. * Length of the particle shape in the "indices" array
  23017. */
  23018. indicesLength: number;
  23019. /**
  23020. * Squared distance from the particle to the camera
  23021. */
  23022. sqDistance: number;
  23023. }
  23024. }
  23025. declare module "babylonjs/Meshes/abstractMesh" {
  23026. import { Observable } from "babylonjs/Misc/observable";
  23027. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23028. import { Camera } from "babylonjs/Cameras/camera";
  23029. import { Scene, IDisposable } from "babylonjs/scene";
  23030. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23031. import { Node } from "babylonjs/node";
  23032. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23034. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23035. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23036. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23037. import { Material } from "babylonjs/Materials/material";
  23038. import { Light } from "babylonjs/Lights/light";
  23039. import { Skeleton } from "babylonjs/Bones/skeleton";
  23040. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23041. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23042. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23043. import { Ray } from "babylonjs/Culling/ray";
  23044. import { Collider } from "babylonjs/Collisions/collider";
  23045. /**
  23046. * Class used to store all common mesh properties
  23047. */
  23048. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23049. /** No occlusion */
  23050. static OCCLUSION_TYPE_NONE: number;
  23051. /** Occlusion set to optimisitic */
  23052. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23053. /** Occlusion set to strict */
  23054. static OCCLUSION_TYPE_STRICT: number;
  23055. /** Use an accurante occlusion algorithm */
  23056. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23057. /** Use a conservative occlusion algorithm */
  23058. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23059. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23060. * Test order :
  23061. * Is the bounding sphere outside the frustum ?
  23062. * If not, are the bounding box vertices outside the frustum ?
  23063. * It not, then the cullable object is in the frustum.
  23064. */
  23065. static readonly CULLINGSTRATEGY_STANDARD: number;
  23066. /** Culling strategy : Bounding Sphere Only.
  23067. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23068. * It's also less accurate than the standard because some not visible objects can still be selected.
  23069. * Test : is the bounding sphere outside the frustum ?
  23070. * If not, then the cullable object is in the frustum.
  23071. */
  23072. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23073. /** Culling strategy : Optimistic Inclusion.
  23074. * This in an inclusion test first, then the standard exclusion test.
  23075. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23076. * 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.
  23077. * Anyway, it's as accurate as the standard strategy.
  23078. * Test :
  23079. * Is the cullable object bounding sphere center in the frustum ?
  23080. * If not, apply the default culling strategy.
  23081. */
  23082. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23083. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23084. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23085. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23086. * 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.
  23087. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23088. * Test :
  23089. * Is the cullable object bounding sphere center in the frustum ?
  23090. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23091. */
  23092. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23093. /**
  23094. * No billboard
  23095. */
  23096. static readonly BILLBOARDMODE_NONE: number;
  23097. /** Billboard on X axis */
  23098. static readonly BILLBOARDMODE_X: number;
  23099. /** Billboard on Y axis */
  23100. static readonly BILLBOARDMODE_Y: number;
  23101. /** Billboard on Z axis */
  23102. static readonly BILLBOARDMODE_Z: number;
  23103. /** Billboard on all axes */
  23104. static readonly BILLBOARDMODE_ALL: number;
  23105. private _facetData;
  23106. /**
  23107. * The culling strategy to use to check whether the mesh must be rendered or not.
  23108. * This value can be changed at any time and will be used on the next render mesh selection.
  23109. * The possible values are :
  23110. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23111. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23112. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23113. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23114. * Please read each static variable documentation to get details about the culling process.
  23115. * */
  23116. cullingStrategy: number;
  23117. /**
  23118. * Gets the number of facets in the mesh
  23119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23120. */
  23121. readonly facetNb: number;
  23122. /**
  23123. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23125. */
  23126. partitioningSubdivisions: number;
  23127. /**
  23128. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23129. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23131. */
  23132. partitioningBBoxRatio: number;
  23133. /**
  23134. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23135. * Works only for updatable meshes.
  23136. * Doesn't work with multi-materials
  23137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23138. */
  23139. mustDepthSortFacets: boolean;
  23140. /**
  23141. * The location (Vector3) where the facet depth sort must be computed from.
  23142. * By default, the active camera position.
  23143. * Used only when facet depth sort is enabled
  23144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23145. */
  23146. facetDepthSortFrom: Vector3;
  23147. /**
  23148. * gets a boolean indicating if facetData is enabled
  23149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23150. */
  23151. readonly isFacetDataEnabled: boolean;
  23152. /** @hidden */
  23153. _updateNonUniformScalingState(value: boolean): boolean;
  23154. /**
  23155. * An event triggered when this mesh collides with another one
  23156. */
  23157. onCollideObservable: Observable<AbstractMesh>;
  23158. private _onCollideObserver;
  23159. /** Set a function to call when this mesh collides with another one */
  23160. onCollide: () => void;
  23161. /**
  23162. * An event triggered when the collision's position changes
  23163. */
  23164. onCollisionPositionChangeObservable: Observable<Vector3>;
  23165. private _onCollisionPositionChangeObserver;
  23166. /** Set a function to call when the collision's position changes */
  23167. onCollisionPositionChange: () => void;
  23168. /**
  23169. * An event triggered when material is changed
  23170. */
  23171. onMaterialChangedObservable: Observable<AbstractMesh>;
  23172. /**
  23173. * Gets or sets the orientation for POV movement & rotation
  23174. */
  23175. definedFacingForward: boolean;
  23176. /** @hidden */
  23177. _occlusionQuery: Nullable<WebGLQuery>;
  23178. private _visibility;
  23179. /**
  23180. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23181. */
  23182. /**
  23183. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23184. */
  23185. visibility: number;
  23186. /** Gets or sets the alpha index used to sort transparent meshes
  23187. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23188. */
  23189. alphaIndex: number;
  23190. /**
  23191. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23192. */
  23193. isVisible: boolean;
  23194. /**
  23195. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23196. */
  23197. isPickable: boolean;
  23198. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23199. showSubMeshesBoundingBox: boolean;
  23200. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23201. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23202. */
  23203. isBlocker: boolean;
  23204. /**
  23205. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23206. */
  23207. enablePointerMoveEvents: boolean;
  23208. /**
  23209. * Specifies the rendering group id for this mesh (0 by default)
  23210. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23211. */
  23212. renderingGroupId: number;
  23213. private _material;
  23214. /** Gets or sets current material */
  23215. material: Nullable<Material>;
  23216. private _receiveShadows;
  23217. /**
  23218. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23219. * @see http://doc.babylonjs.com/babylon101/shadows
  23220. */
  23221. receiveShadows: boolean;
  23222. /** Defines color to use when rendering outline */
  23223. outlineColor: Color3;
  23224. /** Define width to use when rendering outline */
  23225. outlineWidth: number;
  23226. /** Defines color to use when rendering overlay */
  23227. overlayColor: Color3;
  23228. /** Defines alpha to use when rendering overlay */
  23229. overlayAlpha: number;
  23230. private _hasVertexAlpha;
  23231. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23232. hasVertexAlpha: boolean;
  23233. private _useVertexColors;
  23234. /** 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) */
  23235. useVertexColors: boolean;
  23236. private _computeBonesUsingShaders;
  23237. /**
  23238. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23239. */
  23240. computeBonesUsingShaders: boolean;
  23241. private _numBoneInfluencers;
  23242. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23243. numBoneInfluencers: number;
  23244. private _applyFog;
  23245. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23246. applyFog: boolean;
  23247. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23248. useOctreeForRenderingSelection: boolean;
  23249. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23250. useOctreeForPicking: boolean;
  23251. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23252. useOctreeForCollisions: boolean;
  23253. private _layerMask;
  23254. /**
  23255. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23256. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23257. */
  23258. layerMask: number;
  23259. /**
  23260. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23261. */
  23262. alwaysSelectAsActiveMesh: boolean;
  23263. /**
  23264. * Gets or sets the current action manager
  23265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23266. */
  23267. actionManager: Nullable<AbstractActionManager>;
  23268. private _checkCollisions;
  23269. private _collisionMask;
  23270. private _collisionGroup;
  23271. /**
  23272. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23273. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23274. */
  23275. ellipsoid: Vector3;
  23276. /**
  23277. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23279. */
  23280. ellipsoidOffset: Vector3;
  23281. private _collider;
  23282. private _oldPositionForCollisions;
  23283. private _diffPositionForCollisions;
  23284. /**
  23285. * Gets or sets a collision mask used to mask collisions (default is -1).
  23286. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23287. */
  23288. collisionMask: number;
  23289. /**
  23290. * Gets or sets the current collision group mask (-1 by default).
  23291. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23292. */
  23293. collisionGroup: number;
  23294. /**
  23295. * Defines edge width used when edgesRenderer is enabled
  23296. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23297. */
  23298. edgesWidth: number;
  23299. /**
  23300. * Defines edge color used when edgesRenderer is enabled
  23301. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23302. */
  23303. edgesColor: Color4;
  23304. /** @hidden */
  23305. _edgesRenderer: Nullable<IEdgesRenderer>;
  23306. /** @hidden */
  23307. _masterMesh: Nullable<AbstractMesh>;
  23308. /** @hidden */
  23309. _boundingInfo: Nullable<BoundingInfo>;
  23310. /** @hidden */
  23311. _renderId: number;
  23312. /**
  23313. * Gets or sets the list of subMeshes
  23314. * @see http://doc.babylonjs.com/how_to/multi_materials
  23315. */
  23316. subMeshes: SubMesh[];
  23317. /** @hidden */
  23318. _intersectionsInProgress: AbstractMesh[];
  23319. /** @hidden */
  23320. _unIndexed: boolean;
  23321. /** @hidden */
  23322. _lightSources: Light[];
  23323. /** @hidden */
  23324. readonly _positions: Nullable<Vector3[]>;
  23325. /** @hidden */
  23326. _waitingActions: any;
  23327. /** @hidden */
  23328. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23329. private _skeleton;
  23330. /** @hidden */
  23331. _bonesTransformMatrices: Nullable<Float32Array>;
  23332. /**
  23333. * Gets or sets a skeleton to apply skining transformations
  23334. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23335. */
  23336. skeleton: Nullable<Skeleton>;
  23337. /**
  23338. * An event triggered when the mesh is rebuilt.
  23339. */
  23340. onRebuildObservable: Observable<AbstractMesh>;
  23341. /**
  23342. * Creates a new AbstractMesh
  23343. * @param name defines the name of the mesh
  23344. * @param scene defines the hosting scene
  23345. */
  23346. constructor(name: string, scene?: Nullable<Scene>);
  23347. /**
  23348. * Returns the string "AbstractMesh"
  23349. * @returns "AbstractMesh"
  23350. */
  23351. getClassName(): string;
  23352. /**
  23353. * Gets a string representation of the current mesh
  23354. * @param fullDetails defines a boolean indicating if full details must be included
  23355. * @returns a string representation of the current mesh
  23356. */
  23357. toString(fullDetails?: boolean): string;
  23358. /** @hidden */
  23359. _rebuild(): void;
  23360. /** @hidden */
  23361. _resyncLightSources(): void;
  23362. /** @hidden */
  23363. _resyncLighSource(light: Light): void;
  23364. /** @hidden */
  23365. _unBindEffect(): void;
  23366. /** @hidden */
  23367. _removeLightSource(light: Light): void;
  23368. private _markSubMeshesAsDirty;
  23369. /** @hidden */
  23370. _markSubMeshesAsLightDirty(): void;
  23371. /** @hidden */
  23372. _markSubMeshesAsAttributesDirty(): void;
  23373. /** @hidden */
  23374. _markSubMeshesAsMiscDirty(): void;
  23375. /**
  23376. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23377. */
  23378. scaling: Vector3;
  23379. /**
  23380. * Returns true if the mesh is blocked. Implemented by child classes
  23381. */
  23382. readonly isBlocked: boolean;
  23383. /**
  23384. * Returns the mesh itself by default. Implemented by child classes
  23385. * @param camera defines the camera to use to pick the right LOD level
  23386. * @returns the currentAbstractMesh
  23387. */
  23388. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23389. /**
  23390. * Returns 0 by default. Implemented by child classes
  23391. * @returns an integer
  23392. */
  23393. getTotalVertices(): number;
  23394. /**
  23395. * Returns a positive integer : the total number of indices in this mesh geometry.
  23396. * @returns the numner of indices or zero if the mesh has no geometry.
  23397. */
  23398. getTotalIndices(): number;
  23399. /**
  23400. * Returns null by default. Implemented by child classes
  23401. * @returns null
  23402. */
  23403. getIndices(): Nullable<IndicesArray>;
  23404. /**
  23405. * Returns the array of the requested vertex data kind. Implemented by child classes
  23406. * @param kind defines the vertex data kind to use
  23407. * @returns null
  23408. */
  23409. getVerticesData(kind: string): Nullable<FloatArray>;
  23410. /**
  23411. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23412. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23413. * Note that a new underlying VertexBuffer object is created each call.
  23414. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23415. * @param kind defines vertex data kind:
  23416. * * VertexBuffer.PositionKind
  23417. * * VertexBuffer.UVKind
  23418. * * VertexBuffer.UV2Kind
  23419. * * VertexBuffer.UV3Kind
  23420. * * VertexBuffer.UV4Kind
  23421. * * VertexBuffer.UV5Kind
  23422. * * VertexBuffer.UV6Kind
  23423. * * VertexBuffer.ColorKind
  23424. * * VertexBuffer.MatricesIndicesKind
  23425. * * VertexBuffer.MatricesIndicesExtraKind
  23426. * * VertexBuffer.MatricesWeightsKind
  23427. * * VertexBuffer.MatricesWeightsExtraKind
  23428. * @param data defines the data source
  23429. * @param updatable defines if the data must be flagged as updatable (or static)
  23430. * @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
  23431. * @returns the current mesh
  23432. */
  23433. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23434. /**
  23435. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23436. * If the mesh has no geometry, it is simply returned as it is.
  23437. * @param kind defines vertex data kind:
  23438. * * VertexBuffer.PositionKind
  23439. * * VertexBuffer.UVKind
  23440. * * VertexBuffer.UV2Kind
  23441. * * VertexBuffer.UV3Kind
  23442. * * VertexBuffer.UV4Kind
  23443. * * VertexBuffer.UV5Kind
  23444. * * VertexBuffer.UV6Kind
  23445. * * VertexBuffer.ColorKind
  23446. * * VertexBuffer.MatricesIndicesKind
  23447. * * VertexBuffer.MatricesIndicesExtraKind
  23448. * * VertexBuffer.MatricesWeightsKind
  23449. * * VertexBuffer.MatricesWeightsExtraKind
  23450. * @param data defines the data source
  23451. * @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
  23452. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23453. * @returns the current mesh
  23454. */
  23455. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23456. /**
  23457. * Sets the mesh indices,
  23458. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23459. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23460. * @param totalVertices Defines the total number of vertices
  23461. * @returns the current mesh
  23462. */
  23463. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23464. /**
  23465. * Gets a boolean indicating if specific vertex data is present
  23466. * @param kind defines the vertex data kind to use
  23467. * @returns true is data kind is present
  23468. */
  23469. isVerticesDataPresent(kind: string): boolean;
  23470. /**
  23471. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23472. * @returns a BoundingInfo
  23473. */
  23474. getBoundingInfo(): BoundingInfo;
  23475. /**
  23476. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23477. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23478. * @returns the current mesh
  23479. */
  23480. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23481. /**
  23482. * Overwrite the current bounding info
  23483. * @param boundingInfo defines the new bounding info
  23484. * @returns the current mesh
  23485. */
  23486. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23487. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23488. readonly useBones: boolean;
  23489. /** @hidden */
  23490. _preActivate(): void;
  23491. /** @hidden */
  23492. _preActivateForIntermediateRendering(renderId: number): void;
  23493. /** @hidden */
  23494. _activate(renderId: number): void;
  23495. /**
  23496. * Gets the current world matrix
  23497. * @returns a Matrix
  23498. */
  23499. getWorldMatrix(): Matrix;
  23500. /** @hidden */
  23501. _getWorldMatrixDeterminant(): number;
  23502. /**
  23503. * Perform relative position change from the point of view of behind the front of the mesh.
  23504. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23505. * Supports definition of mesh facing forward or backward
  23506. * @param amountRight defines the distance on the right axis
  23507. * @param amountUp defines the distance on the up axis
  23508. * @param amountForward defines the distance on the forward axis
  23509. * @returns the current mesh
  23510. */
  23511. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23512. /**
  23513. * Calculate relative position change from the point of view of behind the front of the mesh.
  23514. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23515. * Supports definition of mesh facing forward or backward
  23516. * @param amountRight defines the distance on the right axis
  23517. * @param amountUp defines the distance on the up axis
  23518. * @param amountForward defines the distance on the forward axis
  23519. * @returns the new displacement vector
  23520. */
  23521. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23522. /**
  23523. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23524. * Supports definition of mesh facing forward or backward
  23525. * @param flipBack defines the flip
  23526. * @param twirlClockwise defines the twirl
  23527. * @param tiltRight defines the tilt
  23528. * @returns the current mesh
  23529. */
  23530. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23531. /**
  23532. * Calculate 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 new rotation vector
  23538. */
  23539. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23540. /**
  23541. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23542. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23543. * @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
  23544. * @returns the new bounding vectors
  23545. */
  23546. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23547. min: Vector3;
  23548. max: Vector3;
  23549. };
  23550. /**
  23551. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23552. * This means the mesh underlying bounding box and sphere are recomputed.
  23553. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23554. * @returns the current mesh
  23555. */
  23556. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23557. /** @hidden */
  23558. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23559. /** @hidden */
  23560. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23561. /** @hidden */
  23562. _updateBoundingInfo(): AbstractMesh;
  23563. /** @hidden */
  23564. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23565. /** @hidden */
  23566. protected _afterComputeWorldMatrix(): void;
  23567. /**
  23568. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23569. * A mesh is in the frustum if its bounding box intersects the frustum
  23570. * @param frustumPlanes defines the frustum to test
  23571. * @returns true if the mesh is in the frustum planes
  23572. */
  23573. isInFrustum(frustumPlanes: Plane[]): boolean;
  23574. /**
  23575. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23576. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23577. * @param frustumPlanes defines the frustum to test
  23578. * @returns true if the mesh is completely in the frustum planes
  23579. */
  23580. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23581. /**
  23582. * True if the mesh intersects another mesh or a SolidParticle object
  23583. * @param mesh defines a target mesh or SolidParticle to test
  23584. * @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)
  23585. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23586. * @returns true if there is an intersection
  23587. */
  23588. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23589. /**
  23590. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23591. * @param point defines the point to test
  23592. * @returns true if there is an intersection
  23593. */
  23594. intersectsPoint(point: Vector3): boolean;
  23595. /**
  23596. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23598. */
  23599. checkCollisions: boolean;
  23600. /**
  23601. * Gets Collider object used to compute collisions (not physics)
  23602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23603. */
  23604. readonly collider: Collider;
  23605. /**
  23606. * Move the mesh using collision engine
  23607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23608. * @param displacement defines the requested displacement vector
  23609. * @returns the current mesh
  23610. */
  23611. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23612. private _onCollisionPositionChange;
  23613. /** @hidden */
  23614. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23615. /** @hidden */
  23616. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23617. /** @hidden */
  23618. _checkCollision(collider: Collider): AbstractMesh;
  23619. /** @hidden */
  23620. _generatePointsArray(): boolean;
  23621. /**
  23622. * Checks if the passed Ray intersects with the mesh
  23623. * @param ray defines the ray to use
  23624. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23625. * @returns the picking info
  23626. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23627. */
  23628. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23629. /**
  23630. * Clones the current mesh
  23631. * @param name defines the mesh name
  23632. * @param newParent defines the new mesh parent
  23633. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23634. * @returns the new mesh
  23635. */
  23636. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23637. /**
  23638. * Disposes all the submeshes of the current meshnp
  23639. * @returns the current mesh
  23640. */
  23641. releaseSubMeshes(): AbstractMesh;
  23642. /**
  23643. * Releases resources associated with this abstract mesh.
  23644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23646. */
  23647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23648. /**
  23649. * Adds the passed mesh as a child to the current mesh
  23650. * @param mesh defines the child mesh
  23651. * @returns the current mesh
  23652. */
  23653. addChild(mesh: AbstractMesh): AbstractMesh;
  23654. /**
  23655. * Removes the passed mesh from the current mesh children list
  23656. * @param mesh defines the child mesh
  23657. * @returns the current mesh
  23658. */
  23659. removeChild(mesh: AbstractMesh): AbstractMesh;
  23660. /** @hidden */
  23661. private _initFacetData;
  23662. /**
  23663. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23664. * This method can be called within the render loop.
  23665. * 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
  23666. * @returns the current mesh
  23667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23668. */
  23669. updateFacetData(): AbstractMesh;
  23670. /**
  23671. * Returns the facetLocalNormals array.
  23672. * The normals are expressed in the mesh local spac
  23673. * @returns an array of Vector3
  23674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23675. */
  23676. getFacetLocalNormals(): Vector3[];
  23677. /**
  23678. * Returns the facetLocalPositions array.
  23679. * The facet positions are expressed in the mesh local space
  23680. * @returns an array of Vector3
  23681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23682. */
  23683. getFacetLocalPositions(): Vector3[];
  23684. /**
  23685. * Returns the facetLocalPartioning array
  23686. * @returns an array of array of numbers
  23687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23688. */
  23689. getFacetLocalPartitioning(): number[][];
  23690. /**
  23691. * Returns the i-th facet position in the world system.
  23692. * This method allocates a new Vector3 per call
  23693. * @param i defines the facet index
  23694. * @returns a new Vector3
  23695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23696. */
  23697. getFacetPosition(i: number): Vector3;
  23698. /**
  23699. * Sets the reference Vector3 with the i-th facet position in the world system
  23700. * @param i defines the facet index
  23701. * @param ref defines the target vector
  23702. * @returns the current mesh
  23703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23704. */
  23705. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23706. /**
  23707. * Returns the i-th facet normal in the world system.
  23708. * This method allocates a new Vector3 per call
  23709. * @param i defines the facet index
  23710. * @returns a new Vector3
  23711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23712. */
  23713. getFacetNormal(i: number): Vector3;
  23714. /**
  23715. * Sets the reference Vector3 with the i-th facet normal in the world system
  23716. * @param i defines the facet index
  23717. * @param ref defines the target vector
  23718. * @returns the current mesh
  23719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23720. */
  23721. getFacetNormalToRef(i: number, ref: Vector3): this;
  23722. /**
  23723. * 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)
  23724. * @param x defines x coordinate
  23725. * @param y defines y coordinate
  23726. * @param z defines z coordinate
  23727. * @returns the array of facet indexes
  23728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23729. */
  23730. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23731. /**
  23732. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23733. * @param projected sets as the (x,y,z) world projection on the facet
  23734. * @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
  23735. * @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
  23736. * @param x defines x coordinate
  23737. * @param y defines y coordinate
  23738. * @param z defines z coordinate
  23739. * @returns the face index if found (or null instead)
  23740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23741. */
  23742. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23743. /**
  23744. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23745. * @param projected sets as the (x,y,z) local projection on the facet
  23746. * @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
  23747. * @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
  23748. * @param x defines x coordinate
  23749. * @param y defines y coordinate
  23750. * @param z defines z coordinate
  23751. * @returns the face index if found (or null instead)
  23752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23753. */
  23754. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23755. /**
  23756. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23757. * @returns the parameters
  23758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23759. */
  23760. getFacetDataParameters(): any;
  23761. /**
  23762. * Disables the feature FacetData and frees the related memory
  23763. * @returns the current mesh
  23764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23765. */
  23766. disableFacetData(): AbstractMesh;
  23767. /**
  23768. * Updates the AbstractMesh indices array
  23769. * @param indices defines the data source
  23770. * @returns the current mesh
  23771. */
  23772. updateIndices(indices: IndicesArray): AbstractMesh;
  23773. /**
  23774. * Creates new normals data for the mesh
  23775. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23776. * @returns the current mesh
  23777. */
  23778. createNormals(updatable: boolean): AbstractMesh;
  23779. /**
  23780. * Align the mesh with a normal
  23781. * @param normal defines the normal to use
  23782. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23783. * @returns the current mesh
  23784. */
  23785. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23786. /** @hidden */
  23787. _checkOcclusionQuery(): boolean;
  23788. }
  23789. }
  23790. declare module "babylonjs/Bones/skeleton" {
  23791. import { Bone } from "babylonjs/Bones/bone";
  23792. import { IAnimatable } from "babylonjs/Misc/tools";
  23793. import { Observable } from "babylonjs/Misc/observable";
  23794. import { Vector3, Matrix } from "babylonjs/Maths/math";
  23795. import { Scene } from "babylonjs/scene";
  23796. import { Nullable } from "babylonjs/types";
  23797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23798. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  23799. import { Animatable } from "babylonjs/Animations/animatable";
  23800. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23801. import { Animation } from "babylonjs/Animations/animation";
  23802. import { AnimationRange } from "babylonjs/Animations/animationRange";
  23803. /**
  23804. * Class used to handle skinning animations
  23805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23806. */
  23807. export class Skeleton implements IAnimatable {
  23808. /** defines the skeleton name */
  23809. name: string;
  23810. /** defines the skeleton Id */
  23811. id: string;
  23812. /**
  23813. * Defines the list of child bones
  23814. */
  23815. bones: Bone[];
  23816. /**
  23817. * Defines an estimate of the dimension of the skeleton at rest
  23818. */
  23819. dimensionsAtRest: Vector3;
  23820. /**
  23821. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23822. */
  23823. needInitialSkinMatrix: boolean;
  23824. /**
  23825. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23826. */
  23827. overrideMesh: Nullable<AbstractMesh>;
  23828. /**
  23829. * Gets the list of animations attached to this skeleton
  23830. */
  23831. animations: Array<Animation>;
  23832. private _scene;
  23833. private _isDirty;
  23834. private _transformMatrices;
  23835. private _transformMatrixTexture;
  23836. private _meshesWithPoseMatrix;
  23837. private _animatables;
  23838. private _identity;
  23839. private _synchronizedWithMesh;
  23840. private _ranges;
  23841. private _lastAbsoluteTransformsUpdateId;
  23842. private _canUseTextureForBones;
  23843. /** @hidden */
  23844. _numBonesWithLinkedTransformNode: number;
  23845. /**
  23846. * Specifies if the skeleton should be serialized
  23847. */
  23848. doNotSerialize: boolean;
  23849. /**
  23850. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23851. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23852. */
  23853. useTextureToStoreBoneMatrices: boolean;
  23854. private _animationPropertiesOverride;
  23855. /**
  23856. * Gets or sets the animation properties override
  23857. */
  23858. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23859. /**
  23860. * An observable triggered before computing the skeleton's matrices
  23861. */
  23862. onBeforeComputeObservable: Observable<Skeleton>;
  23863. /**
  23864. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23865. */
  23866. readonly isUsingTextureForMatrices: boolean;
  23867. /**
  23868. * Creates a new skeleton
  23869. * @param name defines the skeleton name
  23870. * @param id defines the skeleton Id
  23871. * @param scene defines the hosting scene
  23872. */
  23873. constructor(
  23874. /** defines the skeleton name */
  23875. name: string,
  23876. /** defines the skeleton Id */
  23877. id: string, scene: Scene);
  23878. /**
  23879. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23880. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23881. * @returns a Float32Array containing matrices data
  23882. */
  23883. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23884. /**
  23885. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23886. * @returns a raw texture containing the data
  23887. */
  23888. getTransformMatrixTexture(): Nullable<RawTexture>;
  23889. /**
  23890. * Gets the current hosting scene
  23891. * @returns a scene object
  23892. */
  23893. getScene(): Scene;
  23894. /**
  23895. * Gets a string representing the current skeleton data
  23896. * @param fullDetails defines a boolean indicating if we want a verbose version
  23897. * @returns a string representing the current skeleton data
  23898. */
  23899. toString(fullDetails?: boolean): string;
  23900. /**
  23901. * Get bone's index searching by name
  23902. * @param name defines bone's name to search for
  23903. * @return the indice of the bone. Returns -1 if not found
  23904. */
  23905. getBoneIndexByName(name: string): number;
  23906. /**
  23907. * Creater a new animation range
  23908. * @param name defines the name of the range
  23909. * @param from defines the start key
  23910. * @param to defines the end key
  23911. */
  23912. createAnimationRange(name: string, from: number, to: number): void;
  23913. /**
  23914. * Delete a specific animation range
  23915. * @param name defines the name of the range
  23916. * @param deleteFrames defines if frames must be removed as well
  23917. */
  23918. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23919. /**
  23920. * Gets a specific animation range
  23921. * @param name defines the name of the range to look for
  23922. * @returns the requested animation range or null if not found
  23923. */
  23924. getAnimationRange(name: string): Nullable<AnimationRange>;
  23925. /**
  23926. * Gets the list of all animation ranges defined on this skeleton
  23927. * @returns an array
  23928. */
  23929. getAnimationRanges(): Nullable<AnimationRange>[];
  23930. /**
  23931. * Copy animation range from a source skeleton.
  23932. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23933. * @param source defines the source skeleton
  23934. * @param name defines the name of the range to copy
  23935. * @param rescaleAsRequired defines if rescaling must be applied if required
  23936. * @returns true if operation was successful
  23937. */
  23938. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23939. /**
  23940. * Forces the skeleton to go to rest pose
  23941. */
  23942. returnToRest(): void;
  23943. private _getHighestAnimationFrame;
  23944. /**
  23945. * Begin a specific animation range
  23946. * @param name defines the name of the range to start
  23947. * @param loop defines if looping must be turned on (false by default)
  23948. * @param speedRatio defines the speed ratio to apply (1 by default)
  23949. * @param onAnimationEnd defines a callback which will be called when animation will end
  23950. * @returns a new animatable
  23951. */
  23952. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23953. /** @hidden */
  23954. _markAsDirty(): void;
  23955. /** @hidden */
  23956. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23957. /** @hidden */
  23958. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23959. private _computeTransformMatrices;
  23960. /**
  23961. * Build all resources required to render a skeleton
  23962. */
  23963. prepare(): void;
  23964. /**
  23965. * Gets the list of animatables currently running for this skeleton
  23966. * @returns an array of animatables
  23967. */
  23968. getAnimatables(): IAnimatable[];
  23969. /**
  23970. * Clone the current skeleton
  23971. * @param name defines the name of the new skeleton
  23972. * @param id defines the id of the enw skeleton
  23973. * @returns the new skeleton
  23974. */
  23975. clone(name: string, id: string): Skeleton;
  23976. /**
  23977. * Enable animation blending for this skeleton
  23978. * @param blendingSpeed defines the blending speed to apply
  23979. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23980. */
  23981. enableBlending(blendingSpeed?: number): void;
  23982. /**
  23983. * Releases all resources associated with the current skeleton
  23984. */
  23985. dispose(): void;
  23986. /**
  23987. * Serialize the skeleton in a JSON object
  23988. * @returns a JSON object
  23989. */
  23990. serialize(): any;
  23991. /**
  23992. * Creates a new skeleton from serialized data
  23993. * @param parsedSkeleton defines the serialized data
  23994. * @param scene defines the hosting scene
  23995. * @returns a new skeleton
  23996. */
  23997. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23998. /**
  23999. * Compute all node absolute transforms
  24000. * @param forceUpdate defines if computation must be done even if cache is up to date
  24001. */
  24002. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  24003. /**
  24004. * Gets the root pose matrix
  24005. * @returns a matrix
  24006. */
  24007. getPoseMatrix(): Nullable<Matrix>;
  24008. /**
  24009. * Sorts bones per internal index
  24010. */
  24011. sortBones(): void;
  24012. private _sortBones;
  24013. }
  24014. }
  24015. declare module "babylonjs/Bones/bone" {
  24016. import { Skeleton } from "babylonjs/Bones/skeleton";
  24017. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  24018. import { Nullable } from "babylonjs/types";
  24019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24021. import { Node } from "babylonjs/node";
  24022. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24023. /**
  24024. * Class used to store bone information
  24025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24026. */
  24027. export class Bone extends Node {
  24028. /**
  24029. * defines the bone name
  24030. */
  24031. name: string;
  24032. private static _tmpVecs;
  24033. private static _tmpQuat;
  24034. private static _tmpMats;
  24035. /**
  24036. * Gets the list of child bones
  24037. */
  24038. children: Bone[];
  24039. /** Gets the animations associated with this bone */
  24040. animations: import("babylonjs/Animations/animation").Animation[];
  24041. /**
  24042. * Gets or sets bone length
  24043. */
  24044. length: number;
  24045. /**
  24046. * @hidden Internal only
  24047. * Set this value to map this bone to a different index in the transform matrices
  24048. * Set this value to -1 to exclude the bone from the transform matrices
  24049. */
  24050. _index: Nullable<number>;
  24051. private _skeleton;
  24052. private _localMatrix;
  24053. private _restPose;
  24054. private _baseMatrix;
  24055. private _absoluteTransform;
  24056. private _invertedAbsoluteTransform;
  24057. private _parent;
  24058. private _scalingDeterminant;
  24059. private _worldTransform;
  24060. private _localScaling;
  24061. private _localRotation;
  24062. private _localPosition;
  24063. private _needToDecompose;
  24064. private _needToCompose;
  24065. /** @hidden */
  24066. _linkedTransformNode: Nullable<TransformNode>;
  24067. /** @hidden */
  24068. /** @hidden */
  24069. _matrix: Matrix;
  24070. /**
  24071. * Create a new bone
  24072. * @param name defines the bone name
  24073. * @param skeleton defines the parent skeleton
  24074. * @param parentBone defines the parent (can be null if the bone is the root)
  24075. * @param localMatrix defines the local matrix
  24076. * @param restPose defines the rest pose matrix
  24077. * @param baseMatrix defines the base matrix
  24078. * @param index defines index of the bone in the hiearchy
  24079. */
  24080. constructor(
  24081. /**
  24082. * defines the bone name
  24083. */
  24084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  24085. /**
  24086. * Gets the parent skeleton
  24087. * @returns a skeleton
  24088. */
  24089. getSkeleton(): Skeleton;
  24090. /**
  24091. * Gets parent bone
  24092. * @returns a bone or null if the bone is the root of the bone hierarchy
  24093. */
  24094. getParent(): Nullable<Bone>;
  24095. /**
  24096. * Sets the parent bone
  24097. * @param parent defines the parent (can be null if the bone is the root)
  24098. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24099. */
  24100. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  24101. /**
  24102. * Gets the local matrix
  24103. * @returns a matrix
  24104. */
  24105. getLocalMatrix(): Matrix;
  24106. /**
  24107. * Gets the base matrix (initial matrix which remains unchanged)
  24108. * @returns a matrix
  24109. */
  24110. getBaseMatrix(): Matrix;
  24111. /**
  24112. * Gets the rest pose matrix
  24113. * @returns a matrix
  24114. */
  24115. getRestPose(): Matrix;
  24116. /**
  24117. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  24118. */
  24119. getWorldMatrix(): Matrix;
  24120. /**
  24121. * Sets the local matrix to rest pose matrix
  24122. */
  24123. returnToRest(): void;
  24124. /**
  24125. * Gets the inverse of the absolute transform matrix.
  24126. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  24127. * @returns a matrix
  24128. */
  24129. getInvertedAbsoluteTransform(): Matrix;
  24130. /**
  24131. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  24132. * @returns a matrix
  24133. */
  24134. getAbsoluteTransform(): Matrix;
  24135. /**
  24136. * Links with the given transform node.
  24137. * The local matrix of this bone is copied from the transform node every frame.
  24138. * @param transformNode defines the transform node to link to
  24139. */
  24140. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  24141. /** Gets or sets current position (in local space) */
  24142. position: Vector3;
  24143. /** Gets or sets current rotation (in local space) */
  24144. rotation: Vector3;
  24145. /** Gets or sets current rotation quaternion (in local space) */
  24146. rotationQuaternion: Quaternion;
  24147. /** Gets or sets current scaling (in local space) */
  24148. scaling: Vector3;
  24149. /**
  24150. * Gets the animation properties override
  24151. */
  24152. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24153. private _decompose;
  24154. private _compose;
  24155. /**
  24156. * Update the base and local matrices
  24157. * @param matrix defines the new base or local matrix
  24158. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24159. * @param updateLocalMatrix defines if the local matrix should be updated
  24160. */
  24161. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  24162. /** @hidden */
  24163. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  24164. /**
  24165. * Flag the bone as dirty (Forcing it to update everything)
  24166. */
  24167. markAsDirty(): void;
  24168. private _markAsDirtyAndCompose;
  24169. private _markAsDirtyAndDecompose;
  24170. /**
  24171. * Translate the bone in local or world space
  24172. * @param vec The amount to translate the bone
  24173. * @param space The space that the translation is in
  24174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24175. */
  24176. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24177. /**
  24178. * Set the postion of the bone in local or world space
  24179. * @param position The position to set the bone
  24180. * @param space The space that the position is in
  24181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24182. */
  24183. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24184. /**
  24185. * Set the absolute position of the bone (world space)
  24186. * @param position The position to set the bone
  24187. * @param mesh The mesh that this bone is attached to
  24188. */
  24189. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  24190. /**
  24191. * Scale the bone on the x, y and z axes (in local space)
  24192. * @param x The amount to scale the bone on the x axis
  24193. * @param y The amount to scale the bone on the y axis
  24194. * @param z The amount to scale the bone on the z axis
  24195. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  24196. */
  24197. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  24198. /**
  24199. * Set the bone scaling in local space
  24200. * @param scale defines the scaling vector
  24201. */
  24202. setScale(scale: Vector3): void;
  24203. /**
  24204. * Gets the current scaling in local space
  24205. * @returns the current scaling vector
  24206. */
  24207. getScale(): Vector3;
  24208. /**
  24209. * Gets the current scaling in local space and stores it in a target vector
  24210. * @param result defines the target vector
  24211. */
  24212. getScaleToRef(result: Vector3): void;
  24213. /**
  24214. * Set the yaw, pitch, and roll of the bone in local or world space
  24215. * @param yaw The rotation of the bone on the y axis
  24216. * @param pitch The rotation of the bone on the x axis
  24217. * @param roll The rotation of the bone on the z axis
  24218. * @param space The space that the axes of rotation are in
  24219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24220. */
  24221. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  24222. /**
  24223. * Add a rotation to the bone on an axis in local or world space
  24224. * @param axis The axis to rotate the bone on
  24225. * @param amount The amount to rotate the bone
  24226. * @param space The space that the axis is in
  24227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24228. */
  24229. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  24230. /**
  24231. * Set the rotation of the bone to a particular axis angle in local or world space
  24232. * @param axis The axis to rotate the bone on
  24233. * @param angle The angle that the bone should be rotated to
  24234. * @param space The space that the axis is in
  24235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24236. */
  24237. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  24238. /**
  24239. * Set the euler rotation of the bone in local of world space
  24240. * @param rotation The euler rotation that the bone should be set to
  24241. * @param space The space that the rotation is in
  24242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24243. */
  24244. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24245. /**
  24246. * Set the quaternion rotation of the bone in local of world space
  24247. * @param quat The quaternion rotation that the bone should be set to
  24248. * @param space The space that the rotation is in
  24249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24250. */
  24251. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  24252. /**
  24253. * Set the rotation matrix of the bone in local of world space
  24254. * @param rotMat The rotation matrix that the bone should be set to
  24255. * @param space The space that the rotation is in
  24256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24257. */
  24258. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  24259. private _rotateWithMatrix;
  24260. private _getNegativeRotationToRef;
  24261. /**
  24262. * Get the position of the bone in local or world space
  24263. * @param space The space that the returned position is in
  24264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24265. * @returns The position of the bone
  24266. */
  24267. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24268. /**
  24269. * Copy the position of the bone to a vector3 in local or world space
  24270. * @param space The space that the returned position is in
  24271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24272. * @param result The vector3 to copy the position to
  24273. */
  24274. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  24275. /**
  24276. * Get the absolute position of the bone (world space)
  24277. * @param mesh The mesh that this bone is attached to
  24278. * @returns The absolute position of the bone
  24279. */
  24280. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  24281. /**
  24282. * Copy the absolute position of the bone (world space) to the result param
  24283. * @param mesh The mesh that this bone is attached to
  24284. * @param result The vector3 to copy the absolute position to
  24285. */
  24286. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  24287. /**
  24288. * Compute the absolute transforms of this bone and its children
  24289. */
  24290. computeAbsoluteTransforms(): void;
  24291. /**
  24292. * Get the world direction from an axis that is in the local space of the bone
  24293. * @param localAxis The local direction that is used to compute the world direction
  24294. * @param mesh The mesh that this bone is attached to
  24295. * @returns The world direction
  24296. */
  24297. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24298. /**
  24299. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  24300. * @param localAxis The local direction that is used to compute the world direction
  24301. * @param mesh The mesh that this bone is attached to
  24302. * @param result The vector3 that the world direction will be copied to
  24303. */
  24304. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24305. /**
  24306. * Get the euler rotation of the bone in local or world space
  24307. * @param space The space that the rotation should be in
  24308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24309. * @returns The euler rotation
  24310. */
  24311. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24312. /**
  24313. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  24314. * @param space The space that the rotation should be in
  24315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24316. * @param result The vector3 that the rotation should be copied to
  24317. */
  24318. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24319. /**
  24320. * Get the quaternion rotation of the bone in either local or world space
  24321. * @param space The space that the rotation should be in
  24322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24323. * @returns The quaternion rotation
  24324. */
  24325. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  24326. /**
  24327. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  24328. * @param space The space that the rotation should be in
  24329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24330. * @param result The quaternion that the rotation should be copied to
  24331. */
  24332. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  24333. /**
  24334. * Get the rotation matrix of the bone in local or world space
  24335. * @param space The space that the rotation should be in
  24336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24337. * @returns The rotation matrix
  24338. */
  24339. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  24340. /**
  24341. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  24342. * @param space The space that the rotation should be in
  24343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24344. * @param result The quaternion that the rotation should be copied to
  24345. */
  24346. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  24347. /**
  24348. * Get the world position of a point that is in the local space of the bone
  24349. * @param position The local position
  24350. * @param mesh The mesh that this bone is attached to
  24351. * @returns The world position
  24352. */
  24353. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24354. /**
  24355. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  24356. * @param position The local position
  24357. * @param mesh The mesh that this bone is attached to
  24358. * @param result The vector3 that the world position should be copied to
  24359. */
  24360. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24361. /**
  24362. * Get the local position of a point that is in world space
  24363. * @param position The world position
  24364. * @param mesh The mesh that this bone is attached to
  24365. * @returns The local position
  24366. */
  24367. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24368. /**
  24369. * Get the local position of a point that is in world space and copy it to the result param
  24370. * @param position The world position
  24371. * @param mesh The mesh that this bone is attached to
  24372. * @param result The vector3 that the local position should be copied to
  24373. */
  24374. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24375. }
  24376. }
  24377. declare module "babylonjs/Animations/animatable" {
  24378. import { Animation } from "babylonjs/Animations/animation";
  24379. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24380. import { Nullable } from "babylonjs/types";
  24381. import { Observable } from "babylonjs/Misc/observable";
  24382. import { Scene } from "babylonjs/scene";
  24383. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  24384. import { Node } from "babylonjs/node";
  24385. /**
  24386. * Class used to store an actual running animation
  24387. */
  24388. export class Animatable {
  24389. /** defines the target object */
  24390. target: any;
  24391. /** defines the starting frame number (default is 0) */
  24392. fromFrame: number;
  24393. /** defines the ending frame number (default is 100) */
  24394. toFrame: number;
  24395. /** defines if the animation must loop (default is false) */
  24396. loopAnimation: boolean;
  24397. /** defines a callback to call when animation ends if it is not looping */
  24398. onAnimationEnd?: (() => void) | null | undefined;
  24399. /** defines a callback to call when animation loops */
  24400. onAnimationLoop?: (() => void) | null | undefined;
  24401. private _localDelayOffset;
  24402. private _pausedDelay;
  24403. private _runtimeAnimations;
  24404. private _paused;
  24405. private _scene;
  24406. private _speedRatio;
  24407. private _weight;
  24408. private _syncRoot;
  24409. /**
  24410. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24411. * This will only apply for non looping animation (default is true)
  24412. */
  24413. disposeOnEnd: boolean;
  24414. /**
  24415. * Gets a boolean indicating if the animation has started
  24416. */
  24417. animationStarted: boolean;
  24418. /**
  24419. * Observer raised when the animation ends
  24420. */
  24421. onAnimationEndObservable: Observable<Animatable>;
  24422. /**
  24423. * Observer raised when the animation loops
  24424. */
  24425. onAnimationLoopObservable: Observable<Animatable>;
  24426. /**
  24427. * Gets the root Animatable used to synchronize and normalize animations
  24428. */
  24429. readonly syncRoot: Animatable;
  24430. /**
  24431. * Gets the current frame of the first RuntimeAnimation
  24432. * Used to synchronize Animatables
  24433. */
  24434. readonly masterFrame: number;
  24435. /**
  24436. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24437. */
  24438. weight: number;
  24439. /**
  24440. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24441. */
  24442. speedRatio: number;
  24443. /**
  24444. * Creates a new Animatable
  24445. * @param scene defines the hosting scene
  24446. * @param target defines the target object
  24447. * @param fromFrame defines the starting frame number (default is 0)
  24448. * @param toFrame defines the ending frame number (default is 100)
  24449. * @param loopAnimation defines if the animation must loop (default is false)
  24450. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24451. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24452. * @param animations defines a group of animation to add to the new Animatable
  24453. * @param onAnimationLoop defines a callback to call when animation loops
  24454. */
  24455. constructor(scene: Scene,
  24456. /** defines the target object */
  24457. target: any,
  24458. /** defines the starting frame number (default is 0) */
  24459. fromFrame?: number,
  24460. /** defines the ending frame number (default is 100) */
  24461. toFrame?: number,
  24462. /** defines if the animation must loop (default is false) */
  24463. loopAnimation?: boolean, speedRatio?: number,
  24464. /** defines a callback to call when animation ends if it is not looping */
  24465. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24466. /** defines a callback to call when animation loops */
  24467. onAnimationLoop?: (() => void) | null | undefined);
  24468. /**
  24469. * Synchronize and normalize current Animatable with a source Animatable
  24470. * This is useful when using animation weights and when animations are not of the same length
  24471. * @param root defines the root Animatable to synchronize with
  24472. * @returns the current Animatable
  24473. */
  24474. syncWith(root: Animatable): Animatable;
  24475. /**
  24476. * Gets the list of runtime animations
  24477. * @returns an array of RuntimeAnimation
  24478. */
  24479. getAnimations(): RuntimeAnimation[];
  24480. /**
  24481. * Adds more animations to the current animatable
  24482. * @param target defines the target of the animations
  24483. * @param animations defines the new animations to add
  24484. */
  24485. appendAnimations(target: any, animations: Animation[]): void;
  24486. /**
  24487. * Gets the source animation for a specific property
  24488. * @param property defines the propertyu to look for
  24489. * @returns null or the source animation for the given property
  24490. */
  24491. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24492. /**
  24493. * Gets the runtime animation for a specific property
  24494. * @param property defines the propertyu to look for
  24495. * @returns null or the runtime animation for the given property
  24496. */
  24497. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24498. /**
  24499. * Resets the animatable to its original state
  24500. */
  24501. reset(): void;
  24502. /**
  24503. * Allows the animatable to blend with current running animations
  24504. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24505. * @param blendingSpeed defines the blending speed to use
  24506. */
  24507. enableBlending(blendingSpeed: number): void;
  24508. /**
  24509. * Disable animation blending
  24510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24511. */
  24512. disableBlending(): void;
  24513. /**
  24514. * Jump directly to a given frame
  24515. * @param frame defines the frame to jump to
  24516. */
  24517. goToFrame(frame: number): void;
  24518. /**
  24519. * Pause the animation
  24520. */
  24521. pause(): void;
  24522. /**
  24523. * Restart the animation
  24524. */
  24525. restart(): void;
  24526. private _raiseOnAnimationEnd;
  24527. /**
  24528. * Stop and delete the current animation
  24529. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24530. * @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)
  24531. */
  24532. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24533. /**
  24534. * Wait asynchronously for the animation to end
  24535. * @returns a promise which will be fullfilled when the animation ends
  24536. */
  24537. waitAsync(): Promise<Animatable>;
  24538. /** @hidden */
  24539. _animate(delay: number): boolean;
  24540. }
  24541. module "babylonjs/scene" {
  24542. interface Scene {
  24543. /** @hidden */
  24544. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24545. /** @hidden */
  24546. _processLateAnimationBindingsForMatrices(holder: {
  24547. totalWeight: number;
  24548. animations: RuntimeAnimation[];
  24549. originalValue: Matrix;
  24550. }): any;
  24551. /** @hidden */
  24552. _processLateAnimationBindingsForQuaternions(holder: {
  24553. totalWeight: number;
  24554. animations: RuntimeAnimation[];
  24555. originalValue: Quaternion;
  24556. }, refQuaternion: Quaternion): Quaternion;
  24557. /** @hidden */
  24558. _processLateAnimationBindings(): void;
  24559. /**
  24560. * Will start the animation sequence of a given target
  24561. * @param target defines the target
  24562. * @param from defines from which frame should animation start
  24563. * @param to defines until which frame should animation run.
  24564. * @param weight defines the weight to apply to the animation (1.0 by default)
  24565. * @param loop defines if the animation loops
  24566. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24567. * @param onAnimationEnd defines the function to be executed when the animation ends
  24568. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24569. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24570. * @param onAnimationLoop defines the callback to call when an animation loops
  24571. * @returns the animatable object created for this animation
  24572. */
  24573. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24574. /**
  24575. * Will start the animation sequence of a given target
  24576. * @param target defines the target
  24577. * @param from defines from which frame should animation start
  24578. * @param to defines until which frame should animation run.
  24579. * @param loop defines if the animation loops
  24580. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24581. * @param onAnimationEnd defines the function to be executed when the animation ends
  24582. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24583. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24584. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24585. * @param onAnimationLoop defines the callback to call when an animation loops
  24586. * @returns the animatable object created for this animation
  24587. */
  24588. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24589. /**
  24590. * Will start the animation sequence of a given target and its hierarchy
  24591. * @param target defines the target
  24592. * @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.
  24593. * @param from defines from which frame should animation start
  24594. * @param to defines until which frame should animation run.
  24595. * @param loop defines if the animation loops
  24596. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24597. * @param onAnimationEnd defines the function to be executed when the animation ends
  24598. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24599. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24600. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24601. * @param onAnimationLoop defines the callback to call when an animation loops
  24602. * @returns the list of created animatables
  24603. */
  24604. 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[];
  24605. /**
  24606. * Begin a new animation on a given node
  24607. * @param target defines the target where the animation will take place
  24608. * @param animations defines the list of animations to start
  24609. * @param from defines the initial value
  24610. * @param to defines the final value
  24611. * @param loop defines if you want animation to loop (off by default)
  24612. * @param speedRatio defines the speed ratio to apply to all animations
  24613. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24614. * @param onAnimationLoop defines the callback to call when an animation loops
  24615. * @returns the list of created animatables
  24616. */
  24617. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  24618. /**
  24619. * Begin a new animation on a given node and its hierarchy
  24620. * @param target defines the root node where the animation will take place
  24621. * @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.
  24622. * @param animations defines the list of animations to start
  24623. * @param from defines the initial value
  24624. * @param to defines the final value
  24625. * @param loop defines if you want animation to loop (off by default)
  24626. * @param speedRatio defines the speed ratio to apply to all animations
  24627. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24628. * @param onAnimationLoop defines the callback to call when an animation loops
  24629. * @returns the list of animatables created for all nodes
  24630. */
  24631. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24632. /**
  24633. * Gets the animatable associated with a specific target
  24634. * @param target defines the target of the animatable
  24635. * @returns the required animatable if found
  24636. */
  24637. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24638. /**
  24639. * Gets all animatables associated with a given target
  24640. * @param target defines the target to look animatables for
  24641. * @returns an array of Animatables
  24642. */
  24643. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24644. /**
  24645. * Will stop the animation of the given target
  24646. * @param target - the target
  24647. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24648. * @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)
  24649. */
  24650. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24651. /**
  24652. * Stops and removes all animations that have been applied to the scene
  24653. */
  24654. stopAllAnimations(): void;
  24655. }
  24656. }
  24657. module "babylonjs/Bones/bone" {
  24658. interface Bone {
  24659. /**
  24660. * Copy an animation range from another bone
  24661. * @param source defines the source bone
  24662. * @param rangeName defines the range name to copy
  24663. * @param frameOffset defines the frame offset
  24664. * @param rescaleAsRequired defines if rescaling must be applied if required
  24665. * @param skelDimensionsRatio defines the scaling ratio
  24666. * @returns true if operation was successful
  24667. */
  24668. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24669. }
  24670. }
  24671. }
  24672. declare module "babylonjs/node" {
  24673. import { Scene } from "babylonjs/scene";
  24674. import { Nullable } from "babylonjs/types";
  24675. import { Matrix } from "babylonjs/Maths/math";
  24676. import { Engine } from "babylonjs/Engines/engine";
  24677. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24678. import { Observable } from "babylonjs/Misc/observable";
  24679. import { Animatable } from "babylonjs/Animations/animatable";
  24680. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24681. import { Animation } from "babylonjs/Animations/animation";
  24682. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24684. /**
  24685. * Defines how a node can be built from a string name.
  24686. */
  24687. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24688. /**
  24689. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24690. */
  24691. export class Node implements IBehaviorAware<Node> {
  24692. /** @hidden */
  24693. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24694. private static _NodeConstructors;
  24695. /**
  24696. * Add a new node constructor
  24697. * @param type defines the type name of the node to construct
  24698. * @param constructorFunc defines the constructor function
  24699. */
  24700. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24701. /**
  24702. * Returns a node constructor based on type name
  24703. * @param type defines the type name
  24704. * @param name defines the new node name
  24705. * @param scene defines the hosting scene
  24706. * @param options defines optional options to transmit to constructors
  24707. * @returns the new constructor or null
  24708. */
  24709. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24710. /**
  24711. * Gets or sets the name of the node
  24712. */
  24713. name: string;
  24714. /**
  24715. * Gets or sets the id of the node
  24716. */
  24717. id: string;
  24718. /**
  24719. * Gets or sets the unique id of the node
  24720. */
  24721. uniqueId: number;
  24722. /**
  24723. * Gets or sets a string used to store user defined state for the node
  24724. */
  24725. state: string;
  24726. /**
  24727. * Gets or sets an object used to store user defined information for the node
  24728. */
  24729. metadata: any;
  24730. /**
  24731. * For internal use only. Please do not use.
  24732. */
  24733. reservedDataStore: any;
  24734. /**
  24735. * Gets or sets a boolean used to define if the node must be serialized
  24736. */
  24737. doNotSerialize: boolean;
  24738. /** @hidden */
  24739. _isDisposed: boolean;
  24740. /**
  24741. * Gets a list of Animations associated with the node
  24742. */
  24743. animations: import("babylonjs/Animations/animation").Animation[];
  24744. protected _ranges: {
  24745. [name: string]: Nullable<AnimationRange>;
  24746. };
  24747. /**
  24748. * Callback raised when the node is ready to be used
  24749. */
  24750. onReady: (node: Node) => void;
  24751. private _isEnabled;
  24752. private _isParentEnabled;
  24753. private _isReady;
  24754. /** @hidden */
  24755. _currentRenderId: number;
  24756. private _parentRenderId;
  24757. protected _childRenderId: number;
  24758. /** @hidden */
  24759. _waitingParentId: Nullable<string>;
  24760. /** @hidden */
  24761. _scene: Scene;
  24762. /** @hidden */
  24763. _cache: any;
  24764. private _parentNode;
  24765. private _children;
  24766. /** @hidden */
  24767. _worldMatrix: Matrix;
  24768. /** @hidden */
  24769. _worldMatrixDeterminant: number;
  24770. /** @hidden */
  24771. private _sceneRootNodesIndex;
  24772. /**
  24773. * Gets a boolean indicating if the node has been disposed
  24774. * @returns true if the node was disposed
  24775. */
  24776. isDisposed(): boolean;
  24777. /**
  24778. * Gets or sets the parent of the node
  24779. */
  24780. parent: Nullable<Node>;
  24781. private addToSceneRootNodes;
  24782. private removeFromSceneRootNodes;
  24783. private _animationPropertiesOverride;
  24784. /**
  24785. * Gets or sets the animation properties override
  24786. */
  24787. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24788. /**
  24789. * Gets a string idenfifying the name of the class
  24790. * @returns "Node" string
  24791. */
  24792. getClassName(): string;
  24793. /** @hidden */
  24794. readonly _isNode: boolean;
  24795. /**
  24796. * An event triggered when the mesh is disposed
  24797. */
  24798. onDisposeObservable: Observable<Node>;
  24799. private _onDisposeObserver;
  24800. /**
  24801. * Sets a callback that will be raised when the node will be disposed
  24802. */
  24803. onDispose: () => void;
  24804. /**
  24805. * Creates a new Node
  24806. * @param name the name and id to be given to this node
  24807. * @param scene the scene this node will be added to
  24808. * @param addToRootNodes the node will be added to scene.rootNodes
  24809. */
  24810. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24811. /**
  24812. * Gets the scene of the node
  24813. * @returns a scene
  24814. */
  24815. getScene(): Scene;
  24816. /**
  24817. * Gets the engine of the node
  24818. * @returns a Engine
  24819. */
  24820. getEngine(): Engine;
  24821. private _behaviors;
  24822. /**
  24823. * Attach a behavior to the node
  24824. * @see http://doc.babylonjs.com/features/behaviour
  24825. * @param behavior defines the behavior to attach
  24826. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24827. * @returns the current Node
  24828. */
  24829. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24830. /**
  24831. * Remove an attached behavior
  24832. * @see http://doc.babylonjs.com/features/behaviour
  24833. * @param behavior defines the behavior to attach
  24834. * @returns the current Node
  24835. */
  24836. removeBehavior(behavior: Behavior<Node>): Node;
  24837. /**
  24838. * Gets the list of attached behaviors
  24839. * @see http://doc.babylonjs.com/features/behaviour
  24840. */
  24841. readonly behaviors: Behavior<Node>[];
  24842. /**
  24843. * Gets an attached behavior by name
  24844. * @param name defines the name of the behavior to look for
  24845. * @see http://doc.babylonjs.com/features/behaviour
  24846. * @returns null if behavior was not found else the requested behavior
  24847. */
  24848. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24849. /**
  24850. * Returns the latest update of the World matrix
  24851. * @returns a Matrix
  24852. */
  24853. getWorldMatrix(): Matrix;
  24854. /** @hidden */
  24855. _getWorldMatrixDeterminant(): number;
  24856. /**
  24857. * Returns directly the latest state of the mesh World matrix.
  24858. * A Matrix is returned.
  24859. */
  24860. readonly worldMatrixFromCache: Matrix;
  24861. /** @hidden */
  24862. _initCache(): void;
  24863. /** @hidden */
  24864. updateCache(force?: boolean): void;
  24865. /** @hidden */
  24866. _updateCache(ignoreParentClass?: boolean): void;
  24867. /** @hidden */
  24868. _isSynchronized(): boolean;
  24869. /** @hidden */
  24870. _markSyncedWithParent(): void;
  24871. /** @hidden */
  24872. isSynchronizedWithParent(): boolean;
  24873. /** @hidden */
  24874. isSynchronized(): boolean;
  24875. /**
  24876. * Is this node ready to be used/rendered
  24877. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24878. * @return true if the node is ready
  24879. */
  24880. isReady(completeCheck?: boolean): boolean;
  24881. /**
  24882. * Is this node enabled?
  24883. * 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
  24884. * @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
  24885. * @return whether this node (and its parent) is enabled
  24886. */
  24887. isEnabled(checkAncestors?: boolean): boolean;
  24888. /** @hidden */
  24889. protected _syncParentEnabledState(): void;
  24890. /**
  24891. * Set the enabled state of this node
  24892. * @param value defines the new enabled state
  24893. */
  24894. setEnabled(value: boolean): void;
  24895. /**
  24896. * Is this node a descendant of the given node?
  24897. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24898. * @param ancestor defines the parent node to inspect
  24899. * @returns a boolean indicating if this node is a descendant of the given node
  24900. */
  24901. isDescendantOf(ancestor: Node): boolean;
  24902. /** @hidden */
  24903. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24904. /**
  24905. * Will return all nodes that have this node as ascendant
  24906. * @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
  24907. * @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
  24908. * @return all children nodes of all types
  24909. */
  24910. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24911. /**
  24912. * Get all child-meshes of this node
  24913. * @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
  24914. * @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
  24915. * @returns an array of AbstractMesh
  24916. */
  24917. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24918. /**
  24919. * Get all direct children of this node
  24920. * @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
  24921. * @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)
  24922. * @returns an array of Node
  24923. */
  24924. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24925. /** @hidden */
  24926. _setReady(state: boolean): void;
  24927. /**
  24928. * Get an animation by name
  24929. * @param name defines the name of the animation to look for
  24930. * @returns null if not found else the requested animation
  24931. */
  24932. getAnimationByName(name: string): Nullable<Animation>;
  24933. /**
  24934. * Creates an animation range for this node
  24935. * @param name defines the name of the range
  24936. * @param from defines the starting key
  24937. * @param to defines the end key
  24938. */
  24939. createAnimationRange(name: string, from: number, to: number): void;
  24940. /**
  24941. * Delete a specific animation range
  24942. * @param name defines the name of the range to delete
  24943. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24944. */
  24945. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24946. /**
  24947. * Get an animation range by name
  24948. * @param name defines the name of the animation range to look for
  24949. * @returns null if not found else the requested animation range
  24950. */
  24951. getAnimationRange(name: string): Nullable<AnimationRange>;
  24952. /**
  24953. * Will start the animation sequence
  24954. * @param name defines the range frames for animation sequence
  24955. * @param loop defines if the animation should loop (false by default)
  24956. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24957. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24958. * @returns the object created for this animation. If range does not exist, it will return null
  24959. */
  24960. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24961. /**
  24962. * Serialize animation ranges into a JSON compatible object
  24963. * @returns serialization object
  24964. */
  24965. serializeAnimationRanges(): any;
  24966. /**
  24967. * Computes the world matrix of the node
  24968. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24969. * @returns the world matrix
  24970. */
  24971. computeWorldMatrix(force?: boolean): Matrix;
  24972. /**
  24973. * Releases resources associated with this node.
  24974. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24975. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24976. */
  24977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24978. /**
  24979. * Parse animation range data from a serialization object and store them into a given node
  24980. * @param node defines where to store the animation ranges
  24981. * @param parsedNode defines the serialization object to read data from
  24982. * @param scene defines the hosting scene
  24983. */
  24984. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24985. }
  24986. }
  24987. declare module "babylonjs/Animations/animation" {
  24988. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  24989. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  24990. import { Nullable } from "babylonjs/types";
  24991. import { Scene } from "babylonjs/scene";
  24992. import { IAnimatable } from "babylonjs/Misc/tools";
  24993. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  24994. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24995. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  24996. import { Node } from "babylonjs/node";
  24997. import { Animatable } from "babylonjs/Animations/animatable";
  24998. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24999. /**
  25000. * Class used to store any kind of animation
  25001. */
  25002. export class Animation {
  25003. /**Name of the animation */
  25004. name: string;
  25005. /**Property to animate */
  25006. targetProperty: string;
  25007. /**The frames per second of the animation */
  25008. framePerSecond: number;
  25009. /**The data type of the animation */
  25010. dataType: number;
  25011. /**The loop mode of the animation */
  25012. loopMode?: number | undefined;
  25013. /**Specifies if blending should be enabled */
  25014. enableBlending?: boolean | undefined;
  25015. /**
  25016. * Use matrix interpolation instead of using direct key value when animating matrices
  25017. */
  25018. static AllowMatricesInterpolation: boolean;
  25019. /**
  25020. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25021. */
  25022. static AllowMatrixDecomposeForInterpolation: boolean;
  25023. /**
  25024. * Stores the key frames of the animation
  25025. */
  25026. private _keys;
  25027. /**
  25028. * Stores the easing function of the animation
  25029. */
  25030. private _easingFunction;
  25031. /**
  25032. * @hidden Internal use only
  25033. */
  25034. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25035. /**
  25036. * The set of event that will be linked to this animation
  25037. */
  25038. private _events;
  25039. /**
  25040. * Stores an array of target property paths
  25041. */
  25042. targetPropertyPath: string[];
  25043. /**
  25044. * Stores the blending speed of the animation
  25045. */
  25046. blendingSpeed: number;
  25047. /**
  25048. * Stores the animation ranges for the animation
  25049. */
  25050. private _ranges;
  25051. /**
  25052. * @hidden Internal use
  25053. */
  25054. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25055. /**
  25056. * Sets up an animation
  25057. * @param property The property to animate
  25058. * @param animationType The animation type to apply
  25059. * @param framePerSecond The frames per second of the animation
  25060. * @param easingFunction The easing function used in the animation
  25061. * @returns The created animation
  25062. */
  25063. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25064. /**
  25065. * Create and start an animation on a node
  25066. * @param name defines the name of the global animation that will be run on all nodes
  25067. * @param node defines the root node where the animation will take place
  25068. * @param targetProperty defines property to animate
  25069. * @param framePerSecond defines the number of frame per second yo use
  25070. * @param totalFrame defines the number of frames in total
  25071. * @param from defines the initial value
  25072. * @param to defines the final value
  25073. * @param loopMode defines which loop mode you want to use (off by default)
  25074. * @param easingFunction defines the easing function to use (linear by default)
  25075. * @param onAnimationEnd defines the callback to call when animation end
  25076. * @returns the animatable created for this animation
  25077. */
  25078. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25079. /**
  25080. * Create and start an animation on a node and its descendants
  25081. * @param name defines the name of the global animation that will be run on all nodes
  25082. * @param node defines the root node where the animation will take place
  25083. * @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
  25084. * @param targetProperty defines property to animate
  25085. * @param framePerSecond defines the number of frame per second to use
  25086. * @param totalFrame defines the number of frames in total
  25087. * @param from defines the initial value
  25088. * @param to defines the final value
  25089. * @param loopMode defines which loop mode you want to use (off by default)
  25090. * @param easingFunction defines the easing function to use (linear by default)
  25091. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25092. * @returns the list of animatables created for all nodes
  25093. * @example https://www.babylonjs-playground.com/#MH0VLI
  25094. */
  25095. 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[]>;
  25096. /**
  25097. * Creates a new animation, merges it with the existing animations and starts it
  25098. * @param name Name of the animation
  25099. * @param node Node which contains the scene that begins the animations
  25100. * @param targetProperty Specifies which property to animate
  25101. * @param framePerSecond The frames per second of the animation
  25102. * @param totalFrame The total number of frames
  25103. * @param from The frame at the beginning of the animation
  25104. * @param to The frame at the end of the animation
  25105. * @param loopMode Specifies the loop mode of the animation
  25106. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25107. * @param onAnimationEnd Callback to run once the animation is complete
  25108. * @returns Nullable animation
  25109. */
  25110. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25111. /**
  25112. * Transition property of an host to the target Value
  25113. * @param property The property to transition
  25114. * @param targetValue The target Value of the property
  25115. * @param host The object where the property to animate belongs
  25116. * @param scene Scene used to run the animation
  25117. * @param frameRate Framerate (in frame/s) to use
  25118. * @param transition The transition type we want to use
  25119. * @param duration The duration of the animation, in milliseconds
  25120. * @param onAnimationEnd Callback trigger at the end of the animation
  25121. * @returns Nullable animation
  25122. */
  25123. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25124. /**
  25125. * Return the array of runtime animations currently using this animation
  25126. */
  25127. readonly runtimeAnimations: RuntimeAnimation[];
  25128. /**
  25129. * Specifies if any of the runtime animations are currently running
  25130. */
  25131. readonly hasRunningRuntimeAnimations: boolean;
  25132. /**
  25133. * Initializes the animation
  25134. * @param name Name of the animation
  25135. * @param targetProperty Property to animate
  25136. * @param framePerSecond The frames per second of the animation
  25137. * @param dataType The data type of the animation
  25138. * @param loopMode The loop mode of the animation
  25139. * @param enableBlending Specifies if blending should be enabled
  25140. */
  25141. constructor(
  25142. /**Name of the animation */
  25143. name: string,
  25144. /**Property to animate */
  25145. targetProperty: string,
  25146. /**The frames per second of the animation */
  25147. framePerSecond: number,
  25148. /**The data type of the animation */
  25149. dataType: number,
  25150. /**The loop mode of the animation */
  25151. loopMode?: number | undefined,
  25152. /**Specifies if blending should be enabled */
  25153. enableBlending?: boolean | undefined);
  25154. /**
  25155. * Converts the animation to a string
  25156. * @param fullDetails support for multiple levels of logging within scene loading
  25157. * @returns String form of the animation
  25158. */
  25159. toString(fullDetails?: boolean): string;
  25160. /**
  25161. * Add an event to this animation
  25162. * @param event Event to add
  25163. */
  25164. addEvent(event: AnimationEvent): void;
  25165. /**
  25166. * Remove all events found at the given frame
  25167. * @param frame The frame to remove events from
  25168. */
  25169. removeEvents(frame: number): void;
  25170. /**
  25171. * Retrieves all the events from the animation
  25172. * @returns Events from the animation
  25173. */
  25174. getEvents(): AnimationEvent[];
  25175. /**
  25176. * Creates an animation range
  25177. * @param name Name of the animation range
  25178. * @param from Starting frame of the animation range
  25179. * @param to Ending frame of the animation
  25180. */
  25181. createRange(name: string, from: number, to: number): void;
  25182. /**
  25183. * Deletes an animation range by name
  25184. * @param name Name of the animation range to delete
  25185. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25186. */
  25187. deleteRange(name: string, deleteFrames?: boolean): void;
  25188. /**
  25189. * Gets the animation range by name, or null if not defined
  25190. * @param name Name of the animation range
  25191. * @returns Nullable animation range
  25192. */
  25193. getRange(name: string): Nullable<AnimationRange>;
  25194. /**
  25195. * Gets the key frames from the animation
  25196. * @returns The key frames of the animation
  25197. */
  25198. getKeys(): Array<IAnimationKey>;
  25199. /**
  25200. * Gets the highest frame rate of the animation
  25201. * @returns Highest frame rate of the animation
  25202. */
  25203. getHighestFrame(): number;
  25204. /**
  25205. * Gets the easing function of the animation
  25206. * @returns Easing function of the animation
  25207. */
  25208. getEasingFunction(): IEasingFunction;
  25209. /**
  25210. * Sets the easing function of the animation
  25211. * @param easingFunction A custom mathematical formula for animation
  25212. */
  25213. setEasingFunction(easingFunction: EasingFunction): void;
  25214. /**
  25215. * Interpolates a scalar linearly
  25216. * @param startValue Start value of the animation curve
  25217. * @param endValue End value of the animation curve
  25218. * @param gradient Scalar amount to interpolate
  25219. * @returns Interpolated scalar value
  25220. */
  25221. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25222. /**
  25223. * Interpolates a scalar cubically
  25224. * @param startValue Start value of the animation curve
  25225. * @param outTangent End tangent of the animation
  25226. * @param endValue End value of the animation curve
  25227. * @param inTangent Start tangent of the animation curve
  25228. * @param gradient Scalar amount to interpolate
  25229. * @returns Interpolated scalar value
  25230. */
  25231. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25232. /**
  25233. * Interpolates a quaternion using a spherical linear interpolation
  25234. * @param startValue Start value of the animation curve
  25235. * @param endValue End value of the animation curve
  25236. * @param gradient Scalar amount to interpolate
  25237. * @returns Interpolated quaternion value
  25238. */
  25239. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25240. /**
  25241. * Interpolates a quaternion cubically
  25242. * @param startValue Start value of the animation curve
  25243. * @param outTangent End tangent of the animation curve
  25244. * @param endValue End value of the animation curve
  25245. * @param inTangent Start tangent of the animation curve
  25246. * @param gradient Scalar amount to interpolate
  25247. * @returns Interpolated quaternion value
  25248. */
  25249. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25250. /**
  25251. * Interpolates a Vector3 linearl
  25252. * @param startValue Start value of the animation curve
  25253. * @param endValue End value of the animation curve
  25254. * @param gradient Scalar amount to interpolate
  25255. * @returns Interpolated scalar value
  25256. */
  25257. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25258. /**
  25259. * Interpolates a Vector3 cubically
  25260. * @param startValue Start value of the animation curve
  25261. * @param outTangent End tangent of the animation
  25262. * @param endValue End value of the animation curve
  25263. * @param inTangent Start tangent of the animation curve
  25264. * @param gradient Scalar amount to interpolate
  25265. * @returns InterpolatedVector3 value
  25266. */
  25267. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25268. /**
  25269. * Interpolates a Vector2 linearly
  25270. * @param startValue Start value of the animation curve
  25271. * @param endValue End value of the animation curve
  25272. * @param gradient Scalar amount to interpolate
  25273. * @returns Interpolated Vector2 value
  25274. */
  25275. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25276. /**
  25277. * Interpolates a Vector2 cubically
  25278. * @param startValue Start value of the animation curve
  25279. * @param outTangent End tangent of the animation
  25280. * @param endValue End value of the animation curve
  25281. * @param inTangent Start tangent of the animation curve
  25282. * @param gradient Scalar amount to interpolate
  25283. * @returns Interpolated Vector2 value
  25284. */
  25285. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25286. /**
  25287. * Interpolates a size linearly
  25288. * @param startValue Start value of the animation curve
  25289. * @param endValue End value of the animation curve
  25290. * @param gradient Scalar amount to interpolate
  25291. * @returns Interpolated Size value
  25292. */
  25293. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25294. /**
  25295. * Interpolates a Color3 linearly
  25296. * @param startValue Start value of the animation curve
  25297. * @param endValue End value of the animation curve
  25298. * @param gradient Scalar amount to interpolate
  25299. * @returns Interpolated Color3 value
  25300. */
  25301. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25302. /**
  25303. * @hidden Internal use only
  25304. */
  25305. _getKeyValue(value: any): any;
  25306. /**
  25307. * @hidden Internal use only
  25308. */
  25309. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25310. /**
  25311. * Defines the function to use to interpolate matrices
  25312. * @param startValue defines the start matrix
  25313. * @param endValue defines the end matrix
  25314. * @param gradient defines the gradient between both matrices
  25315. * @param result defines an optional target matrix where to store the interpolation
  25316. * @returns the interpolated matrix
  25317. */
  25318. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25319. /**
  25320. * Makes a copy of the animation
  25321. * @returns Cloned animation
  25322. */
  25323. clone(): Animation;
  25324. /**
  25325. * Sets the key frames of the animation
  25326. * @param values The animation key frames to set
  25327. */
  25328. setKeys(values: Array<IAnimationKey>): void;
  25329. /**
  25330. * Serializes the animation to an object
  25331. * @returns Serialized object
  25332. */
  25333. serialize(): any;
  25334. /**
  25335. * Float animation type
  25336. */
  25337. private static _ANIMATIONTYPE_FLOAT;
  25338. /**
  25339. * Vector3 animation type
  25340. */
  25341. private static _ANIMATIONTYPE_VECTOR3;
  25342. /**
  25343. * Quaternion animation type
  25344. */
  25345. private static _ANIMATIONTYPE_QUATERNION;
  25346. /**
  25347. * Matrix animation type
  25348. */
  25349. private static _ANIMATIONTYPE_MATRIX;
  25350. /**
  25351. * Color3 animation type
  25352. */
  25353. private static _ANIMATIONTYPE_COLOR3;
  25354. /**
  25355. * Vector2 animation type
  25356. */
  25357. private static _ANIMATIONTYPE_VECTOR2;
  25358. /**
  25359. * Size animation type
  25360. */
  25361. private static _ANIMATIONTYPE_SIZE;
  25362. /**
  25363. * Relative Loop Mode
  25364. */
  25365. private static _ANIMATIONLOOPMODE_RELATIVE;
  25366. /**
  25367. * Cycle Loop Mode
  25368. */
  25369. private static _ANIMATIONLOOPMODE_CYCLE;
  25370. /**
  25371. * Constant Loop Mode
  25372. */
  25373. private static _ANIMATIONLOOPMODE_CONSTANT;
  25374. /**
  25375. * Get the float animation type
  25376. */
  25377. static readonly ANIMATIONTYPE_FLOAT: number;
  25378. /**
  25379. * Get the Vector3 animation type
  25380. */
  25381. static readonly ANIMATIONTYPE_VECTOR3: number;
  25382. /**
  25383. * Get the Vector2 animation type
  25384. */
  25385. static readonly ANIMATIONTYPE_VECTOR2: number;
  25386. /**
  25387. * Get the Size animation type
  25388. */
  25389. static readonly ANIMATIONTYPE_SIZE: number;
  25390. /**
  25391. * Get the Quaternion animation type
  25392. */
  25393. static readonly ANIMATIONTYPE_QUATERNION: number;
  25394. /**
  25395. * Get the Matrix animation type
  25396. */
  25397. static readonly ANIMATIONTYPE_MATRIX: number;
  25398. /**
  25399. * Get the Color3 animation type
  25400. */
  25401. static readonly ANIMATIONTYPE_COLOR3: number;
  25402. /**
  25403. * Get the Relative Loop Mode
  25404. */
  25405. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25406. /**
  25407. * Get the Cycle Loop Mode
  25408. */
  25409. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25410. /**
  25411. * Get the Constant Loop Mode
  25412. */
  25413. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25414. /** @hidden */
  25415. static _UniversalLerp(left: any, right: any, amount: number): any;
  25416. /**
  25417. * Parses an animation object and creates an animation
  25418. * @param parsedAnimation Parsed animation object
  25419. * @returns Animation object
  25420. */
  25421. static Parse(parsedAnimation: any): Animation;
  25422. /**
  25423. * Appends the serialized animations from the source animations
  25424. * @param source Source containing the animations
  25425. * @param destination Target to store the animations
  25426. */
  25427. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25428. }
  25429. }
  25430. declare module "babylonjs/Materials/Textures/baseTexture" {
  25431. import { Observable } from "babylonjs/Misc/observable";
  25432. import { IAnimatable } from "babylonjs/Misc/tools";
  25433. import { Nullable } from "babylonjs/types";
  25434. import { Scene } from "babylonjs/scene";
  25435. import { Matrix, ISize } from "babylonjs/Maths/math";
  25436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25437. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25438. /**
  25439. * Base class of all the textures in babylon.
  25440. * It groups all the common properties the materials, post process, lights... might need
  25441. * in order to make a correct use of the texture.
  25442. */
  25443. export class BaseTexture implements IAnimatable {
  25444. /**
  25445. * Default anisotropic filtering level for the application.
  25446. * It is set to 4 as a good tradeoff between perf and quality.
  25447. */
  25448. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25449. /**
  25450. * Gets or sets the unique id of the texture
  25451. */
  25452. uniqueId: number;
  25453. /**
  25454. * Define the name of the texture.
  25455. */
  25456. name: string;
  25457. /**
  25458. * Gets or sets an object used to store user defined information.
  25459. */
  25460. metadata: any;
  25461. /**
  25462. * For internal use only. Please do not use.
  25463. */
  25464. reservedDataStore: any;
  25465. private _hasAlpha;
  25466. /**
  25467. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25468. */
  25469. hasAlpha: boolean;
  25470. /**
  25471. * Defines if the alpha value should be determined via the rgb values.
  25472. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25473. */
  25474. getAlphaFromRGB: boolean;
  25475. /**
  25476. * Intensity or strength of the texture.
  25477. * It is commonly used by materials to fine tune the intensity of the texture
  25478. */
  25479. level: number;
  25480. /**
  25481. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25482. * This is part of the texture as textures usually maps to one uv set.
  25483. */
  25484. coordinatesIndex: number;
  25485. private _coordinatesMode;
  25486. /**
  25487. * How a texture is mapped.
  25488. *
  25489. * | Value | Type | Description |
  25490. * | ----- | ----------------------------------- | ----------- |
  25491. * | 0 | EXPLICIT_MODE | |
  25492. * | 1 | SPHERICAL_MODE | |
  25493. * | 2 | PLANAR_MODE | |
  25494. * | 3 | CUBIC_MODE | |
  25495. * | 4 | PROJECTION_MODE | |
  25496. * | 5 | SKYBOX_MODE | |
  25497. * | 6 | INVCUBIC_MODE | |
  25498. * | 7 | EQUIRECTANGULAR_MODE | |
  25499. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25500. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25501. */
  25502. coordinatesMode: number;
  25503. /**
  25504. * | Value | Type | Description |
  25505. * | ----- | ------------------ | ----------- |
  25506. * | 0 | CLAMP_ADDRESSMODE | |
  25507. * | 1 | WRAP_ADDRESSMODE | |
  25508. * | 2 | MIRROR_ADDRESSMODE | |
  25509. */
  25510. wrapU: number;
  25511. /**
  25512. * | Value | Type | Description |
  25513. * | ----- | ------------------ | ----------- |
  25514. * | 0 | CLAMP_ADDRESSMODE | |
  25515. * | 1 | WRAP_ADDRESSMODE | |
  25516. * | 2 | MIRROR_ADDRESSMODE | |
  25517. */
  25518. wrapV: number;
  25519. /**
  25520. * | Value | Type | Description |
  25521. * | ----- | ------------------ | ----------- |
  25522. * | 0 | CLAMP_ADDRESSMODE | |
  25523. * | 1 | WRAP_ADDRESSMODE | |
  25524. * | 2 | MIRROR_ADDRESSMODE | |
  25525. */
  25526. wrapR: number;
  25527. /**
  25528. * With compliant hardware and browser (supporting anisotropic filtering)
  25529. * this defines the level of anisotropic filtering in the texture.
  25530. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25531. */
  25532. anisotropicFilteringLevel: number;
  25533. /**
  25534. * Define if the texture is a cube texture or if false a 2d texture.
  25535. */
  25536. isCube: boolean;
  25537. /**
  25538. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25539. */
  25540. is3D: boolean;
  25541. /**
  25542. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25543. * HDR texture are usually stored in linear space.
  25544. * This only impacts the PBR and Background materials
  25545. */
  25546. gammaSpace: boolean;
  25547. /**
  25548. * Gets whether or not the texture contains RGBD data.
  25549. */
  25550. readonly isRGBD: boolean;
  25551. /**
  25552. * Is Z inverted in the texture (useful in a cube texture).
  25553. */
  25554. invertZ: boolean;
  25555. /**
  25556. * Are mip maps generated for this texture or not.
  25557. */
  25558. readonly noMipmap: boolean;
  25559. /**
  25560. * @hidden
  25561. */
  25562. lodLevelInAlpha: boolean;
  25563. /**
  25564. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25565. */
  25566. lodGenerationOffset: number;
  25567. /**
  25568. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25569. */
  25570. lodGenerationScale: number;
  25571. /**
  25572. * Define if the texture is a render target.
  25573. */
  25574. isRenderTarget: boolean;
  25575. /**
  25576. * Define the unique id of the texture in the scene.
  25577. */
  25578. readonly uid: string;
  25579. /**
  25580. * Return a string representation of the texture.
  25581. * @returns the texture as a string
  25582. */
  25583. toString(): string;
  25584. /**
  25585. * Get the class name of the texture.
  25586. * @returns "BaseTexture"
  25587. */
  25588. getClassName(): string;
  25589. /**
  25590. * Define the list of animation attached to the texture.
  25591. */
  25592. animations: import("babylonjs/Animations/animation").Animation[];
  25593. /**
  25594. * An event triggered when the texture is disposed.
  25595. */
  25596. onDisposeObservable: Observable<BaseTexture>;
  25597. private _onDisposeObserver;
  25598. /**
  25599. * Callback triggered when the texture has been disposed.
  25600. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25601. */
  25602. onDispose: () => void;
  25603. /**
  25604. * Define the current state of the loading sequence when in delayed load mode.
  25605. */
  25606. delayLoadState: number;
  25607. private _scene;
  25608. /** @hidden */
  25609. _texture: Nullable<InternalTexture>;
  25610. private _uid;
  25611. /**
  25612. * Define if the texture is preventinga material to render or not.
  25613. * If not and the texture is not ready, the engine will use a default black texture instead.
  25614. */
  25615. readonly isBlocking: boolean;
  25616. /**
  25617. * Instantiates a new BaseTexture.
  25618. * Base class of all the textures in babylon.
  25619. * It groups all the common properties the materials, post process, lights... might need
  25620. * in order to make a correct use of the texture.
  25621. * @param scene Define the scene the texture blongs to
  25622. */
  25623. constructor(scene: Nullable<Scene>);
  25624. /**
  25625. * Get the scene the texture belongs to.
  25626. * @returns the scene or null if undefined
  25627. */
  25628. getScene(): Nullable<Scene>;
  25629. /**
  25630. * Get the texture transform matrix used to offset tile the texture for istance.
  25631. * @returns the transformation matrix
  25632. */
  25633. getTextureMatrix(): Matrix;
  25634. /**
  25635. * Get the texture reflection matrix used to rotate/transform the reflection.
  25636. * @returns the reflection matrix
  25637. */
  25638. getReflectionTextureMatrix(): Matrix;
  25639. /**
  25640. * Get the underlying lower level texture from Babylon.
  25641. * @returns the insternal texture
  25642. */
  25643. getInternalTexture(): Nullable<InternalTexture>;
  25644. /**
  25645. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25646. * @returns true if ready or not blocking
  25647. */
  25648. isReadyOrNotBlocking(): boolean;
  25649. /**
  25650. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25651. * @returns true if fully ready
  25652. */
  25653. isReady(): boolean;
  25654. private _cachedSize;
  25655. /**
  25656. * Get the size of the texture.
  25657. * @returns the texture size.
  25658. */
  25659. getSize(): ISize;
  25660. /**
  25661. * Get the base size of the texture.
  25662. * It can be different from the size if the texture has been resized for POT for instance
  25663. * @returns the base size
  25664. */
  25665. getBaseSize(): ISize;
  25666. /**
  25667. * Update the sampling mode of the texture.
  25668. * Default is Trilinear mode.
  25669. *
  25670. * | Value | Type | Description |
  25671. * | ----- | ------------------ | ----------- |
  25672. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25673. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25674. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25675. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25676. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25677. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25678. * | 7 | NEAREST_LINEAR | |
  25679. * | 8 | NEAREST_NEAREST | |
  25680. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25681. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25682. * | 11 | LINEAR_LINEAR | |
  25683. * | 12 | LINEAR_NEAREST | |
  25684. *
  25685. * > _mag_: magnification filter (close to the viewer)
  25686. * > _min_: minification filter (far from the viewer)
  25687. * > _mip_: filter used between mip map levels
  25688. *@param samplingMode Define the new sampling mode of the texture
  25689. */
  25690. updateSamplingMode(samplingMode: number): void;
  25691. /**
  25692. * Scales the texture if is `canRescale()`
  25693. * @param ratio the resize factor we want to use to rescale
  25694. */
  25695. scale(ratio: number): void;
  25696. /**
  25697. * Get if the texture can rescale.
  25698. */
  25699. readonly canRescale: boolean;
  25700. /** @hidden */
  25701. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25702. /** @hidden */
  25703. _rebuild(): void;
  25704. /**
  25705. * Triggers the load sequence in delayed load mode.
  25706. */
  25707. delayLoad(): void;
  25708. /**
  25709. * Clones the texture.
  25710. * @returns the cloned texture
  25711. */
  25712. clone(): Nullable<BaseTexture>;
  25713. /**
  25714. * Get the texture underlying type (INT, FLOAT...)
  25715. */
  25716. readonly textureType: number;
  25717. /**
  25718. * Get the texture underlying format (RGB, RGBA...)
  25719. */
  25720. readonly textureFormat: number;
  25721. /**
  25722. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25723. * This will returns an RGBA array buffer containing either in values (0-255) or
  25724. * float values (0-1) depending of the underlying buffer type.
  25725. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25726. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25727. * @param buffer defines a user defined buffer to fill with data (can be null)
  25728. * @returns The Array buffer containing the pixels data.
  25729. */
  25730. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25731. /**
  25732. * Release and destroy the underlying lower level texture aka internalTexture.
  25733. */
  25734. releaseInternalTexture(): void;
  25735. /**
  25736. * Get the polynomial representation of the texture data.
  25737. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25738. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25739. */
  25740. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25741. /** @hidden */
  25742. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25743. /** @hidden */
  25744. readonly _lodTextureMid: Nullable<BaseTexture>;
  25745. /** @hidden */
  25746. readonly _lodTextureLow: Nullable<BaseTexture>;
  25747. /**
  25748. * Dispose the texture and release its associated resources.
  25749. */
  25750. dispose(): void;
  25751. /**
  25752. * Serialize the texture into a JSON representation that can be parsed later on.
  25753. * @returns the JSON representation of the texture
  25754. */
  25755. serialize(): any;
  25756. /**
  25757. * Helper function to be called back once a list of texture contains only ready textures.
  25758. * @param textures Define the list of textures to wait for
  25759. * @param callback Define the callback triggered once the entire list will be ready
  25760. */
  25761. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25762. }
  25763. }
  25764. declare module "babylonjs/Materials/uniformBuffer" {
  25765. import { Nullable, FloatArray } from "babylonjs/types";
  25766. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25767. import { Engine } from "babylonjs/Engines/engine";
  25768. import { Effect } from "babylonjs/Materials/effect";
  25769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25770. /**
  25771. * Uniform buffer objects.
  25772. *
  25773. * Handles blocks of uniform on the GPU.
  25774. *
  25775. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25776. *
  25777. * For more information, please refer to :
  25778. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25779. */
  25780. export class UniformBuffer {
  25781. private _engine;
  25782. private _buffer;
  25783. private _data;
  25784. private _bufferData;
  25785. private _dynamic?;
  25786. private _uniformLocations;
  25787. private _uniformSizes;
  25788. private _uniformLocationPointer;
  25789. private _needSync;
  25790. private _noUBO;
  25791. private _currentEffect;
  25792. private static _MAX_UNIFORM_SIZE;
  25793. private static _tempBuffer;
  25794. /**
  25795. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25796. * This is dynamic to allow compat with webgl 1 and 2.
  25797. * You will need to pass the name of the uniform as well as the value.
  25798. */
  25799. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25800. /**
  25801. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25802. * This is dynamic to allow compat with webgl 1 and 2.
  25803. * You will need to pass the name of the uniform as well as the value.
  25804. */
  25805. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25806. /**
  25807. * Lambda to Update a single float in a uniform buffer.
  25808. * This is dynamic to allow compat with webgl 1 and 2.
  25809. * You will need to pass the name of the uniform as well as the value.
  25810. */
  25811. updateFloat: (name: string, x: number) => void;
  25812. /**
  25813. * Lambda to Update a vec2 of float in a uniform buffer.
  25814. * This is dynamic to allow compat with webgl 1 and 2.
  25815. * You will need to pass the name of the uniform as well as the value.
  25816. */
  25817. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25818. /**
  25819. * Lambda to Update a vec3 of float in a uniform buffer.
  25820. * This is dynamic to allow compat with webgl 1 and 2.
  25821. * You will need to pass the name of the uniform as well as the value.
  25822. */
  25823. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25824. /**
  25825. * Lambda to Update a vec4 of float in a uniform buffer.
  25826. * This is dynamic to allow compat with webgl 1 and 2.
  25827. * You will need to pass the name of the uniform as well as the value.
  25828. */
  25829. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25830. /**
  25831. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25832. * This is dynamic to allow compat with webgl 1 and 2.
  25833. * You will need to pass the name of the uniform as well as the value.
  25834. */
  25835. updateMatrix: (name: string, mat: Matrix) => void;
  25836. /**
  25837. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25838. * This is dynamic to allow compat with webgl 1 and 2.
  25839. * You will need to pass the name of the uniform as well as the value.
  25840. */
  25841. updateVector3: (name: string, vector: Vector3) => void;
  25842. /**
  25843. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25844. * This is dynamic to allow compat with webgl 1 and 2.
  25845. * You will need to pass the name of the uniform as well as the value.
  25846. */
  25847. updateVector4: (name: string, vector: Vector4) => void;
  25848. /**
  25849. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25850. * This is dynamic to allow compat with webgl 1 and 2.
  25851. * You will need to pass the name of the uniform as well as the value.
  25852. */
  25853. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25854. /**
  25855. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25856. * This is dynamic to allow compat with webgl 1 and 2.
  25857. * You will need to pass the name of the uniform as well as the value.
  25858. */
  25859. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25860. /**
  25861. * Instantiates a new Uniform buffer objects.
  25862. *
  25863. * Handles blocks of uniform on the GPU.
  25864. *
  25865. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25866. *
  25867. * For more information, please refer to :
  25868. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25869. * @param engine Define the engine the buffer is associated with
  25870. * @param data Define the data contained in the buffer
  25871. * @param dynamic Define if the buffer is updatable
  25872. */
  25873. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25874. /**
  25875. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25876. * or just falling back on setUniformXXX calls.
  25877. */
  25878. readonly useUbo: boolean;
  25879. /**
  25880. * Indicates if the WebGL underlying uniform buffer is in sync
  25881. * with the javascript cache data.
  25882. */
  25883. readonly isSync: boolean;
  25884. /**
  25885. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25886. * Also, a dynamic UniformBuffer will disable cache verification and always
  25887. * update the underlying WebGL uniform buffer to the GPU.
  25888. * @returns if Dynamic, otherwise false
  25889. */
  25890. isDynamic(): boolean;
  25891. /**
  25892. * The data cache on JS side.
  25893. * @returns the underlying data as a float array
  25894. */
  25895. getData(): Float32Array;
  25896. /**
  25897. * The underlying WebGL Uniform buffer.
  25898. * @returns the webgl buffer
  25899. */
  25900. getBuffer(): Nullable<WebGLBuffer>;
  25901. /**
  25902. * std140 layout specifies how to align data within an UBO structure.
  25903. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25904. * for specs.
  25905. */
  25906. private _fillAlignment;
  25907. /**
  25908. * Adds an uniform in the buffer.
  25909. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25910. * for the layout to be correct !
  25911. * @param name Name of the uniform, as used in the uniform block in the shader.
  25912. * @param size Data size, or data directly.
  25913. */
  25914. addUniform(name: string, size: number | number[]): void;
  25915. /**
  25916. * Adds a Matrix 4x4 to the uniform buffer.
  25917. * @param name Name of the uniform, as used in the uniform block in the shader.
  25918. * @param mat A 4x4 matrix.
  25919. */
  25920. addMatrix(name: string, mat: Matrix): void;
  25921. /**
  25922. * Adds a vec2 to the uniform buffer.
  25923. * @param name Name of the uniform, as used in the uniform block in the shader.
  25924. * @param x Define the x component value of the vec2
  25925. * @param y Define the y component value of the vec2
  25926. */
  25927. addFloat2(name: string, x: number, y: number): void;
  25928. /**
  25929. * Adds a vec3 to the uniform buffer.
  25930. * @param name Name of the uniform, as used in the uniform block in the shader.
  25931. * @param x Define the x component value of the vec3
  25932. * @param y Define the y component value of the vec3
  25933. * @param z Define the z component value of the vec3
  25934. */
  25935. addFloat3(name: string, x: number, y: number, z: number): void;
  25936. /**
  25937. * Adds a vec3 to the uniform buffer.
  25938. * @param name Name of the uniform, as used in the uniform block in the shader.
  25939. * @param color Define the vec3 from a Color
  25940. */
  25941. addColor3(name: string, color: Color3): void;
  25942. /**
  25943. * Adds a vec4 to the uniform buffer.
  25944. * @param name Name of the uniform, as used in the uniform block in the shader.
  25945. * @param color Define the rgb components from a Color
  25946. * @param alpha Define the a component of the vec4
  25947. */
  25948. addColor4(name: string, color: Color3, alpha: number): void;
  25949. /**
  25950. * Adds a vec3 to the uniform buffer.
  25951. * @param name Name of the uniform, as used in the uniform block in the shader.
  25952. * @param vector Define the vec3 components from a Vector
  25953. */
  25954. addVector3(name: string, vector: Vector3): void;
  25955. /**
  25956. * Adds a Matrix 3x3 to the uniform buffer.
  25957. * @param name Name of the uniform, as used in the uniform block in the shader.
  25958. */
  25959. addMatrix3x3(name: string): void;
  25960. /**
  25961. * Adds a Matrix 2x2 to the uniform buffer.
  25962. * @param name Name of the uniform, as used in the uniform block in the shader.
  25963. */
  25964. addMatrix2x2(name: string): void;
  25965. /**
  25966. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25967. */
  25968. create(): void;
  25969. /** @hidden */
  25970. _rebuild(): void;
  25971. /**
  25972. * Updates the WebGL Uniform Buffer on the GPU.
  25973. * If the `dynamic` flag is set to true, no cache comparison is done.
  25974. * Otherwise, the buffer will be updated only if the cache differs.
  25975. */
  25976. update(): void;
  25977. /**
  25978. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25979. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25980. * @param data Define the flattened data
  25981. * @param size Define the size of the data.
  25982. */
  25983. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25984. private _updateMatrix3x3ForUniform;
  25985. private _updateMatrix3x3ForEffect;
  25986. private _updateMatrix2x2ForEffect;
  25987. private _updateMatrix2x2ForUniform;
  25988. private _updateFloatForEffect;
  25989. private _updateFloatForUniform;
  25990. private _updateFloat2ForEffect;
  25991. private _updateFloat2ForUniform;
  25992. private _updateFloat3ForEffect;
  25993. private _updateFloat3ForUniform;
  25994. private _updateFloat4ForEffect;
  25995. private _updateFloat4ForUniform;
  25996. private _updateMatrixForEffect;
  25997. private _updateMatrixForUniform;
  25998. private _updateVector3ForEffect;
  25999. private _updateVector3ForUniform;
  26000. private _updateVector4ForEffect;
  26001. private _updateVector4ForUniform;
  26002. private _updateColor3ForEffect;
  26003. private _updateColor3ForUniform;
  26004. private _updateColor4ForEffect;
  26005. private _updateColor4ForUniform;
  26006. /**
  26007. * Sets a sampler uniform on the effect.
  26008. * @param name Define the name of the sampler.
  26009. * @param texture Define the texture to set in the sampler
  26010. */
  26011. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26012. /**
  26013. * Directly updates the value of the uniform in the cache AND on the GPU.
  26014. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26015. * @param data Define the flattened data
  26016. */
  26017. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26018. /**
  26019. * Binds this uniform buffer to an effect.
  26020. * @param effect Define the effect to bind the buffer to
  26021. * @param name Name of the uniform block in the shader.
  26022. */
  26023. bindToEffect(effect: Effect, name: string): void;
  26024. /**
  26025. * Disposes the uniform buffer.
  26026. */
  26027. dispose(): void;
  26028. }
  26029. }
  26030. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26031. import { Nullable } from "babylonjs/types";
  26032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26033. /**
  26034. * This represents the required contract to create a new type of texture loader.
  26035. */
  26036. export interface IInternalTextureLoader {
  26037. /**
  26038. * Defines wether the loader supports cascade loading the different faces.
  26039. */
  26040. supportCascades: boolean;
  26041. /**
  26042. * This returns if the loader support the current file information.
  26043. * @param extension defines the file extension of the file being loaded
  26044. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26045. * @param fallback defines the fallback internal texture if any
  26046. * @param isBase64 defines whether the texture is encoded as a base64
  26047. * @param isBuffer defines whether the texture data are stored as a buffer
  26048. * @returns true if the loader can load the specified file
  26049. */
  26050. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26051. /**
  26052. * Transform the url before loading if required.
  26053. * @param rootUrl the url of the texture
  26054. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26055. * @returns the transformed texture
  26056. */
  26057. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26058. /**
  26059. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26060. * @param rootUrl the url of the texture
  26061. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26062. * @returns the fallback texture
  26063. */
  26064. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26065. /**
  26066. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26067. * @param data contains the texture data
  26068. * @param texture defines the BabylonJS internal texture
  26069. * @param createPolynomials will be true if polynomials have been requested
  26070. * @param onLoad defines the callback to trigger once the texture is ready
  26071. * @param onError defines the callback to trigger in case of error
  26072. */
  26073. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26074. /**
  26075. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26076. * @param data contains the texture data
  26077. * @param texture defines the BabylonJS internal texture
  26078. * @param callback defines the method to call once ready to upload
  26079. */
  26080. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26081. }
  26082. }
  26083. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26084. import { Scene } from "babylonjs/scene";
  26085. import { Engine } from "babylonjs/Engines/engine";
  26086. import { Texture } from "babylonjs/Materials/Textures/texture";
  26087. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26088. /**
  26089. * Creation options of the multi render target texture.
  26090. */
  26091. export interface IMultiRenderTargetOptions {
  26092. /**
  26093. * Define if the texture needs to create mip maps after render.
  26094. */
  26095. generateMipMaps?: boolean;
  26096. /**
  26097. * Define the types of all the draw buffers we want to create
  26098. */
  26099. types?: number[];
  26100. /**
  26101. * Define the sampling modes of all the draw buffers we want to create
  26102. */
  26103. samplingModes?: number[];
  26104. /**
  26105. * Define if a depth buffer is required
  26106. */
  26107. generateDepthBuffer?: boolean;
  26108. /**
  26109. * Define if a stencil buffer is required
  26110. */
  26111. generateStencilBuffer?: boolean;
  26112. /**
  26113. * Define if a depth texture is required instead of a depth buffer
  26114. */
  26115. generateDepthTexture?: boolean;
  26116. /**
  26117. * Define the number of desired draw buffers
  26118. */
  26119. textureCount?: number;
  26120. /**
  26121. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26122. */
  26123. doNotChangeAspectRatio?: boolean;
  26124. /**
  26125. * Define the default type of the buffers we are creating
  26126. */
  26127. defaultType?: number;
  26128. }
  26129. /**
  26130. * A multi render target, like a render target provides the ability to render to a texture.
  26131. * Unlike the render target, it can render to several draw buffers in one draw.
  26132. * This is specially interesting in deferred rendering or for any effects requiring more than
  26133. * just one color from a single pass.
  26134. */
  26135. export class MultiRenderTarget extends RenderTargetTexture {
  26136. private _internalTextures;
  26137. private _textures;
  26138. private _multiRenderTargetOptions;
  26139. /**
  26140. * Get if draw buffers are currently supported by the used hardware and browser.
  26141. */
  26142. readonly isSupported: boolean;
  26143. /**
  26144. * Get the list of textures generated by the multi render target.
  26145. */
  26146. readonly textures: Texture[];
  26147. /**
  26148. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26149. */
  26150. readonly depthTexture: Texture;
  26151. /**
  26152. * Set the wrapping mode on U of all the textures we are rendering to.
  26153. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26154. */
  26155. wrapU: number;
  26156. /**
  26157. * Set the wrapping mode on V of all the textures we are rendering to.
  26158. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26159. */
  26160. wrapV: number;
  26161. /**
  26162. * Instantiate a new multi render target texture.
  26163. * A multi render target, like a render target provides the ability to render to a texture.
  26164. * Unlike the render target, it can render to several draw buffers in one draw.
  26165. * This is specially interesting in deferred rendering or for any effects requiring more than
  26166. * just one color from a single pass.
  26167. * @param name Define the name of the texture
  26168. * @param size Define the size of the buffers to render to
  26169. * @param count Define the number of target we are rendering into
  26170. * @param scene Define the scene the texture belongs to
  26171. * @param options Define the options used to create the multi render target
  26172. */
  26173. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26174. /** @hidden */
  26175. _rebuild(): void;
  26176. private _createInternalTextures;
  26177. private _createTextures;
  26178. /**
  26179. * Define the number of samples used if MSAA is enabled.
  26180. */
  26181. samples: number;
  26182. /**
  26183. * Resize all the textures in the multi render target.
  26184. * Be carrefull as it will recreate all the data in the new texture.
  26185. * @param size Define the new size
  26186. */
  26187. resize(size: any): void;
  26188. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26189. /**
  26190. * Dispose the render targets and their associated resources
  26191. */
  26192. dispose(): void;
  26193. /**
  26194. * Release all the underlying texture used as draw buffers.
  26195. */
  26196. releaseInternalTextures(): void;
  26197. }
  26198. }
  26199. declare module "babylonjs/Audio/analyser" {
  26200. import { Scene } from "babylonjs/scene";
  26201. /**
  26202. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26204. */
  26205. export class Analyser {
  26206. /**
  26207. * Gets or sets the smoothing
  26208. * @ignorenaming
  26209. */
  26210. SMOOTHING: number;
  26211. /**
  26212. * Gets or sets the FFT table size
  26213. * @ignorenaming
  26214. */
  26215. FFT_SIZE: number;
  26216. /**
  26217. * Gets or sets the bar graph amplitude
  26218. * @ignorenaming
  26219. */
  26220. BARGRAPHAMPLITUDE: number;
  26221. /**
  26222. * Gets or sets the position of the debug canvas
  26223. * @ignorenaming
  26224. */
  26225. DEBUGCANVASPOS: {
  26226. x: number;
  26227. y: number;
  26228. };
  26229. /**
  26230. * Gets or sets the debug canvas size
  26231. * @ignorenaming
  26232. */
  26233. DEBUGCANVASSIZE: {
  26234. width: number;
  26235. height: number;
  26236. };
  26237. private _byteFreqs;
  26238. private _byteTime;
  26239. private _floatFreqs;
  26240. private _webAudioAnalyser;
  26241. private _debugCanvas;
  26242. private _debugCanvasContext;
  26243. private _scene;
  26244. private _registerFunc;
  26245. private _audioEngine;
  26246. /**
  26247. * Creates a new analyser
  26248. * @param scene defines hosting scene
  26249. */
  26250. constructor(scene: Scene);
  26251. /**
  26252. * Get the number of data values you will have to play with for the visualization
  26253. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26254. * @returns a number
  26255. */
  26256. getFrequencyBinCount(): number;
  26257. /**
  26258. * Gets the current frequency data as a byte array
  26259. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26260. * @returns a Uint8Array
  26261. */
  26262. getByteFrequencyData(): Uint8Array;
  26263. /**
  26264. * Gets the current waveform as a byte array
  26265. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26266. * @returns a Uint8Array
  26267. */
  26268. getByteTimeDomainData(): Uint8Array;
  26269. /**
  26270. * Gets the current frequency data as a float array
  26271. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26272. * @returns a Float32Array
  26273. */
  26274. getFloatFrequencyData(): Float32Array;
  26275. /**
  26276. * Renders the debug canvas
  26277. */
  26278. drawDebugCanvas(): void;
  26279. /**
  26280. * Stops rendering the debug canvas and removes it
  26281. */
  26282. stopDebugCanvas(): void;
  26283. /**
  26284. * Connects two audio nodes
  26285. * @param inputAudioNode defines first node to connect
  26286. * @param outputAudioNode defines second node to connect
  26287. */
  26288. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26289. /**
  26290. * Releases all associated resources
  26291. */
  26292. dispose(): void;
  26293. }
  26294. }
  26295. declare module "babylonjs/Audio/audioEngine" {
  26296. import { IDisposable } from "babylonjs/scene";
  26297. import { Analyser } from "babylonjs/Audio/analyser";
  26298. import { Nullable } from "babylonjs/types";
  26299. import { Observable } from "babylonjs/Misc/observable";
  26300. /**
  26301. * This represents an audio engine and it is responsible
  26302. * to play, synchronize and analyse sounds throughout the application.
  26303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26304. */
  26305. export interface IAudioEngine extends IDisposable {
  26306. /**
  26307. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26308. */
  26309. readonly canUseWebAudio: boolean;
  26310. /**
  26311. * Gets the current AudioContext if available.
  26312. */
  26313. readonly audioContext: Nullable<AudioContext>;
  26314. /**
  26315. * The master gain node defines the global audio volume of your audio engine.
  26316. */
  26317. readonly masterGain: GainNode;
  26318. /**
  26319. * Gets whether or not mp3 are supported by your browser.
  26320. */
  26321. readonly isMP3supported: boolean;
  26322. /**
  26323. * Gets whether or not ogg are supported by your browser.
  26324. */
  26325. readonly isOGGsupported: boolean;
  26326. /**
  26327. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26328. * @ignoreNaming
  26329. */
  26330. WarnedWebAudioUnsupported: boolean;
  26331. /**
  26332. * Defines if the audio engine relies on a custom unlocked button.
  26333. * In this case, the embedded button will not be displayed.
  26334. */
  26335. useCustomUnlockedButton: boolean;
  26336. /**
  26337. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26338. */
  26339. readonly unlocked: boolean;
  26340. /**
  26341. * Event raised when audio has been unlocked on the browser.
  26342. */
  26343. onAudioUnlockedObservable: Observable<AudioEngine>;
  26344. /**
  26345. * Event raised when audio has been locked on the browser.
  26346. */
  26347. onAudioLockedObservable: Observable<AudioEngine>;
  26348. /**
  26349. * Flags the audio engine in Locked state.
  26350. * This happens due to new browser policies preventing audio to autoplay.
  26351. */
  26352. lock(): void;
  26353. /**
  26354. * Unlocks the audio engine once a user action has been done on the dom.
  26355. * This is helpful to resume play once browser policies have been satisfied.
  26356. */
  26357. unlock(): void;
  26358. }
  26359. /**
  26360. * This represents the default audio engine used in babylon.
  26361. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26363. */
  26364. export class AudioEngine implements IAudioEngine {
  26365. private _audioContext;
  26366. private _audioContextInitialized;
  26367. private _muteButton;
  26368. private _hostElement;
  26369. /**
  26370. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26371. */
  26372. canUseWebAudio: boolean;
  26373. /**
  26374. * The master gain node defines the global audio volume of your audio engine.
  26375. */
  26376. masterGain: GainNode;
  26377. /**
  26378. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26379. * @ignoreNaming
  26380. */
  26381. WarnedWebAudioUnsupported: boolean;
  26382. /**
  26383. * Gets whether or not mp3 are supported by your browser.
  26384. */
  26385. isMP3supported: boolean;
  26386. /**
  26387. * Gets whether or not ogg are supported by your browser.
  26388. */
  26389. isOGGsupported: boolean;
  26390. /**
  26391. * Gets whether audio has been unlocked on the device.
  26392. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26393. * a user interaction has happened.
  26394. */
  26395. unlocked: boolean;
  26396. /**
  26397. * Defines if the audio engine relies on a custom unlocked button.
  26398. * In this case, the embedded button will not be displayed.
  26399. */
  26400. useCustomUnlockedButton: boolean;
  26401. /**
  26402. * Event raised when audio has been unlocked on the browser.
  26403. */
  26404. onAudioUnlockedObservable: Observable<AudioEngine>;
  26405. /**
  26406. * Event raised when audio has been locked on the browser.
  26407. */
  26408. onAudioLockedObservable: Observable<AudioEngine>;
  26409. /**
  26410. * Gets the current AudioContext if available.
  26411. */
  26412. readonly audioContext: Nullable<AudioContext>;
  26413. private _connectedAnalyser;
  26414. /**
  26415. * Instantiates a new audio engine.
  26416. *
  26417. * There should be only one per page as some browsers restrict the number
  26418. * of audio contexts you can create.
  26419. * @param hostElement defines the host element where to display the mute icon if necessary
  26420. */
  26421. constructor(hostElement?: Nullable<HTMLElement>);
  26422. /**
  26423. * Flags the audio engine in Locked state.
  26424. * This happens due to new browser policies preventing audio to autoplay.
  26425. */
  26426. lock(): void;
  26427. /**
  26428. * Unlocks the audio engine once a user action has been done on the dom.
  26429. * This is helpful to resume play once browser policies have been satisfied.
  26430. */
  26431. unlock(): void;
  26432. private _resumeAudioContext;
  26433. private _initializeAudioContext;
  26434. private _tryToRun;
  26435. private _triggerRunningState;
  26436. private _triggerSuspendedState;
  26437. private _displayMuteButton;
  26438. private _moveButtonToTopLeft;
  26439. private _onResize;
  26440. private _hideMuteButton;
  26441. /**
  26442. * Destroy and release the resources associated with the audio ccontext.
  26443. */
  26444. dispose(): void;
  26445. /**
  26446. * Gets the global volume sets on the master gain.
  26447. * @returns the global volume if set or -1 otherwise
  26448. */
  26449. getGlobalVolume(): number;
  26450. /**
  26451. * Sets the global volume of your experience (sets on the master gain).
  26452. * @param newVolume Defines the new global volume of the application
  26453. */
  26454. setGlobalVolume(newVolume: number): void;
  26455. /**
  26456. * Connect the audio engine to an audio analyser allowing some amazing
  26457. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26459. * @param analyser The analyser to connect to the engine
  26460. */
  26461. connectToAnalyser(analyser: Analyser): void;
  26462. }
  26463. }
  26464. declare module "babylonjs/Loading/loadingScreen" {
  26465. /**
  26466. * Interface used to present a loading screen while loading a scene
  26467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26468. */
  26469. export interface ILoadingScreen {
  26470. /**
  26471. * Function called to display the loading screen
  26472. */
  26473. displayLoadingUI: () => void;
  26474. /**
  26475. * Function called to hide the loading screen
  26476. */
  26477. hideLoadingUI: () => void;
  26478. /**
  26479. * Gets or sets the color to use for the background
  26480. */
  26481. loadingUIBackgroundColor: string;
  26482. /**
  26483. * Gets or sets the text to display while loading
  26484. */
  26485. loadingUIText: string;
  26486. }
  26487. /**
  26488. * Class used for the default loading screen
  26489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26490. */
  26491. export class DefaultLoadingScreen implements ILoadingScreen {
  26492. private _renderingCanvas;
  26493. private _loadingText;
  26494. private _loadingDivBackgroundColor;
  26495. private _loadingDiv;
  26496. private _loadingTextDiv;
  26497. /**
  26498. * Creates a new default loading screen
  26499. * @param _renderingCanvas defines the canvas used to render the scene
  26500. * @param _loadingText defines the default text to display
  26501. * @param _loadingDivBackgroundColor defines the default background color
  26502. */
  26503. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26504. /**
  26505. * Function called to display the loading screen
  26506. */
  26507. displayLoadingUI(): void;
  26508. /**
  26509. * Function called to hide the loading screen
  26510. */
  26511. hideLoadingUI(): void;
  26512. /**
  26513. * Gets or sets the text to display while loading
  26514. */
  26515. loadingUIText: string;
  26516. /**
  26517. * Gets or sets the color to use for the background
  26518. */
  26519. loadingUIBackgroundColor: string;
  26520. private _resizeLoadingUI;
  26521. }
  26522. }
  26523. declare module "babylonjs/Materials/Textures/videoTexture" {
  26524. import { Observable } from "babylonjs/Misc/observable";
  26525. import { Nullable } from "babylonjs/types";
  26526. import { Scene } from "babylonjs/scene";
  26527. import { Texture } from "babylonjs/Materials/Textures/texture";
  26528. /**
  26529. * Settings for finer control over video usage
  26530. */
  26531. export interface VideoTextureSettings {
  26532. /**
  26533. * Applies `autoplay` to video, if specified
  26534. */
  26535. autoPlay?: boolean;
  26536. /**
  26537. * Applies `loop` to video, if specified
  26538. */
  26539. loop?: boolean;
  26540. /**
  26541. * Automatically updates internal texture from video at every frame in the render loop
  26542. */
  26543. autoUpdateTexture: boolean;
  26544. /**
  26545. * Image src displayed during the video loading or until the user interacts with the video.
  26546. */
  26547. poster?: string;
  26548. }
  26549. /**
  26550. * If you want to display a video in your scene, this is the special texture for that.
  26551. * This special texture works similar to other textures, with the exception of a few parameters.
  26552. * @see https://doc.babylonjs.com/how_to/video_texture
  26553. */
  26554. export class VideoTexture extends Texture {
  26555. /**
  26556. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26557. */
  26558. readonly autoUpdateTexture: boolean;
  26559. /**
  26560. * The video instance used by the texture internally
  26561. */
  26562. readonly video: HTMLVideoElement;
  26563. private _onUserActionRequestedObservable;
  26564. /**
  26565. * Event triggerd when a dom action is required by the user to play the video.
  26566. * This happens due to recent changes in browser policies preventing video to auto start.
  26567. */
  26568. readonly onUserActionRequestedObservable: Observable<Texture>;
  26569. private _generateMipMaps;
  26570. private _engine;
  26571. private _stillImageCaptured;
  26572. private _displayingPosterTexture;
  26573. private _settings;
  26574. private _createInternalTextureOnEvent;
  26575. /**
  26576. * Creates a video texture.
  26577. * If you want to display a video in your scene, this is the special texture for that.
  26578. * This special texture works similar to other textures, with the exception of a few parameters.
  26579. * @see https://doc.babylonjs.com/how_to/video_texture
  26580. * @param name optional name, will detect from video source, if not defined
  26581. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26582. * @param scene is obviously the current scene.
  26583. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26584. * @param invertY is false by default but can be used to invert video on Y axis
  26585. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26586. * @param settings allows finer control over video usage
  26587. */
  26588. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26589. private _getName;
  26590. private _getVideo;
  26591. private _createInternalTexture;
  26592. private reset;
  26593. /**
  26594. * @hidden Internal method to initiate `update`.
  26595. */
  26596. _rebuild(): void;
  26597. /**
  26598. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26599. */
  26600. update(): void;
  26601. /**
  26602. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26603. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26604. */
  26605. updateTexture(isVisible: boolean): void;
  26606. protected _updateInternalTexture: () => void;
  26607. /**
  26608. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26609. * @param url New url.
  26610. */
  26611. updateURL(url: string): void;
  26612. /**
  26613. * Dispose the texture and release its associated resources.
  26614. */
  26615. dispose(): void;
  26616. /**
  26617. * Creates a video texture straight from your WebCam video feed.
  26618. * @param scene Define the scene the texture should be created in
  26619. * @param onReady Define a callback to triggered once the texture will be ready
  26620. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26621. */
  26622. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26623. minWidth: number;
  26624. maxWidth: number;
  26625. minHeight: number;
  26626. maxHeight: number;
  26627. deviceId: string;
  26628. }): void;
  26629. }
  26630. }
  26631. declare module "babylonjs/Engines/engine" {
  26632. import { Observable } from "babylonjs/Misc/observable";
  26633. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26634. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26635. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26636. import { Camera } from "babylonjs/Cameras/camera";
  26637. import { Scene } from "babylonjs/scene";
  26638. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26639. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26640. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26641. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26642. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26643. import { Material } from "babylonjs/Materials/material";
  26644. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26646. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26647. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26648. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26649. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26650. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26651. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26652. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26653. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26654. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26655. /**
  26656. * Interface for attribute information associated with buffer instanciation
  26657. */
  26658. export class InstancingAttributeInfo {
  26659. /**
  26660. * Index/offset of the attribute in the vertex shader
  26661. */
  26662. index: number;
  26663. /**
  26664. * size of the attribute, 1, 2, 3 or 4
  26665. */
  26666. attributeSize: number;
  26667. /**
  26668. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26669. * default is FLOAT
  26670. */
  26671. attribyteType: number;
  26672. /**
  26673. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26674. */
  26675. normalized: boolean;
  26676. /**
  26677. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26678. */
  26679. offset: number;
  26680. /**
  26681. * Name of the GLSL attribute, for debugging purpose only
  26682. */
  26683. attributeName: string;
  26684. }
  26685. /**
  26686. * Define options used to create a depth texture
  26687. */
  26688. export class DepthTextureCreationOptions {
  26689. /** Specifies whether or not a stencil should be allocated in the texture */
  26690. generateStencil?: boolean;
  26691. /** Specifies whether or not bilinear filtering is enable on the texture */
  26692. bilinearFiltering?: boolean;
  26693. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26694. comparisonFunction?: number;
  26695. /** Specifies if the created texture is a cube texture */
  26696. isCube?: boolean;
  26697. }
  26698. /**
  26699. * Class used to describe the capabilities of the engine relatively to the current browser
  26700. */
  26701. export class EngineCapabilities {
  26702. /** Maximum textures units per fragment shader */
  26703. maxTexturesImageUnits: number;
  26704. /** Maximum texture units per vertex shader */
  26705. maxVertexTextureImageUnits: number;
  26706. /** Maximum textures units in the entire pipeline */
  26707. maxCombinedTexturesImageUnits: number;
  26708. /** Maximum texture size */
  26709. maxTextureSize: number;
  26710. /** Maximum cube texture size */
  26711. maxCubemapTextureSize: number;
  26712. /** Maximum render texture size */
  26713. maxRenderTextureSize: number;
  26714. /** Maximum number of vertex attributes */
  26715. maxVertexAttribs: number;
  26716. /** Maximum number of varyings */
  26717. maxVaryingVectors: number;
  26718. /** Maximum number of uniforms per vertex shader */
  26719. maxVertexUniformVectors: number;
  26720. /** Maximum number of uniforms per fragment shader */
  26721. maxFragmentUniformVectors: number;
  26722. /** Defines if standard derivates (dx/dy) are supported */
  26723. standardDerivatives: boolean;
  26724. /** Defines if s3tc texture compression is supported */
  26725. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26726. /** Defines if pvrtc texture compression is supported */
  26727. pvrtc: any;
  26728. /** Defines if etc1 texture compression is supported */
  26729. etc1: any;
  26730. /** Defines if etc2 texture compression is supported */
  26731. etc2: any;
  26732. /** Defines if astc texture compression is supported */
  26733. astc: any;
  26734. /** Defines if float textures are supported */
  26735. textureFloat: boolean;
  26736. /** Defines if vertex array objects are supported */
  26737. vertexArrayObject: boolean;
  26738. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26739. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26740. /** Gets the maximum level of anisotropy supported */
  26741. maxAnisotropy: number;
  26742. /** Defines if instancing is supported */
  26743. instancedArrays: boolean;
  26744. /** Defines if 32 bits indices are supported */
  26745. uintIndices: boolean;
  26746. /** Defines if high precision shaders are supported */
  26747. highPrecisionShaderSupported: boolean;
  26748. /** Defines if depth reading in the fragment shader is supported */
  26749. fragmentDepthSupported: boolean;
  26750. /** Defines if float texture linear filtering is supported*/
  26751. textureFloatLinearFiltering: boolean;
  26752. /** Defines if rendering to float textures is supported */
  26753. textureFloatRender: boolean;
  26754. /** Defines if half float textures are supported*/
  26755. textureHalfFloat: boolean;
  26756. /** Defines if half float texture linear filtering is supported*/
  26757. textureHalfFloatLinearFiltering: boolean;
  26758. /** Defines if rendering to half float textures is supported */
  26759. textureHalfFloatRender: boolean;
  26760. /** Defines if textureLOD shader command is supported */
  26761. textureLOD: boolean;
  26762. /** Defines if draw buffers extension is supported */
  26763. drawBuffersExtension: boolean;
  26764. /** Defines if depth textures are supported */
  26765. depthTextureExtension: boolean;
  26766. /** Defines if float color buffer are supported */
  26767. colorBufferFloat: boolean;
  26768. /** Gets disjoint timer query extension (null if not supported) */
  26769. timerQuery: EXT_disjoint_timer_query;
  26770. /** Defines if timestamp can be used with timer query */
  26771. canUseTimestampForTimerQuery: boolean;
  26772. /** Function used to let the system compiles shaders in background */
  26773. parallelShaderCompile: {
  26774. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26775. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26776. COMPLETION_STATUS_KHR: number;
  26777. };
  26778. }
  26779. /** Interface defining initialization parameters for Engine class */
  26780. export interface EngineOptions extends WebGLContextAttributes {
  26781. /**
  26782. * Defines if the engine should no exceed a specified device ratio
  26783. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26784. */
  26785. limitDeviceRatio?: number;
  26786. /**
  26787. * Defines if webvr should be enabled automatically
  26788. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26789. */
  26790. autoEnableWebVR?: boolean;
  26791. /**
  26792. * Defines if webgl2 should be turned off even if supported
  26793. * @see http://doc.babylonjs.com/features/webgl2
  26794. */
  26795. disableWebGL2Support?: boolean;
  26796. /**
  26797. * Defines if webaudio should be initialized as well
  26798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26799. */
  26800. audioEngine?: boolean;
  26801. /**
  26802. * Defines if animations should run using a deterministic lock step
  26803. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26804. */
  26805. deterministicLockstep?: boolean;
  26806. /** Defines the maximum steps to use with deterministic lock step mode */
  26807. lockstepMaxSteps?: number;
  26808. /**
  26809. * Defines that engine should ignore context lost events
  26810. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26811. */
  26812. doNotHandleContextLost?: boolean;
  26813. /**
  26814. * Defines that engine should ignore modifying touch action attribute and style
  26815. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26816. */
  26817. doNotHandleTouchAction?: boolean;
  26818. }
  26819. /**
  26820. * Defines the interface used by display changed events
  26821. */
  26822. export interface IDisplayChangedEventArgs {
  26823. /** Gets the vrDisplay object (if any) */
  26824. vrDisplay: Nullable<any>;
  26825. /** Gets a boolean indicating if webVR is supported */
  26826. vrSupported: boolean;
  26827. }
  26828. /**
  26829. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26830. */
  26831. export class Engine {
  26832. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26833. static ExceptionList: ({
  26834. key: string;
  26835. capture: string;
  26836. captureConstraint: number;
  26837. targets: string[];
  26838. } | {
  26839. key: string;
  26840. capture: null;
  26841. captureConstraint: null;
  26842. targets: string[];
  26843. })[];
  26844. /** Gets the list of created engines */
  26845. static readonly Instances: Engine[];
  26846. /**
  26847. * Gets the latest created engine
  26848. */
  26849. static readonly LastCreatedEngine: Nullable<Engine>;
  26850. /**
  26851. * Gets the latest created scene
  26852. */
  26853. static readonly LastCreatedScene: Nullable<Scene>;
  26854. /**
  26855. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26856. * @param flag defines which part of the materials must be marked as dirty
  26857. * @param predicate defines a predicate used to filter which materials should be affected
  26858. */
  26859. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26860. /**
  26861. * Hidden
  26862. */
  26863. static _TextureLoaders: IInternalTextureLoader[];
  26864. /** Defines that alpha blending is disabled */
  26865. static readonly ALPHA_DISABLE: number;
  26866. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26867. static readonly ALPHA_ADD: number;
  26868. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26869. static readonly ALPHA_COMBINE: number;
  26870. /** Defines that alpha blending to DEST - SRC * DEST */
  26871. static readonly ALPHA_SUBTRACT: number;
  26872. /** Defines that alpha blending to SRC * DEST */
  26873. static readonly ALPHA_MULTIPLY: number;
  26874. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26875. static readonly ALPHA_MAXIMIZED: number;
  26876. /** Defines that alpha blending to SRC + DEST */
  26877. static readonly ALPHA_ONEONE: number;
  26878. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26879. static readonly ALPHA_PREMULTIPLIED: number;
  26880. /**
  26881. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26882. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26883. */
  26884. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26885. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26886. static readonly ALPHA_INTERPOLATE: number;
  26887. /**
  26888. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26889. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26890. */
  26891. static readonly ALPHA_SCREENMODE: number;
  26892. /** Defines that the ressource is not delayed*/
  26893. static readonly DELAYLOADSTATE_NONE: number;
  26894. /** Defines that the ressource was successfully delay loaded */
  26895. static readonly DELAYLOADSTATE_LOADED: number;
  26896. /** Defines that the ressource is currently delay loading */
  26897. static readonly DELAYLOADSTATE_LOADING: number;
  26898. /** Defines that the ressource is delayed and has not started loading */
  26899. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26901. static readonly NEVER: number;
  26902. /** 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 */
  26903. static readonly ALWAYS: number;
  26904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26905. static readonly LESS: number;
  26906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26907. static readonly EQUAL: number;
  26908. /** 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 */
  26909. static readonly LEQUAL: number;
  26910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26911. static readonly GREATER: number;
  26912. /** 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 */
  26913. static readonly GEQUAL: number;
  26914. /** 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 */
  26915. static readonly NOTEQUAL: number;
  26916. /** Passed to stencilOperation to specify that stencil value must be kept */
  26917. static readonly KEEP: number;
  26918. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26919. static readonly REPLACE: number;
  26920. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26921. static readonly INCR: number;
  26922. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26923. static readonly DECR: number;
  26924. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26925. static readonly INVERT: number;
  26926. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26927. static readonly INCR_WRAP: number;
  26928. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26929. static readonly DECR_WRAP: number;
  26930. /** Texture is not repeating outside of 0..1 UVs */
  26931. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26932. /** Texture is repeating outside of 0..1 UVs */
  26933. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26934. /** Texture is repeating and mirrored */
  26935. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26936. /** ALPHA */
  26937. static readonly TEXTUREFORMAT_ALPHA: number;
  26938. /** LUMINANCE */
  26939. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26940. /** LUMINANCE_ALPHA */
  26941. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26942. /** RGB */
  26943. static readonly TEXTUREFORMAT_RGB: number;
  26944. /** RGBA */
  26945. static readonly TEXTUREFORMAT_RGBA: number;
  26946. /** RED */
  26947. static readonly TEXTUREFORMAT_RED: number;
  26948. /** RED (2nd reference) */
  26949. static readonly TEXTUREFORMAT_R: number;
  26950. /** RG */
  26951. static readonly TEXTUREFORMAT_RG: number;
  26952. /** RED_INTEGER */
  26953. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26954. /** RED_INTEGER (2nd reference) */
  26955. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26956. /** RG_INTEGER */
  26957. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26958. /** RGB_INTEGER */
  26959. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26960. /** RGBA_INTEGER */
  26961. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26962. /** UNSIGNED_BYTE */
  26963. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26964. /** UNSIGNED_BYTE (2nd reference) */
  26965. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26966. /** FLOAT */
  26967. static readonly TEXTURETYPE_FLOAT: number;
  26968. /** HALF_FLOAT */
  26969. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26970. /** BYTE */
  26971. static readonly TEXTURETYPE_BYTE: number;
  26972. /** SHORT */
  26973. static readonly TEXTURETYPE_SHORT: number;
  26974. /** UNSIGNED_SHORT */
  26975. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26976. /** INT */
  26977. static readonly TEXTURETYPE_INT: number;
  26978. /** UNSIGNED_INT */
  26979. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26980. /** UNSIGNED_SHORT_4_4_4_4 */
  26981. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26982. /** UNSIGNED_SHORT_5_5_5_1 */
  26983. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26984. /** UNSIGNED_SHORT_5_6_5 */
  26985. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26986. /** UNSIGNED_INT_2_10_10_10_REV */
  26987. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26988. /** UNSIGNED_INT_24_8 */
  26989. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26990. /** UNSIGNED_INT_10F_11F_11F_REV */
  26991. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26992. /** UNSIGNED_INT_5_9_9_9_REV */
  26993. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26994. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26995. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26996. /** nearest is mag = nearest and min = nearest and mip = linear */
  26997. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26998. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26999. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27000. /** Trilinear is mag = linear and min = linear and mip = linear */
  27001. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27002. /** nearest is mag = nearest and min = nearest and mip = linear */
  27003. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27004. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27005. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27006. /** Trilinear is mag = linear and min = linear and mip = linear */
  27007. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27008. /** mag = nearest and min = nearest and mip = nearest */
  27009. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27010. /** mag = nearest and min = linear and mip = nearest */
  27011. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27012. /** mag = nearest and min = linear and mip = linear */
  27013. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27014. /** mag = nearest and min = linear and mip = none */
  27015. static readonly TEXTURE_NEAREST_LINEAR: number;
  27016. /** mag = nearest and min = nearest and mip = none */
  27017. static readonly TEXTURE_NEAREST_NEAREST: number;
  27018. /** mag = linear and min = nearest and mip = nearest */
  27019. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27020. /** mag = linear and min = nearest and mip = linear */
  27021. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27022. /** mag = linear and min = linear and mip = none */
  27023. static readonly TEXTURE_LINEAR_LINEAR: number;
  27024. /** mag = linear and min = nearest and mip = none */
  27025. static readonly TEXTURE_LINEAR_NEAREST: number;
  27026. /** Explicit coordinates mode */
  27027. static readonly TEXTURE_EXPLICIT_MODE: number;
  27028. /** Spherical coordinates mode */
  27029. static readonly TEXTURE_SPHERICAL_MODE: number;
  27030. /** Planar coordinates mode */
  27031. static readonly TEXTURE_PLANAR_MODE: number;
  27032. /** Cubic coordinates mode */
  27033. static readonly TEXTURE_CUBIC_MODE: number;
  27034. /** Projection coordinates mode */
  27035. static readonly TEXTURE_PROJECTION_MODE: number;
  27036. /** Skybox coordinates mode */
  27037. static readonly TEXTURE_SKYBOX_MODE: number;
  27038. /** Inverse Cubic coordinates mode */
  27039. static readonly TEXTURE_INVCUBIC_MODE: number;
  27040. /** Equirectangular coordinates mode */
  27041. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27042. /** Equirectangular Fixed coordinates mode */
  27043. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27044. /** Equirectangular Fixed Mirrored coordinates mode */
  27045. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27046. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27047. static readonly SCALEMODE_FLOOR: number;
  27048. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27049. static readonly SCALEMODE_NEAREST: number;
  27050. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27051. static readonly SCALEMODE_CEILING: number;
  27052. /**
  27053. * Returns the current version of the framework
  27054. */
  27055. static readonly Version: string;
  27056. /**
  27057. * Returns a string describing the current engine
  27058. */
  27059. readonly description: string;
  27060. /**
  27061. * Gets or sets the epsilon value used by collision engine
  27062. */
  27063. static CollisionsEpsilon: number;
  27064. /**
  27065. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27066. */
  27067. static ShadersRepository: string;
  27068. /**
  27069. * Method called to create the default loading screen.
  27070. * This can be overriden in your own app.
  27071. * @param canvas The rendering canvas element
  27072. * @returns The loading screen
  27073. */
  27074. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27075. /**
  27076. * Method called to create the default rescale post process on each engine.
  27077. */
  27078. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27079. /**
  27080. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27081. */
  27082. forcePOTTextures: boolean;
  27083. /**
  27084. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27085. */
  27086. isFullscreen: boolean;
  27087. /**
  27088. * Gets a boolean indicating if the pointer is currently locked
  27089. */
  27090. isPointerLock: boolean;
  27091. /**
  27092. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27093. */
  27094. cullBackFaces: boolean;
  27095. /**
  27096. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27097. */
  27098. renderEvenInBackground: boolean;
  27099. /**
  27100. * Gets or sets a boolean indicating that cache can be kept between frames
  27101. */
  27102. preventCacheWipeBetweenFrames: boolean;
  27103. /**
  27104. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27105. **/
  27106. enableOfflineSupport: boolean;
  27107. /**
  27108. * 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)
  27109. **/
  27110. disableManifestCheck: boolean;
  27111. /**
  27112. * Gets the list of created scenes
  27113. */
  27114. scenes: Scene[];
  27115. /**
  27116. * Event raised when a new scene is created
  27117. */
  27118. onNewSceneAddedObservable: Observable<Scene>;
  27119. /**
  27120. * Gets the list of created postprocesses
  27121. */
  27122. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27123. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27124. validateShaderPrograms: boolean;
  27125. /**
  27126. * Observable event triggered each time the rendering canvas is resized
  27127. */
  27128. onResizeObservable: Observable<Engine>;
  27129. /**
  27130. * Observable event triggered each time the canvas loses focus
  27131. */
  27132. onCanvasBlurObservable: Observable<Engine>;
  27133. /**
  27134. * Observable event triggered each time the canvas gains focus
  27135. */
  27136. onCanvasFocusObservable: Observable<Engine>;
  27137. /**
  27138. * Observable event triggered each time the canvas receives pointerout event
  27139. */
  27140. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27141. /**
  27142. * Observable event triggered before each texture is initialized
  27143. */
  27144. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27145. private _vrDisplay;
  27146. private _vrSupported;
  27147. private _oldSize;
  27148. private _oldHardwareScaleFactor;
  27149. private _vrExclusivePointerMode;
  27150. private _webVRInitPromise;
  27151. /**
  27152. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27153. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27154. */
  27155. readonly isInVRExclusivePointerMode: boolean;
  27156. /**
  27157. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27158. */
  27159. disableUniformBuffers: boolean;
  27160. /** @hidden */
  27161. _uniformBuffers: UniformBuffer[];
  27162. /**
  27163. * Gets a boolean indicating that the engine supports uniform buffers
  27164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27165. */
  27166. readonly supportsUniformBuffers: boolean;
  27167. /**
  27168. * Observable raised when the engine begins a new frame
  27169. */
  27170. onBeginFrameObservable: Observable<Engine>;
  27171. /**
  27172. * If set, will be used to request the next animation frame for the render loop
  27173. */
  27174. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27175. /**
  27176. * Observable raised when the engine ends the current frame
  27177. */
  27178. onEndFrameObservable: Observable<Engine>;
  27179. /**
  27180. * Observable raised when the engine is about to compile a shader
  27181. */
  27182. onBeforeShaderCompilationObservable: Observable<Engine>;
  27183. /**
  27184. * Observable raised when the engine has jsut compiled a shader
  27185. */
  27186. onAfterShaderCompilationObservable: Observable<Engine>;
  27187. /** @hidden */
  27188. _gl: WebGLRenderingContext;
  27189. private _renderingCanvas;
  27190. private _windowIsBackground;
  27191. private _webGLVersion;
  27192. /**
  27193. * Gets a boolean indicating that only power of 2 textures are supported
  27194. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27195. */
  27196. readonly needPOTTextures: boolean;
  27197. /** @hidden */
  27198. _badOS: boolean;
  27199. /** @hidden */
  27200. _badDesktopOS: boolean;
  27201. /**
  27202. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27203. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27204. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27205. */
  27206. disableTextureBindingOptimization: boolean;
  27207. /**
  27208. * Gets the audio engine
  27209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27210. * @ignorenaming
  27211. */
  27212. static audioEngine: IAudioEngine;
  27213. /**
  27214. * Default AudioEngine factory responsible of creating the Audio Engine.
  27215. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27216. */
  27217. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27218. /**
  27219. * Default offline support factory responsible of creating a tool used to store data locally.
  27220. * By default, this will create a Database object if the workload has been embedded.
  27221. */
  27222. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27223. private _onFocus;
  27224. private _onBlur;
  27225. private _onCanvasPointerOut;
  27226. private _onCanvasBlur;
  27227. private _onCanvasFocus;
  27228. private _onFullscreenChange;
  27229. private _onPointerLockChange;
  27230. private _onVRDisplayPointerRestricted;
  27231. private _onVRDisplayPointerUnrestricted;
  27232. private _onVrDisplayConnect;
  27233. private _onVrDisplayDisconnect;
  27234. private _onVrDisplayPresentChange;
  27235. /**
  27236. * Observable signaled when VR display mode changes
  27237. */
  27238. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27239. /**
  27240. * Observable signaled when VR request present is complete
  27241. */
  27242. onVRRequestPresentComplete: Observable<boolean>;
  27243. /**
  27244. * Observable signaled when VR request present starts
  27245. */
  27246. onVRRequestPresentStart: Observable<Engine>;
  27247. private _hardwareScalingLevel;
  27248. /** @hidden */
  27249. protected _caps: EngineCapabilities;
  27250. private _pointerLockRequested;
  27251. private _isStencilEnable;
  27252. private _colorWrite;
  27253. private _loadingScreen;
  27254. /** @hidden */
  27255. _drawCalls: PerfCounter;
  27256. /** @hidden */
  27257. _textureCollisions: PerfCounter;
  27258. private _glVersion;
  27259. private _glRenderer;
  27260. private _glVendor;
  27261. private _videoTextureSupported;
  27262. private _renderingQueueLaunched;
  27263. private _activeRenderLoops;
  27264. private _deterministicLockstep;
  27265. private _lockstepMaxSteps;
  27266. /**
  27267. * Observable signaled when a context lost event is raised
  27268. */
  27269. onContextLostObservable: Observable<Engine>;
  27270. /**
  27271. * Observable signaled when a context restored event is raised
  27272. */
  27273. onContextRestoredObservable: Observable<Engine>;
  27274. private _onContextLost;
  27275. private _onContextRestored;
  27276. private _contextWasLost;
  27277. private _doNotHandleContextLost;
  27278. /**
  27279. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27281. */
  27282. doNotHandleContextLost: boolean;
  27283. private _performanceMonitor;
  27284. private _fps;
  27285. private _deltaTime;
  27286. /**
  27287. * Turn this value on if you want to pause FPS computation when in background
  27288. */
  27289. disablePerformanceMonitorInBackground: boolean;
  27290. /**
  27291. * Gets the performance monitor attached to this engine
  27292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27293. */
  27294. readonly performanceMonitor: PerformanceMonitor;
  27295. /** @hidden */
  27296. protected _depthCullingState: _DepthCullingState;
  27297. /** @hidden */
  27298. protected _stencilState: _StencilState;
  27299. /** @hidden */
  27300. protected _alphaState: _AlphaState;
  27301. /** @hidden */
  27302. protected _alphaMode: number;
  27303. protected _internalTexturesCache: InternalTexture[];
  27304. /** @hidden */
  27305. protected _activeChannel: number;
  27306. private _currentTextureChannel;
  27307. /** @hidden */
  27308. protected _boundTexturesCache: {
  27309. [key: string]: Nullable<InternalTexture>;
  27310. };
  27311. /** @hidden */
  27312. protected _currentEffect: Nullable<Effect>;
  27313. /** @hidden */
  27314. protected _currentProgram: Nullable<WebGLProgram>;
  27315. private _compiledEffects;
  27316. private _vertexAttribArraysEnabled;
  27317. /** @hidden */
  27318. protected _cachedViewport: Nullable<Viewport>;
  27319. private _cachedVertexArrayObject;
  27320. /** @hidden */
  27321. protected _cachedVertexBuffers: any;
  27322. /** @hidden */
  27323. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27324. /** @hidden */
  27325. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27326. /** @hidden */
  27327. protected _currentRenderTarget: Nullable<InternalTexture>;
  27328. private _uintIndicesCurrentlySet;
  27329. private _currentBoundBuffer;
  27330. /** @hidden */
  27331. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27332. private _currentBufferPointers;
  27333. private _currentInstanceLocations;
  27334. private _currentInstanceBuffers;
  27335. private _textureUnits;
  27336. private _firstBoundInternalTextureTracker;
  27337. private _lastBoundInternalTextureTracker;
  27338. private _workingCanvas;
  27339. private _workingContext;
  27340. private _rescalePostProcess;
  27341. private _dummyFramebuffer;
  27342. private _externalData;
  27343. private _bindedRenderFunction;
  27344. private _vaoRecordInProgress;
  27345. private _mustWipeVertexAttributes;
  27346. private _emptyTexture;
  27347. private _emptyCubeTexture;
  27348. private _emptyTexture3D;
  27349. /** @hidden */
  27350. _frameHandler: number;
  27351. private _nextFreeTextureSlots;
  27352. private _maxSimultaneousTextures;
  27353. private _activeRequests;
  27354. private _texturesSupported;
  27355. private _textureFormatInUse;
  27356. /**
  27357. * Gets the list of texture formats supported
  27358. */
  27359. readonly texturesSupported: Array<string>;
  27360. /**
  27361. * Gets the list of texture formats in use
  27362. */
  27363. readonly textureFormatInUse: Nullable<string>;
  27364. /**
  27365. * Gets the current viewport
  27366. */
  27367. readonly currentViewport: Nullable<Viewport>;
  27368. /**
  27369. * Gets the default empty texture
  27370. */
  27371. readonly emptyTexture: InternalTexture;
  27372. /**
  27373. * Gets the default empty 3D texture
  27374. */
  27375. readonly emptyTexture3D: InternalTexture;
  27376. /**
  27377. * Gets the default empty cube texture
  27378. */
  27379. readonly emptyCubeTexture: InternalTexture;
  27380. /**
  27381. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27382. */
  27383. readonly premultipliedAlpha: boolean;
  27384. /**
  27385. * Creates a new engine
  27386. * @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
  27387. * @param antialias defines enable antialiasing (default: false)
  27388. * @param options defines further options to be sent to the getContext() function
  27389. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27390. */
  27391. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27392. private _disableTouchAction;
  27393. private _rebuildInternalTextures;
  27394. private _rebuildEffects;
  27395. /**
  27396. * Gets a boolean indicating if all created effects are ready
  27397. * @returns true if all effects are ready
  27398. */
  27399. areAllEffectsReady(): boolean;
  27400. private _rebuildBuffers;
  27401. private _initGLContext;
  27402. /**
  27403. * Gets version of the current webGL context
  27404. */
  27405. readonly webGLVersion: number;
  27406. /**
  27407. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27408. */
  27409. readonly isStencilEnable: boolean;
  27410. private _prepareWorkingCanvas;
  27411. /**
  27412. * Reset the texture cache to empty state
  27413. */
  27414. resetTextureCache(): void;
  27415. /**
  27416. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27418. * @returns true if engine is in deterministic lock step mode
  27419. */
  27420. isDeterministicLockStep(): boolean;
  27421. /**
  27422. * Gets the max steps when engine is running in deterministic lock step
  27423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27424. * @returns the max steps
  27425. */
  27426. getLockstepMaxSteps(): number;
  27427. /**
  27428. * Gets an object containing information about the current webGL context
  27429. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27430. */
  27431. getGlInfo(): {
  27432. vendor: string;
  27433. renderer: string;
  27434. version: string;
  27435. };
  27436. /**
  27437. * Gets current aspect ratio
  27438. * @param camera defines the camera to use to get the aspect ratio
  27439. * @param useScreen defines if screen size must be used (or the current render target if any)
  27440. * @returns a number defining the aspect ratio
  27441. */
  27442. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27443. /**
  27444. * Gets current screen aspect ratio
  27445. * @returns a number defining the aspect ratio
  27446. */
  27447. getScreenAspectRatio(): number;
  27448. /**
  27449. * Gets the current render width
  27450. * @param useScreen defines if screen size must be used (or the current render target if any)
  27451. * @returns a number defining the current render width
  27452. */
  27453. getRenderWidth(useScreen?: boolean): number;
  27454. /**
  27455. * Gets the current render height
  27456. * @param useScreen defines if screen size must be used (or the current render target if any)
  27457. * @returns a number defining the current render height
  27458. */
  27459. getRenderHeight(useScreen?: boolean): number;
  27460. /**
  27461. * Gets the HTML canvas attached with the current webGL context
  27462. * @returns a HTML canvas
  27463. */
  27464. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27465. /**
  27466. * Gets the client rect of the HTML canvas attached with the current webGL context
  27467. * @returns a client rectanglee
  27468. */
  27469. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27470. /**
  27471. * Defines the hardware scaling level.
  27472. * By default the hardware scaling level is computed from the window device ratio.
  27473. * 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.
  27474. * @param level defines the level to use
  27475. */
  27476. setHardwareScalingLevel(level: number): void;
  27477. /**
  27478. * Gets the current hardware scaling level.
  27479. * By default the hardware scaling level is computed from the window device ratio.
  27480. * 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.
  27481. * @returns a number indicating the current hardware scaling level
  27482. */
  27483. getHardwareScalingLevel(): number;
  27484. /**
  27485. * Gets the list of loaded textures
  27486. * @returns an array containing all loaded textures
  27487. */
  27488. getLoadedTexturesCache(): InternalTexture[];
  27489. /**
  27490. * Gets the object containing all engine capabilities
  27491. * @returns the EngineCapabilities object
  27492. */
  27493. getCaps(): EngineCapabilities;
  27494. /**
  27495. * Gets the current depth function
  27496. * @returns a number defining the depth function
  27497. */
  27498. getDepthFunction(): Nullable<number>;
  27499. /**
  27500. * Sets the current depth function
  27501. * @param depthFunc defines the function to use
  27502. */
  27503. setDepthFunction(depthFunc: number): void;
  27504. /**
  27505. * Sets the current depth function to GREATER
  27506. */
  27507. setDepthFunctionToGreater(): void;
  27508. /**
  27509. * Sets the current depth function to GEQUAL
  27510. */
  27511. setDepthFunctionToGreaterOrEqual(): void;
  27512. /**
  27513. * Sets the current depth function to LESS
  27514. */
  27515. setDepthFunctionToLess(): void;
  27516. /**
  27517. * Sets the current depth function to LEQUAL
  27518. */
  27519. setDepthFunctionToLessOrEqual(): void;
  27520. /**
  27521. * Gets a boolean indicating if stencil buffer is enabled
  27522. * @returns the current stencil buffer state
  27523. */
  27524. getStencilBuffer(): boolean;
  27525. /**
  27526. * Enable or disable the stencil buffer
  27527. * @param enable defines if the stencil buffer must be enabled or disabled
  27528. */
  27529. setStencilBuffer(enable: boolean): void;
  27530. /**
  27531. * Gets the current stencil mask
  27532. * @returns a number defining the new stencil mask to use
  27533. */
  27534. getStencilMask(): number;
  27535. /**
  27536. * Sets the current stencil mask
  27537. * @param mask defines the new stencil mask to use
  27538. */
  27539. setStencilMask(mask: number): void;
  27540. /**
  27541. * Gets the current stencil function
  27542. * @returns a number defining the stencil function to use
  27543. */
  27544. getStencilFunction(): number;
  27545. /**
  27546. * Gets the current stencil reference value
  27547. * @returns a number defining the stencil reference value to use
  27548. */
  27549. getStencilFunctionReference(): number;
  27550. /**
  27551. * Gets the current stencil mask
  27552. * @returns a number defining the stencil mask to use
  27553. */
  27554. getStencilFunctionMask(): number;
  27555. /**
  27556. * Sets the current stencil function
  27557. * @param stencilFunc defines the new stencil function to use
  27558. */
  27559. setStencilFunction(stencilFunc: number): void;
  27560. /**
  27561. * Sets the current stencil reference
  27562. * @param reference defines the new stencil reference to use
  27563. */
  27564. setStencilFunctionReference(reference: number): void;
  27565. /**
  27566. * Sets the current stencil mask
  27567. * @param mask defines the new stencil mask to use
  27568. */
  27569. setStencilFunctionMask(mask: number): void;
  27570. /**
  27571. * Gets the current stencil operation when stencil fails
  27572. * @returns a number defining stencil operation to use when stencil fails
  27573. */
  27574. getStencilOperationFail(): number;
  27575. /**
  27576. * Gets the current stencil operation when depth fails
  27577. * @returns a number defining stencil operation to use when depth fails
  27578. */
  27579. getStencilOperationDepthFail(): number;
  27580. /**
  27581. * Gets the current stencil operation when stencil passes
  27582. * @returns a number defining stencil operation to use when stencil passes
  27583. */
  27584. getStencilOperationPass(): number;
  27585. /**
  27586. * Sets the stencil operation to use when stencil fails
  27587. * @param operation defines the stencil operation to use when stencil fails
  27588. */
  27589. setStencilOperationFail(operation: number): void;
  27590. /**
  27591. * Sets the stencil operation to use when depth fails
  27592. * @param operation defines the stencil operation to use when depth fails
  27593. */
  27594. setStencilOperationDepthFail(operation: number): void;
  27595. /**
  27596. * Sets the stencil operation to use when stencil passes
  27597. * @param operation defines the stencil operation to use when stencil passes
  27598. */
  27599. setStencilOperationPass(operation: number): void;
  27600. /**
  27601. * Sets a boolean indicating if the dithering state is enabled or disabled
  27602. * @param value defines the dithering state
  27603. */
  27604. setDitheringState(value: boolean): void;
  27605. /**
  27606. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27607. * @param value defines the rasterizer state
  27608. */
  27609. setRasterizerState(value: boolean): void;
  27610. /**
  27611. * stop executing a render loop function and remove it from the execution array
  27612. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27613. */
  27614. stopRenderLoop(renderFunction?: () => void): void;
  27615. /** @hidden */
  27616. _renderLoop(): void;
  27617. /**
  27618. * Register and execute a render loop. The engine can have more than one render function
  27619. * @param renderFunction defines the function to continuously execute
  27620. */
  27621. runRenderLoop(renderFunction: () => void): void;
  27622. /**
  27623. * Toggle full screen mode
  27624. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27625. */
  27626. switchFullscreen(requestPointerLock: boolean): void;
  27627. /**
  27628. * Enters full screen mode
  27629. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27630. */
  27631. enterFullscreen(requestPointerLock: boolean): void;
  27632. /**
  27633. * Exits full screen mode
  27634. */
  27635. exitFullscreen(): void;
  27636. /**
  27637. * Clear the current render buffer or the current render target (if any is set up)
  27638. * @param color defines the color to use
  27639. * @param backBuffer defines if the back buffer must be cleared
  27640. * @param depth defines if the depth buffer must be cleared
  27641. * @param stencil defines if the stencil buffer must be cleared
  27642. */
  27643. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27644. /**
  27645. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27646. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27647. * @param y defines the y-coordinate of the corner of the clear rectangle
  27648. * @param width defines the width of the clear rectangle
  27649. * @param height defines the height of the clear rectangle
  27650. * @param clearColor defines the clear color
  27651. */
  27652. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27653. /**
  27654. * Enable scissor test on a specific rectangle (ie. render will only be executed 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. */
  27660. enableScissor(x: number, y: number, width: number, height: number): void;
  27661. /**
  27662. * Disable previously set scissor test rectangle
  27663. */
  27664. disableScissor(): void;
  27665. private _viewportCached;
  27666. /** @hidden */
  27667. _viewport(x: number, y: number, width: number, height: number): void;
  27668. /**
  27669. * Set the WebGL's viewport
  27670. * @param viewport defines the viewport element to be used
  27671. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27672. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27673. */
  27674. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27675. /**
  27676. * Directly set the WebGL Viewport
  27677. * @param x defines the x coordinate of the viewport (in screen space)
  27678. * @param y defines the y coordinate of the viewport (in screen space)
  27679. * @param width defines the width of the viewport (in screen space)
  27680. * @param height defines the height of the viewport (in screen space)
  27681. * @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
  27682. */
  27683. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27684. /**
  27685. * Begin a new frame
  27686. */
  27687. beginFrame(): void;
  27688. /**
  27689. * Enf the current frame
  27690. */
  27691. endFrame(): void;
  27692. /**
  27693. * Resize the view according to the canvas' size
  27694. */
  27695. resize(): void;
  27696. /**
  27697. * Force a specific size of the canvas
  27698. * @param width defines the new canvas' width
  27699. * @param height defines the new canvas' height
  27700. */
  27701. setSize(width: number, height: number): void;
  27702. /**
  27703. * Gets a boolean indicating if a webVR device was detected
  27704. * @returns true if a webVR device was detected
  27705. */
  27706. isVRDevicePresent(): boolean;
  27707. /**
  27708. * Gets the current webVR device
  27709. * @returns the current webVR device (or null)
  27710. */
  27711. getVRDevice(): any;
  27712. /**
  27713. * Initializes a webVR display and starts listening to display change events
  27714. * The onVRDisplayChangedObservable will be notified upon these changes
  27715. * @returns The onVRDisplayChangedObservable
  27716. */
  27717. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27718. /**
  27719. * Initializes a webVR display and starts listening to display change events
  27720. * The onVRDisplayChangedObservable will be notified upon these changes
  27721. * @returns A promise containing a VRDisplay and if vr is supported
  27722. */
  27723. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27724. /**
  27725. * Call this function to switch to webVR mode
  27726. * Will do nothing if webVR is not supported or if there is no webVR device
  27727. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27728. */
  27729. enableVR(): void;
  27730. /**
  27731. * Call this function to leave webVR mode
  27732. * Will do nothing if webVR is not supported or if there is no webVR device
  27733. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27734. */
  27735. disableVR(): void;
  27736. private _onVRFullScreenTriggered;
  27737. private _getVRDisplaysAsync;
  27738. /**
  27739. * Binds the frame buffer to the specified texture.
  27740. * @param texture The texture to render to or null for the default canvas
  27741. * @param faceIndex The face of the texture to render to in case of cube texture
  27742. * @param requiredWidth The width of the target to render to
  27743. * @param requiredHeight The height of the target to render to
  27744. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27745. * @param depthStencilTexture The depth stencil texture to use to render
  27746. * @param lodLevel defines le lod level to bind to the frame buffer
  27747. */
  27748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27749. private bindUnboundFramebuffer;
  27750. /**
  27751. * Unbind the current render target texture from the webGL context
  27752. * @param texture defines the render target texture to unbind
  27753. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27754. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27755. */
  27756. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27757. /**
  27758. * Unbind a list of render target textures from the webGL context
  27759. * This is used only when drawBuffer extension or webGL2 are active
  27760. * @param textures defines the render target textures to unbind
  27761. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27762. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27763. */
  27764. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27765. /**
  27766. * Force the mipmap generation for the given render target texture
  27767. * @param texture defines the render target texture to use
  27768. */
  27769. generateMipMapsForCubemap(texture: InternalTexture): void;
  27770. /**
  27771. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27772. */
  27773. flushFramebuffer(): void;
  27774. /**
  27775. * Unbind the current render target and bind the default framebuffer
  27776. */
  27777. restoreDefaultFramebuffer(): void;
  27778. /**
  27779. * Create an uniform buffer
  27780. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27781. * @param elements defines the content of the uniform buffer
  27782. * @returns the webGL uniform buffer
  27783. */
  27784. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27785. /**
  27786. * Create a dynamic uniform buffer
  27787. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27788. * @param elements defines the content of the uniform buffer
  27789. * @returns the webGL uniform buffer
  27790. */
  27791. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27792. /**
  27793. * Update an existing uniform buffer
  27794. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27795. * @param uniformBuffer defines the target uniform buffer
  27796. * @param elements defines the content to update
  27797. * @param offset defines the offset in the uniform buffer where update should start
  27798. * @param count defines the size of the data to update
  27799. */
  27800. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27801. private _resetVertexBufferBinding;
  27802. /**
  27803. * Creates a vertex buffer
  27804. * @param data the data for the vertex buffer
  27805. * @returns the new WebGL static buffer
  27806. */
  27807. createVertexBuffer(data: DataArray): WebGLBuffer;
  27808. /**
  27809. * Creates a dynamic vertex buffer
  27810. * @param data the data for the dynamic vertex buffer
  27811. * @returns the new WebGL dynamic buffer
  27812. */
  27813. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27814. /**
  27815. * Update a dynamic index buffer
  27816. * @param indexBuffer defines the target index buffer
  27817. * @param indices defines the data to update
  27818. * @param offset defines the offset in the target index buffer where update should start
  27819. */
  27820. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27821. /**
  27822. * Updates a dynamic vertex buffer.
  27823. * @param vertexBuffer the vertex buffer to update
  27824. * @param data the data used to update the vertex buffer
  27825. * @param byteOffset the byte offset of the data
  27826. * @param byteLength the byte length of the data
  27827. */
  27828. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27829. private _resetIndexBufferBinding;
  27830. /**
  27831. * Creates a new index buffer
  27832. * @param indices defines the content of the index buffer
  27833. * @param updatable defines if the index buffer must be updatable
  27834. * @returns a new webGL buffer
  27835. */
  27836. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27837. /**
  27838. * Bind a webGL buffer to the webGL context
  27839. * @param buffer defines the buffer to bind
  27840. */
  27841. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27842. /**
  27843. * Bind an uniform buffer to the current webGL context
  27844. * @param buffer defines the buffer to bind
  27845. */
  27846. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27847. /**
  27848. * Bind a buffer to the current webGL context at a given location
  27849. * @param buffer defines the buffer to bind
  27850. * @param location defines the index where to bind the buffer
  27851. */
  27852. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27853. /**
  27854. * Bind a specific block at a given index in a specific shader program
  27855. * @param shaderProgram defines the shader program
  27856. * @param blockName defines the block name
  27857. * @param index defines the index where to bind the block
  27858. */
  27859. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27860. private bindIndexBuffer;
  27861. private bindBuffer;
  27862. /**
  27863. * update the bound buffer with the given data
  27864. * @param data defines the data to update
  27865. */
  27866. updateArrayBuffer(data: Float32Array): void;
  27867. private _vertexAttribPointer;
  27868. private _bindIndexBufferWithCache;
  27869. private _bindVertexBuffersAttributes;
  27870. /**
  27871. * Records a vertex array object
  27872. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27873. * @param vertexBuffers defines the list of vertex buffers to store
  27874. * @param indexBuffer defines the index buffer to store
  27875. * @param effect defines the effect to store
  27876. * @returns the new vertex array object
  27877. */
  27878. recordVertexArrayObject(vertexBuffers: {
  27879. [key: string]: VertexBuffer;
  27880. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27881. /**
  27882. * Bind a specific vertex array object
  27883. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27884. * @param vertexArrayObject defines the vertex array object to bind
  27885. * @param indexBuffer defines the index buffer to bind
  27886. */
  27887. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27888. /**
  27889. * Bind webGl buffers directly to the webGL context
  27890. * @param vertexBuffer defines the vertex buffer to bind
  27891. * @param indexBuffer defines the index buffer to bind
  27892. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27893. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27894. * @param effect defines the effect associated with the vertex buffer
  27895. */
  27896. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27897. private _unbindVertexArrayObject;
  27898. /**
  27899. * Bind a list of vertex buffers to the webGL context
  27900. * @param vertexBuffers defines the list of vertex buffers to bind
  27901. * @param indexBuffer defines the index buffer to bind
  27902. * @param effect defines the effect associated with the vertex buffers
  27903. */
  27904. bindBuffers(vertexBuffers: {
  27905. [key: string]: Nullable<VertexBuffer>;
  27906. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27907. /**
  27908. * Unbind all instance attributes
  27909. */
  27910. unbindInstanceAttributes(): void;
  27911. /**
  27912. * Release and free the memory of a vertex array object
  27913. * @param vao defines the vertex array object to delete
  27914. */
  27915. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27916. /** @hidden */
  27917. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27918. /**
  27919. * Creates a webGL buffer to use with instanciation
  27920. * @param capacity defines the size of the buffer
  27921. * @returns the webGL buffer
  27922. */
  27923. createInstancesBuffer(capacity: number): WebGLBuffer;
  27924. /**
  27925. * Delete a webGL buffer used with instanciation
  27926. * @param buffer defines the webGL buffer to delete
  27927. */
  27928. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27929. /**
  27930. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27931. * @param instancesBuffer defines the webGL buffer to update and bind
  27932. * @param data defines the data to store in the buffer
  27933. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27934. */
  27935. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27936. /**
  27937. * Apply all cached states (depth, culling, stencil and alpha)
  27938. */
  27939. applyStates(): void;
  27940. /**
  27941. * Send a draw order
  27942. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27943. * @param indexStart defines the starting index
  27944. * @param indexCount defines the number of index to draw
  27945. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27946. */
  27947. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27948. /**
  27949. * Draw a list of points
  27950. * @param verticesStart defines the index of first vertex to draw
  27951. * @param verticesCount defines the count of vertices to draw
  27952. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27953. */
  27954. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27955. /**
  27956. * Draw a list of unindexed primitives
  27957. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27958. * @param verticesStart defines the index of first vertex to draw
  27959. * @param verticesCount defines the count of vertices to draw
  27960. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27961. */
  27962. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27963. /**
  27964. * Draw a list of indexed primitives
  27965. * @param fillMode defines the primitive to use
  27966. * @param indexStart defines the starting index
  27967. * @param indexCount defines the number of index to draw
  27968. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27969. */
  27970. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27971. /**
  27972. * Draw a list of unindexed primitives
  27973. * @param fillMode defines the primitive to use
  27974. * @param verticesStart defines the index of first vertex to draw
  27975. * @param verticesCount defines the count of vertices to draw
  27976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27977. */
  27978. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27979. private _drawMode;
  27980. /** @hidden */
  27981. _releaseEffect(effect: Effect): void;
  27982. /** @hidden */
  27983. _deleteProgram(program: WebGLProgram): void;
  27984. /**
  27985. * Create a new effect (used to store vertex/fragment shaders)
  27986. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27987. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27988. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27989. * @param samplers defines an array of string used to represent textures
  27990. * @param defines defines the string containing the defines to use to compile the shaders
  27991. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27992. * @param onCompiled defines a function to call when the effect creation is successful
  27993. * @param onError defines a function to call when the effect creation has failed
  27994. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27995. * @returns the new Effect
  27996. */
  27997. 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;
  27998. private _compileShader;
  27999. private _compileRawShader;
  28000. /**
  28001. * Directly creates a webGL program
  28002. * @param vertexCode defines the vertex shader code to use
  28003. * @param fragmentCode defines the fragment shader code to use
  28004. * @param context defines the webGL context to use (if not set, the current one will be used)
  28005. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28006. * @returns the new webGL program
  28007. */
  28008. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28009. /**
  28010. * 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 defines defines the string containing the defines to use to compile the shaders
  28014. * @param context defines the webGL context to use (if not set, the current one will be used)
  28015. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28016. * @returns the new webGL program
  28017. */
  28018. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28019. private _createShaderProgram;
  28020. private _finalizeProgram;
  28021. /** @hidden */
  28022. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28023. /** @hidden */
  28024. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28025. /**
  28026. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28027. * @param shaderProgram defines the webGL program to use
  28028. * @param uniformsNames defines the list of uniform names
  28029. * @returns an array of webGL uniform locations
  28030. */
  28031. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28032. /**
  28033. * Gets the lsit of active attributes for a given webGL program
  28034. * @param shaderProgram defines the webGL program to use
  28035. * @param attributesNames defines the list of attribute names to get
  28036. * @returns an array of indices indicating the offset of each attribute
  28037. */
  28038. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28039. /**
  28040. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28041. * @param effect defines the effect to activate
  28042. */
  28043. enableEffect(effect: Nullable<Effect>): void;
  28044. /**
  28045. * Set the value of an uniform to an array of int32
  28046. * @param uniform defines the webGL uniform location where to store the value
  28047. * @param array defines the array of int32 to store
  28048. */
  28049. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28050. /**
  28051. * Set the value of an uniform to an array of int32 (stored as vec2)
  28052. * @param uniform defines the webGL uniform location where to store the value
  28053. * @param array defines the array of int32 to store
  28054. */
  28055. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28056. /**
  28057. * Set the value of an uniform to an array of int32 (stored as vec3)
  28058. * @param uniform defines the webGL uniform location where to store the value
  28059. * @param array defines the array of int32 to store
  28060. */
  28061. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28062. /**
  28063. * Set the value of an uniform to an array of int32 (stored as vec4)
  28064. * @param uniform defines the webGL uniform location where to store the value
  28065. * @param array defines the array of int32 to store
  28066. */
  28067. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28068. /**
  28069. * Set the value of an uniform to an array of float32
  28070. * @param uniform defines the webGL uniform location where to store the value
  28071. * @param array defines the array of float32 to store
  28072. */
  28073. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28074. /**
  28075. * Set the value of an uniform to an array of float32 (stored as vec2)
  28076. * @param uniform defines the webGL uniform location where to store the value
  28077. * @param array defines the array of float32 to store
  28078. */
  28079. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28080. /**
  28081. * Set the value of an uniform to an array of float32 (stored as vec3)
  28082. * @param uniform defines the webGL uniform location where to store the value
  28083. * @param array defines the array of float32 to store
  28084. */
  28085. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28086. /**
  28087. * Set the value of an uniform to an array of float32 (stored as vec4)
  28088. * @param uniform defines the webGL uniform location where to store the value
  28089. * @param array defines the array of float32 to store
  28090. */
  28091. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28092. /**
  28093. * Set the value of an uniform to an array of number
  28094. * @param uniform defines the webGL uniform location where to store the value
  28095. * @param array defines the array of number to store
  28096. */
  28097. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28098. /**
  28099. * Set the value of an uniform to an array of number (stored as vec2)
  28100. * @param uniform defines the webGL uniform location where to store the value
  28101. * @param array defines the array of number to store
  28102. */
  28103. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28104. /**
  28105. * Set the value of an uniform to an array of number (stored as vec3)
  28106. * @param uniform defines the webGL uniform location where to store the value
  28107. * @param array defines the array of number to store
  28108. */
  28109. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28110. /**
  28111. * Set the value of an uniform to an array of number (stored as vec4)
  28112. * @param uniform defines the webGL uniform location where to store the value
  28113. * @param array defines the array of number to store
  28114. */
  28115. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28116. /**
  28117. * Set the value of an uniform to an array of float32 (stored as matrices)
  28118. * @param uniform defines the webGL uniform location where to store the value
  28119. * @param matrices defines the array of float32 to store
  28120. */
  28121. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28122. /**
  28123. * Set the value of an uniform to a matrix
  28124. * @param uniform defines the webGL uniform location where to store the value
  28125. * @param matrix defines the matrix to store
  28126. */
  28127. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28128. /**
  28129. * Set the value of an uniform to a matrix (3x3)
  28130. * @param uniform defines the webGL uniform location where to store the value
  28131. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28132. */
  28133. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28134. /**
  28135. * Set the value of an uniform to a matrix (2x2)
  28136. * @param uniform defines the webGL uniform location where to store the value
  28137. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28138. */
  28139. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28140. /**
  28141. * Set the value of an uniform to a number (int)
  28142. * @param uniform defines the webGL uniform location where to store the value
  28143. * @param value defines the int number to store
  28144. */
  28145. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28146. /**
  28147. * Set the value of an uniform to a number (float)
  28148. * @param uniform defines the webGL uniform location where to store the value
  28149. * @param value defines the float number to store
  28150. */
  28151. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28152. /**
  28153. * Set the value of an uniform to a vec2
  28154. * @param uniform defines the webGL uniform location where to store the value
  28155. * @param x defines the 1st component of the value
  28156. * @param y defines the 2nd component of the value
  28157. */
  28158. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28159. /**
  28160. * Set the value of an uniform to a vec3
  28161. * @param uniform defines the webGL uniform location where to store the value
  28162. * @param x defines the 1st component of the value
  28163. * @param y defines the 2nd component of the value
  28164. * @param z defines the 3rd component of the value
  28165. */
  28166. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28167. /**
  28168. * Set the value of an uniform to a boolean
  28169. * @param uniform defines the webGL uniform location where to store the value
  28170. * @param bool defines the boolean to store
  28171. */
  28172. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28173. /**
  28174. * Set the value of an uniform to a vec4
  28175. * @param uniform defines the webGL uniform location where to store the value
  28176. * @param x defines the 1st component of the value
  28177. * @param y defines the 2nd component of the value
  28178. * @param z defines the 3rd component of the value
  28179. * @param w defines the 4th component of the value
  28180. */
  28181. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28182. /**
  28183. * Set the value of an uniform to a Color3
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param color3 defines the color to store
  28186. */
  28187. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28188. /**
  28189. * Set the value of an uniform to a Color3 and an alpha value
  28190. * @param uniform defines the webGL uniform location where to store the value
  28191. * @param color3 defines the color to store
  28192. * @param alpha defines the alpha component to store
  28193. */
  28194. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28195. /**
  28196. * Sets a Color4 on a uniform variable
  28197. * @param uniform defines the uniform location
  28198. * @param color4 defines the value to be set
  28199. */
  28200. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28201. /**
  28202. * Set various states to the webGL context
  28203. * @param culling defines backface culling state
  28204. * @param zOffset defines the value to apply to zOffset (0 by default)
  28205. * @param force defines if states must be applied even if cache is up to date
  28206. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28207. */
  28208. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28209. /**
  28210. * Set the z offset to apply to current rendering
  28211. * @param value defines the offset to apply
  28212. */
  28213. setZOffset(value: number): void;
  28214. /**
  28215. * Gets the current value of the zOffset
  28216. * @returns the current zOffset state
  28217. */
  28218. getZOffset(): number;
  28219. /**
  28220. * Enable or disable depth buffering
  28221. * @param enable defines the state to set
  28222. */
  28223. setDepthBuffer(enable: boolean): void;
  28224. /**
  28225. * Gets a boolean indicating if depth writing is enabled
  28226. * @returns the current depth writing state
  28227. */
  28228. getDepthWrite(): boolean;
  28229. /**
  28230. * Enable or disable depth writing
  28231. * @param enable defines the state to set
  28232. */
  28233. setDepthWrite(enable: boolean): void;
  28234. /**
  28235. * Enable or disable color writing
  28236. * @param enable defines the state to set
  28237. */
  28238. setColorWrite(enable: boolean): void;
  28239. /**
  28240. * Gets a boolean indicating if color writing is enabled
  28241. * @returns the current color writing state
  28242. */
  28243. getColorWrite(): boolean;
  28244. /**
  28245. * Sets alpha constants used by some alpha blending modes
  28246. * @param r defines the red component
  28247. * @param g defines the green component
  28248. * @param b defines the blue component
  28249. * @param a defines the alpha component
  28250. */
  28251. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28252. /**
  28253. * Sets the current alpha mode
  28254. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28255. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28256. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28257. */
  28258. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28259. /**
  28260. * Gets the current alpha mode
  28261. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28262. * @returns the current alpha mode
  28263. */
  28264. getAlphaMode(): number;
  28265. /**
  28266. * Clears the list of texture accessible through engine.
  28267. * This can help preventing texture load conflict due to name collision.
  28268. */
  28269. clearInternalTexturesCache(): void;
  28270. /**
  28271. * Force the entire cache to be cleared
  28272. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28273. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28274. */
  28275. wipeCaches(bruteForce?: boolean): void;
  28276. /**
  28277. * Set the compressed texture format to use, based on the formats you have, and the formats
  28278. * supported by the hardware / browser.
  28279. *
  28280. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28281. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28282. * to API arguments needed to compressed textures. This puts the burden on the container
  28283. * generator to house the arcane code for determining these for current & future formats.
  28284. *
  28285. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28286. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28287. *
  28288. * Note: The result of this call is not taken into account when a texture is base64.
  28289. *
  28290. * @param formatsAvailable defines the list of those format families you have created
  28291. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28292. *
  28293. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28294. * @returns The extension selected.
  28295. */
  28296. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28297. private _getSamplingParameters;
  28298. private _partialLoadImg;
  28299. private _cascadeLoadImgs;
  28300. /** @hidden */
  28301. _createTexture(): WebGLTexture;
  28302. /**
  28303. * Usually called from Texture.ts.
  28304. * Passed information to create a WebGLTexture
  28305. * @param urlArg defines a value which contains one of the following:
  28306. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28307. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28308. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28309. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28310. * @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)
  28311. * @param scene needed for loading to the correct scene
  28312. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28313. * @param onLoad optional callback to be called upon successful completion
  28314. * @param onError optional callback to be called upon failure
  28315. * @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
  28316. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28317. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28318. * @param forcedExtension defines the extension to use to pick the right loader
  28319. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28320. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28321. */
  28322. 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;
  28323. private _rescaleTexture;
  28324. /**
  28325. * Update a raw texture
  28326. * @param texture defines the texture to update
  28327. * @param data defines the data to store in the texture
  28328. * @param format defines the format of the data
  28329. * @param invertY defines if data must be stored with Y axis inverted
  28330. * @param compression defines the compression used (null by default)
  28331. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28332. */
  28333. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28334. /**
  28335. * Creates a raw texture
  28336. * @param data defines the data to store in the texture
  28337. * @param width defines the width of the texture
  28338. * @param height defines the height of the texture
  28339. * @param format defines the format of the data
  28340. * @param generateMipMaps defines if the engine should generate the mip levels
  28341. * @param invertY defines if data must be stored with Y axis inverted
  28342. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28343. * @param compression defines the compression used (null by default)
  28344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28345. * @returns the raw texture inside an InternalTexture
  28346. */
  28347. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28348. private _unpackFlipYCached;
  28349. /**
  28350. * In case you are sharing the context with other applications, it might
  28351. * be interested to not cache the unpack flip y state to ensure a consistent
  28352. * value would be set.
  28353. */
  28354. enableUnpackFlipYCached: boolean;
  28355. /** @hidden */
  28356. _unpackFlipY(value: boolean): void;
  28357. /** @hidden */
  28358. _getUnpackAlignement(): number;
  28359. /**
  28360. * Creates a dynamic texture
  28361. * @param width defines the width of the texture
  28362. * @param height defines the height of the texture
  28363. * @param generateMipMaps defines if the engine should generate the mip levels
  28364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28365. * @returns the dynamic texture inside an InternalTexture
  28366. */
  28367. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28368. /**
  28369. * Update the sampling mode of a given texture
  28370. * @param samplingMode defines the required sampling mode
  28371. * @param texture defines the texture to update
  28372. */
  28373. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28374. /**
  28375. * Update the content of a dynamic texture
  28376. * @param texture defines the texture to update
  28377. * @param canvas defines the canvas containing the source
  28378. * @param invertY defines if data must be stored with Y axis inverted
  28379. * @param premulAlpha defines if alpha is stored as premultiplied
  28380. * @param format defines the format of the data
  28381. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28382. */
  28383. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28384. /**
  28385. * Update a video texture
  28386. * @param texture defines the texture to update
  28387. * @param video defines the video element to use
  28388. * @param invertY defines if data must be stored with Y axis inverted
  28389. */
  28390. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28391. /**
  28392. * Updates a depth texture Comparison Mode and Function.
  28393. * If the comparison Function is equal to 0, the mode will be set to none.
  28394. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28395. * @param texture The texture to set the comparison function for
  28396. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28397. */
  28398. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28399. private _setupDepthStencilTexture;
  28400. /**
  28401. * Creates a depth stencil texture.
  28402. * This is only available in WebGL 2 or with the depth texture extension available.
  28403. * @param size The size of face edge in the texture.
  28404. * @param options The options defining the texture.
  28405. * @returns The texture
  28406. */
  28407. createDepthStencilTexture(size: number | {
  28408. width: number;
  28409. height: number;
  28410. }, options: DepthTextureCreationOptions): InternalTexture;
  28411. /**
  28412. * Creates a depth stencil texture.
  28413. * This is only available in WebGL 2 or with the depth texture extension available.
  28414. * @param size The size of face edge in the texture.
  28415. * @param options The options defining the texture.
  28416. * @returns The texture
  28417. */
  28418. private _createDepthStencilTexture;
  28419. /**
  28420. * Creates a depth stencil cube texture.
  28421. * This is only available in WebGL 2.
  28422. * @param size The size of face edge in the cube texture.
  28423. * @param options The options defining the cube texture.
  28424. * @returns The cube texture
  28425. */
  28426. private _createDepthStencilCubeTexture;
  28427. /**
  28428. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28429. * @param renderTarget The render target to set the frame buffer for
  28430. */
  28431. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28432. /**
  28433. * Creates a new render target texture
  28434. * @param size defines the size of the texture
  28435. * @param options defines the options used to create the texture
  28436. * @returns a new render target texture stored in an InternalTexture
  28437. */
  28438. createRenderTargetTexture(size: number | {
  28439. width: number;
  28440. height: number;
  28441. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28442. /**
  28443. * Create a multi render target texture
  28444. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28445. * @param size defines the size of the texture
  28446. * @param options defines the creation options
  28447. * @returns the cube texture as an InternalTexture
  28448. */
  28449. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28450. private _setupFramebufferDepthAttachments;
  28451. /**
  28452. * Updates the sample count of a render target texture
  28453. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28454. * @param texture defines the texture to update
  28455. * @param samples defines the sample count to set
  28456. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28457. */
  28458. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28459. /**
  28460. * Update the sample count for a given multiple render target texture
  28461. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28462. * @param textures defines the textures to update
  28463. * @param samples defines the sample count to set
  28464. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28465. */
  28466. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28467. /** @hidden */
  28468. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28469. /** @hidden */
  28470. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28471. /** @hidden */
  28472. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28473. /** @hidden */
  28474. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28475. /**
  28476. * Creates a new render target cube texture
  28477. * @param size defines the size of the texture
  28478. * @param options defines the options used to create the texture
  28479. * @returns a new render target cube texture stored in an InternalTexture
  28480. */
  28481. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28482. /**
  28483. * Creates a cube texture
  28484. * @param rootUrl defines the url where the files to load is located
  28485. * @param scene defines the current scene
  28486. * @param files defines the list of files to load (1 per face)
  28487. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28488. * @param onLoad defines an optional callback raised when the texture is loaded
  28489. * @param onError defines an optional callback raised if there is an issue to load the texture
  28490. * @param format defines the format of the data
  28491. * @param forcedExtension defines the extension to use to pick the right loader
  28492. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28495. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28496. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28497. * @returns the cube texture as an InternalTexture
  28498. */
  28499. 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;
  28500. /**
  28501. * @hidden
  28502. */
  28503. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28504. /**
  28505. * Update a raw cube texture
  28506. * @param texture defines the texture to udpdate
  28507. * @param data defines the data to store
  28508. * @param format defines the data format
  28509. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28510. * @param invertY defines if data must be stored with Y axis inverted
  28511. * @param compression defines the compression used (null by default)
  28512. * @param level defines which level of the texture to update
  28513. */
  28514. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28515. /**
  28516. * Creates a new raw cube texture
  28517. * @param data defines the array of data to use to create each face
  28518. * @param size defines the size of the textures
  28519. * @param format defines the format of the data
  28520. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28521. * @param generateMipMaps defines if the engine should generate the mip levels
  28522. * @param invertY defines if data must be stored with Y axis inverted
  28523. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28524. * @param compression defines the compression used (null by default)
  28525. * @returns the cube texture as an InternalTexture
  28526. */
  28527. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28528. /**
  28529. * Creates a new raw cube texture from a specified url
  28530. * @param url defines the url where the data is located
  28531. * @param scene defines the current scene
  28532. * @param size defines the size of the textures
  28533. * @param format defines the format of the data
  28534. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28535. * @param noMipmap defines if the engine should avoid generating the mip levels
  28536. * @param callback defines a callback used to extract texture data from loaded data
  28537. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28538. * @param onLoad defines a callback called when texture is loaded
  28539. * @param onError defines a callback called if there is an error
  28540. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28541. * @param invertY defines if data must be stored with Y axis inverted
  28542. * @returns the cube texture as an InternalTexture
  28543. */
  28544. 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;
  28545. /**
  28546. * Update a raw 3D texture
  28547. * @param texture defines the texture to update
  28548. * @param data defines the data to store
  28549. * @param format defines the data format
  28550. * @param invertY defines if data must be stored with Y axis inverted
  28551. * @param compression defines the used compression (can be null)
  28552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28553. */
  28554. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28555. /**
  28556. * Creates a new raw 3D texture
  28557. * @param data defines the data used to create the texture
  28558. * @param width defines the width of the texture
  28559. * @param height defines the height of the texture
  28560. * @param depth defines the depth of the texture
  28561. * @param format defines the format of the texture
  28562. * @param generateMipMaps defines if the engine must generate mip levels
  28563. * @param invertY defines if data must be stored with Y axis inverted
  28564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28565. * @param compression defines the compressed used (can be null)
  28566. * @param textureType defines the compressed used (can be null)
  28567. * @returns a new raw 3D texture (stored in an InternalTexture)
  28568. */
  28569. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28570. private _prepareWebGLTextureContinuation;
  28571. private _prepareWebGLTexture;
  28572. private _convertRGBtoRGBATextureData;
  28573. /** @hidden */
  28574. _releaseFramebufferObjects(texture: InternalTexture): void;
  28575. /** @hidden */
  28576. _releaseTexture(texture: InternalTexture): void;
  28577. private setProgram;
  28578. private _boundUniforms;
  28579. /**
  28580. * Binds an effect to the webGL context
  28581. * @param effect defines the effect to bind
  28582. */
  28583. bindSamplers(effect: Effect): void;
  28584. private _moveBoundTextureOnTop;
  28585. private _getCorrectTextureChannel;
  28586. private _linkTrackers;
  28587. private _removeDesignatedSlot;
  28588. private _activateCurrentTexture;
  28589. /** @hidden */
  28590. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28591. /** @hidden */
  28592. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28593. /**
  28594. * Sets a texture to the webGL context from a postprocess
  28595. * @param channel defines the channel to use
  28596. * @param postProcess defines the source postprocess
  28597. */
  28598. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28599. /**
  28600. * Binds the output of the passed in post process to the texture channel specified
  28601. * @param channel The channel the texture should be bound to
  28602. * @param postProcess The post process which's output should be bound
  28603. */
  28604. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28605. /**
  28606. * Unbind all textures from the webGL context
  28607. */
  28608. unbindAllTextures(): void;
  28609. /**
  28610. * Sets a texture to the according uniform.
  28611. * @param channel The texture channel
  28612. * @param uniform The uniform to set
  28613. * @param texture The texture to apply
  28614. */
  28615. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28616. /**
  28617. * Sets a depth stencil texture from a render target to the according uniform.
  28618. * @param channel The texture channel
  28619. * @param uniform The uniform to set
  28620. * @param texture The render target texture containing the depth stencil texture to apply
  28621. */
  28622. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28623. private _bindSamplerUniformToChannel;
  28624. private _getTextureWrapMode;
  28625. private _setTexture;
  28626. /**
  28627. * Sets an array of texture to the webGL context
  28628. * @param channel defines the channel where the texture array must be set
  28629. * @param uniform defines the associated uniform location
  28630. * @param textures defines the array of textures to bind
  28631. */
  28632. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28633. /** @hidden */
  28634. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28635. private _setTextureParameterFloat;
  28636. private _setTextureParameterInteger;
  28637. /**
  28638. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28639. * @param x defines the x coordinate of the rectangle where pixels must be read
  28640. * @param y defines the y coordinate of the rectangle where pixels must be read
  28641. * @param width defines the width of the rectangle where pixels must be read
  28642. * @param height defines the height of the rectangle where pixels must be read
  28643. * @returns a Uint8Array containing RGBA colors
  28644. */
  28645. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28646. /**
  28647. * Add an externaly attached data from its key.
  28648. * This method call will fail and return false, if such key already exists.
  28649. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28650. * @param key the unique key that identifies the data
  28651. * @param data the data object to associate to the key for this Engine instance
  28652. * @return true if no such key were already present and the data was added successfully, false otherwise
  28653. */
  28654. addExternalData<T>(key: string, data: T): boolean;
  28655. /**
  28656. * Get an externaly attached data from its key
  28657. * @param key the unique key that identifies the data
  28658. * @return the associated data, if present (can be null), or undefined if not present
  28659. */
  28660. getExternalData<T>(key: string): T;
  28661. /**
  28662. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28663. * @param key the unique key that identifies the data
  28664. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28665. * @return the associated data, can be null if the factory returned null.
  28666. */
  28667. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28668. /**
  28669. * Remove an externaly attached data from the Engine instance
  28670. * @param key the unique key that identifies the data
  28671. * @return true if the data was successfully removed, false if it doesn't exist
  28672. */
  28673. removeExternalData(key: string): boolean;
  28674. /**
  28675. * Unbind all vertex attributes from the webGL context
  28676. */
  28677. unbindAllAttributes(): void;
  28678. /**
  28679. * 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
  28680. */
  28681. releaseEffects(): void;
  28682. /**
  28683. * Dispose and release all associated resources
  28684. */
  28685. dispose(): void;
  28686. /**
  28687. * Display the loading screen
  28688. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28689. */
  28690. displayLoadingUI(): void;
  28691. /**
  28692. * Hide the loading screen
  28693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28694. */
  28695. hideLoadingUI(): void;
  28696. /**
  28697. * Gets the current loading screen object
  28698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28699. */
  28700. /**
  28701. * Sets the current loading screen object
  28702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28703. */
  28704. loadingScreen: ILoadingScreen;
  28705. /**
  28706. * Sets the current loading screen text
  28707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28708. */
  28709. loadingUIText: string;
  28710. /**
  28711. * Sets the current loading screen background color
  28712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28713. */
  28714. loadingUIBackgroundColor: string;
  28715. /**
  28716. * Attach a new callback raised when context lost event is fired
  28717. * @param callback defines the callback to call
  28718. */
  28719. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28720. /**
  28721. * Attach a new callback raised when context restored event is fired
  28722. * @param callback defines the callback to call
  28723. */
  28724. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28725. /**
  28726. * Gets the source code of the vertex shader associated with a specific webGL program
  28727. * @param program defines the program to use
  28728. * @returns a string containing the source code of the vertex shader associated with the program
  28729. */
  28730. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28731. /**
  28732. * Gets the source code of the fragment shader associated with a specific webGL program
  28733. * @param program defines the program to use
  28734. * @returns a string containing the source code of the fragment shader associated with the program
  28735. */
  28736. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28737. /**
  28738. * Get the current error code of the webGL context
  28739. * @returns the error code
  28740. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28741. */
  28742. getError(): number;
  28743. /**
  28744. * Gets the current framerate
  28745. * @returns a number representing the framerate
  28746. */
  28747. getFps(): number;
  28748. /**
  28749. * Gets the time spent between current and previous frame
  28750. * @returns a number representing the delta time in ms
  28751. */
  28752. getDeltaTime(): number;
  28753. private _measureFps;
  28754. /** @hidden */
  28755. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28756. private _canRenderToFloatFramebuffer;
  28757. private _canRenderToHalfFloatFramebuffer;
  28758. private _canRenderToFramebuffer;
  28759. /** @hidden */
  28760. _getWebGLTextureType(type: number): number;
  28761. private _getInternalFormat;
  28762. /** @hidden */
  28763. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28764. /** @hidden */
  28765. _getRGBAMultiSampleBufferFormat(type: number): number;
  28766. /** @hidden */
  28767. _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;
  28768. /** @hidden */
  28769. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28770. private _partialLoadFile;
  28771. private _cascadeLoadFiles;
  28772. /**
  28773. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28774. * @returns true if the engine can be created
  28775. * @ignorenaming
  28776. */
  28777. static isSupported(): boolean;
  28778. }
  28779. }
  28780. declare module "babylonjs/Materials/effect" {
  28781. import { Observable } from "babylonjs/Misc/observable";
  28782. import { Nullable } from "babylonjs/types";
  28783. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28784. import { Engine } from "babylonjs/Engines/engine";
  28785. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28787. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28790. /**
  28791. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28792. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28793. */
  28794. export class EffectFallbacks {
  28795. private _defines;
  28796. private _currentRank;
  28797. private _maxRank;
  28798. private _mesh;
  28799. /**
  28800. * Removes the fallback from the bound mesh.
  28801. */
  28802. unBindMesh(): void;
  28803. /**
  28804. * Adds a fallback on the specified property.
  28805. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28806. * @param define The name of the define in the shader
  28807. */
  28808. addFallback(rank: number, define: string): void;
  28809. /**
  28810. * Sets the mesh to use CPU skinning when needing to fallback.
  28811. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28812. * @param mesh The mesh to use the fallbacks.
  28813. */
  28814. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28815. /**
  28816. * Checks to see if more fallbacks are still availible.
  28817. */
  28818. readonly isMoreFallbacks: boolean;
  28819. /**
  28820. * Removes the defines that shoould be removed when falling back.
  28821. * @param currentDefines defines the current define statements for the shader.
  28822. * @param effect defines the current effect we try to compile
  28823. * @returns The resulting defines with defines of the current rank removed.
  28824. */
  28825. reduce(currentDefines: string, effect: Effect): string;
  28826. }
  28827. /**
  28828. * Options to be used when creating an effect.
  28829. */
  28830. export class EffectCreationOptions {
  28831. /**
  28832. * Atrributes that will be used in the shader.
  28833. */
  28834. attributes: string[];
  28835. /**
  28836. * Uniform varible names that will be set in the shader.
  28837. */
  28838. uniformsNames: string[];
  28839. /**
  28840. * Uniform buffer varible names that will be set in the shader.
  28841. */
  28842. uniformBuffersNames: string[];
  28843. /**
  28844. * Sampler texture variable names that will be set in the shader.
  28845. */
  28846. samplers: string[];
  28847. /**
  28848. * Define statements that will be set in the shader.
  28849. */
  28850. defines: any;
  28851. /**
  28852. * Possible fallbacks for this effect to improve performance when needed.
  28853. */
  28854. fallbacks: Nullable<EffectFallbacks>;
  28855. /**
  28856. * Callback that will be called when the shader is compiled.
  28857. */
  28858. onCompiled: Nullable<(effect: Effect) => void>;
  28859. /**
  28860. * Callback that will be called if an error occurs during shader compilation.
  28861. */
  28862. onError: Nullable<(effect: Effect, errors: string) => void>;
  28863. /**
  28864. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28865. */
  28866. indexParameters: any;
  28867. /**
  28868. * Max number of lights that can be used in the shader.
  28869. */
  28870. maxSimultaneousLights: number;
  28871. /**
  28872. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28873. */
  28874. transformFeedbackVaryings: Nullable<string[]>;
  28875. }
  28876. /**
  28877. * Effect containing vertex and fragment shader that can be executed on an object.
  28878. */
  28879. export class Effect {
  28880. /**
  28881. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28882. */
  28883. static ShadersRepository: string;
  28884. /**
  28885. * Name of the effect.
  28886. */
  28887. name: any;
  28888. /**
  28889. * String container all the define statements that should be set on the shader.
  28890. */
  28891. defines: string;
  28892. /**
  28893. * Callback that will be called when the shader is compiled.
  28894. */
  28895. onCompiled: Nullable<(effect: Effect) => void>;
  28896. /**
  28897. * Callback that will be called if an error occurs during shader compilation.
  28898. */
  28899. onError: Nullable<(effect: Effect, errors: string) => void>;
  28900. /**
  28901. * Callback that will be called when effect is bound.
  28902. */
  28903. onBind: Nullable<(effect: Effect) => void>;
  28904. /**
  28905. * Unique ID of the effect.
  28906. */
  28907. uniqueId: number;
  28908. /**
  28909. * Observable that will be called when the shader is compiled.
  28910. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28911. */
  28912. onCompileObservable: Observable<Effect>;
  28913. /**
  28914. * Observable that will be called if an error occurs during shader compilation.
  28915. */
  28916. onErrorObservable: Observable<Effect>;
  28917. /** @hidden */
  28918. _onBindObservable: Nullable<Observable<Effect>>;
  28919. /**
  28920. * Observable that will be called when effect is bound.
  28921. */
  28922. readonly onBindObservable: Observable<Effect>;
  28923. /** @hidden */
  28924. _bonesComputationForcedToCPU: boolean;
  28925. private static _uniqueIdSeed;
  28926. private _engine;
  28927. private _uniformBuffersNames;
  28928. private _uniformsNames;
  28929. private _samplers;
  28930. private _isReady;
  28931. private _compilationError;
  28932. private _attributesNames;
  28933. private _attributes;
  28934. private _uniforms;
  28935. /**
  28936. * Key for the effect.
  28937. * @hidden
  28938. */
  28939. _key: string;
  28940. private _indexParameters;
  28941. private _fallbacks;
  28942. private _vertexSourceCode;
  28943. private _fragmentSourceCode;
  28944. private _vertexSourceCodeOverride;
  28945. private _fragmentSourceCodeOverride;
  28946. private _transformFeedbackVaryings;
  28947. /**
  28948. * Compiled shader to webGL program.
  28949. * @hidden
  28950. */
  28951. _program: WebGLProgram;
  28952. private _valueCache;
  28953. private static _baseCache;
  28954. /**
  28955. * Instantiates an effect.
  28956. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28957. * @param baseName Name of the effect.
  28958. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28959. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28960. * @param samplers List of sampler variables that will be passed to the shader.
  28961. * @param engine Engine to be used to render the effect
  28962. * @param defines Define statements to be added to the shader.
  28963. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28964. * @param onCompiled Callback that will be called when the shader is compiled.
  28965. * @param onError Callback that will be called if an error occurs during shader compilation.
  28966. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28967. */
  28968. 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);
  28969. /**
  28970. * Unique key for this effect
  28971. */
  28972. readonly key: string;
  28973. /**
  28974. * If the effect has been compiled and prepared.
  28975. * @returns if the effect is compiled and prepared.
  28976. */
  28977. isReady(): boolean;
  28978. /**
  28979. * The engine the effect was initialized with.
  28980. * @returns the engine.
  28981. */
  28982. getEngine(): Engine;
  28983. /**
  28984. * The compiled webGL program for the effect
  28985. * @returns the webGL program.
  28986. */
  28987. getProgram(): WebGLProgram;
  28988. /**
  28989. * The set of names of attribute variables for the shader.
  28990. * @returns An array of attribute names.
  28991. */
  28992. getAttributesNames(): string[];
  28993. /**
  28994. * Returns the attribute at the given index.
  28995. * @param index The index of the attribute.
  28996. * @returns The location of the attribute.
  28997. */
  28998. getAttributeLocation(index: number): number;
  28999. /**
  29000. * Returns the attribute based on the name of the variable.
  29001. * @param name of the attribute to look up.
  29002. * @returns the attribute location.
  29003. */
  29004. getAttributeLocationByName(name: string): number;
  29005. /**
  29006. * The number of attributes.
  29007. * @returns the numnber of attributes.
  29008. */
  29009. getAttributesCount(): number;
  29010. /**
  29011. * Gets the index of a uniform variable.
  29012. * @param uniformName of the uniform to look up.
  29013. * @returns the index.
  29014. */
  29015. getUniformIndex(uniformName: string): number;
  29016. /**
  29017. * Returns the attribute based on the name of the variable.
  29018. * @param uniformName of the uniform to look up.
  29019. * @returns the location of the uniform.
  29020. */
  29021. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29022. /**
  29023. * Returns an array of sampler variable names
  29024. * @returns The array of sampler variable neames.
  29025. */
  29026. getSamplers(): string[];
  29027. /**
  29028. * The error from the last compilation.
  29029. * @returns the error string.
  29030. */
  29031. getCompilationError(): string;
  29032. /**
  29033. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29034. * @param func The callback to be used.
  29035. */
  29036. executeWhenCompiled(func: (effect: Effect) => void): void;
  29037. private _checkIsReady;
  29038. /** @hidden */
  29039. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29040. /** @hidden */
  29041. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29042. /** @hidden */
  29043. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29044. private _processShaderConversion;
  29045. private _processIncludes;
  29046. private _processPrecision;
  29047. /**
  29048. * Recompiles the webGL program
  29049. * @param vertexSourceCode The source code for the vertex shader.
  29050. * @param fragmentSourceCode The source code for the fragment shader.
  29051. * @param onCompiled Callback called when completed.
  29052. * @param onError Callback called on error.
  29053. * @hidden
  29054. */
  29055. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29056. /**
  29057. * Gets the uniform locations of the the specified variable names
  29058. * @param names THe names of the variables to lookup.
  29059. * @returns Array of locations in the same order as variable names.
  29060. */
  29061. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29062. /**
  29063. * Prepares the effect
  29064. * @hidden
  29065. */
  29066. _prepareEffect(): void;
  29067. /**
  29068. * Checks if the effect is supported. (Must be called after compilation)
  29069. */
  29070. readonly isSupported: boolean;
  29071. /**
  29072. * Binds a texture to the engine to be used as output of the shader.
  29073. * @param channel Name of the output variable.
  29074. * @param texture Texture to bind.
  29075. * @hidden
  29076. */
  29077. _bindTexture(channel: string, texture: InternalTexture): void;
  29078. /**
  29079. * Sets a texture on the engine to be used in the shader.
  29080. * @param channel Name of the sampler variable.
  29081. * @param texture Texture to set.
  29082. */
  29083. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29084. /**
  29085. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29086. * @param channel Name of the sampler variable.
  29087. * @param texture Texture to set.
  29088. */
  29089. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29090. /**
  29091. * Sets an array of textures on the engine to be used in the shader.
  29092. * @param channel Name of the variable.
  29093. * @param textures Textures to set.
  29094. */
  29095. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29096. /**
  29097. * 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)
  29098. * @param channel Name of the sampler variable.
  29099. * @param postProcess Post process to get the input texture from.
  29100. */
  29101. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29102. /**
  29103. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29104. * 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)
  29105. * @param channel Name of the sampler variable.
  29106. * @param postProcess Post process to get the output texture from.
  29107. */
  29108. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29109. /** @hidden */
  29110. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29111. /** @hidden */
  29112. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29113. /** @hidden */
  29114. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29115. /** @hidden */
  29116. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29117. /**
  29118. * Binds a buffer to a uniform.
  29119. * @param buffer Buffer to bind.
  29120. * @param name Name of the uniform variable to bind to.
  29121. */
  29122. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29123. /**
  29124. * Binds block to a uniform.
  29125. * @param blockName Name of the block to bind.
  29126. * @param index Index to bind.
  29127. */
  29128. bindUniformBlock(blockName: string, index: number): void;
  29129. /**
  29130. * Sets an interger value on a uniform variable.
  29131. * @param uniformName Name of the variable.
  29132. * @param value Value to be set.
  29133. * @returns this effect.
  29134. */
  29135. setInt(uniformName: string, value: number): Effect;
  29136. /**
  29137. * Sets an int array on a uniform variable.
  29138. * @param uniformName Name of the variable.
  29139. * @param array array to be set.
  29140. * @returns this effect.
  29141. */
  29142. setIntArray(uniformName: string, array: Int32Array): Effect;
  29143. /**
  29144. * 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)
  29145. * @param uniformName Name of the variable.
  29146. * @param array array to be set.
  29147. * @returns this effect.
  29148. */
  29149. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29150. /**
  29151. * 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)
  29152. * @param uniformName Name of the variable.
  29153. * @param array array to be set.
  29154. * @returns this effect.
  29155. */
  29156. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29157. /**
  29158. * 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)
  29159. * @param uniformName Name of the variable.
  29160. * @param array array to be set.
  29161. * @returns this effect.
  29162. */
  29163. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29164. /**
  29165. * Sets an float array on a uniform variable.
  29166. * @param uniformName Name of the variable.
  29167. * @param array array to be set.
  29168. * @returns this effect.
  29169. */
  29170. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29171. /**
  29172. * 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)
  29173. * @param uniformName Name of the variable.
  29174. * @param array array to be set.
  29175. * @returns this effect.
  29176. */
  29177. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29178. /**
  29179. * 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)
  29180. * @param uniformName Name of the variable.
  29181. * @param array array to be set.
  29182. * @returns this effect.
  29183. */
  29184. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29185. /**
  29186. * 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)
  29187. * @param uniformName Name of the variable.
  29188. * @param array array to be set.
  29189. * @returns this effect.
  29190. */
  29191. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29192. /**
  29193. * Sets an array on a uniform variable.
  29194. * @param uniformName Name of the variable.
  29195. * @param array array to be set.
  29196. * @returns this effect.
  29197. */
  29198. setArray(uniformName: string, array: number[]): Effect;
  29199. /**
  29200. * 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)
  29201. * @param uniformName Name of the variable.
  29202. * @param array array to be set.
  29203. * @returns this effect.
  29204. */
  29205. setArray2(uniformName: string, array: number[]): Effect;
  29206. /**
  29207. * 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)
  29208. * @param uniformName Name of the variable.
  29209. * @param array array to be set.
  29210. * @returns this effect.
  29211. */
  29212. setArray3(uniformName: string, array: number[]): Effect;
  29213. /**
  29214. * 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)
  29215. * @param uniformName Name of the variable.
  29216. * @param array array to be set.
  29217. * @returns this effect.
  29218. */
  29219. setArray4(uniformName: string, array: number[]): Effect;
  29220. /**
  29221. * Sets matrices on a uniform variable.
  29222. * @param uniformName Name of the variable.
  29223. * @param matrices matrices to be set.
  29224. * @returns this effect.
  29225. */
  29226. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29227. /**
  29228. * Sets matrix on a uniform variable.
  29229. * @param uniformName Name of the variable.
  29230. * @param matrix matrix to be set.
  29231. * @returns this effect.
  29232. */
  29233. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29234. /**
  29235. * 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)
  29236. * @param uniformName Name of the variable.
  29237. * @param matrix matrix to be set.
  29238. * @returns this effect.
  29239. */
  29240. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29241. /**
  29242. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29243. * @param uniformName Name of the variable.
  29244. * @param matrix matrix to be set.
  29245. * @returns this effect.
  29246. */
  29247. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29248. /**
  29249. * Sets a float on a uniform variable.
  29250. * @param uniformName Name of the variable.
  29251. * @param value value to be set.
  29252. * @returns this effect.
  29253. */
  29254. setFloat(uniformName: string, value: number): Effect;
  29255. /**
  29256. * Sets a boolean on a uniform variable.
  29257. * @param uniformName Name of the variable.
  29258. * @param bool value to be set.
  29259. * @returns this effect.
  29260. */
  29261. setBool(uniformName: string, bool: boolean): Effect;
  29262. /**
  29263. * Sets a Vector2 on a uniform variable.
  29264. * @param uniformName Name of the variable.
  29265. * @param vector2 vector2 to be set.
  29266. * @returns this effect.
  29267. */
  29268. setVector2(uniformName: string, vector2: Vector2): Effect;
  29269. /**
  29270. * Sets a float2 on a uniform variable.
  29271. * @param uniformName Name of the variable.
  29272. * @param x First float in float2.
  29273. * @param y Second float in float2.
  29274. * @returns this effect.
  29275. */
  29276. setFloat2(uniformName: string, x: number, y: number): Effect;
  29277. /**
  29278. * Sets a Vector3 on a uniform variable.
  29279. * @param uniformName Name of the variable.
  29280. * @param vector3 Value to be set.
  29281. * @returns this effect.
  29282. */
  29283. setVector3(uniformName: string, vector3: Vector3): Effect;
  29284. /**
  29285. * Sets a float3 on a uniform variable.
  29286. * @param uniformName Name of the variable.
  29287. * @param x First float in float3.
  29288. * @param y Second float in float3.
  29289. * @param z Third float in float3.
  29290. * @returns this effect.
  29291. */
  29292. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29293. /**
  29294. * Sets a Vector4 on a uniform variable.
  29295. * @param uniformName Name of the variable.
  29296. * @param vector4 Value to be set.
  29297. * @returns this effect.
  29298. */
  29299. setVector4(uniformName: string, vector4: Vector4): Effect;
  29300. /**
  29301. * Sets a float4 on a uniform variable.
  29302. * @param uniformName Name of the variable.
  29303. * @param x First float in float4.
  29304. * @param y Second float in float4.
  29305. * @param z Third float in float4.
  29306. * @param w Fourth float in float4.
  29307. * @returns this effect.
  29308. */
  29309. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29310. /**
  29311. * Sets a Color3 on a uniform variable.
  29312. * @param uniformName Name of the variable.
  29313. * @param color3 Value to be set.
  29314. * @returns this effect.
  29315. */
  29316. setColor3(uniformName: string, color3: Color3): Effect;
  29317. /**
  29318. * Sets a Color4 on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param color3 Value to be set.
  29321. * @param alpha Alpha value to be set.
  29322. * @returns this effect.
  29323. */
  29324. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29325. /**
  29326. * Sets a Color4 on a uniform variable
  29327. * @param uniformName defines the name of the variable
  29328. * @param color4 defines the value to be set
  29329. * @returns this effect.
  29330. */
  29331. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29332. /**
  29333. * This function will add a new shader to the shader store
  29334. * @param name the name of the shader
  29335. * @param pixelShader optional pixel shader content
  29336. * @param vertexShader optional vertex shader content
  29337. */
  29338. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29339. /**
  29340. * Store of each shader (The can be looked up using effect.key)
  29341. */
  29342. static ShadersStore: {
  29343. [key: string]: string;
  29344. };
  29345. /**
  29346. * Store of each included file for a shader (The can be looked up using effect.key)
  29347. */
  29348. static IncludesShadersStore: {
  29349. [key: string]: string;
  29350. };
  29351. /**
  29352. * Resets the cache of effects.
  29353. */
  29354. static ResetCache(): void;
  29355. }
  29356. }
  29357. declare module "babylonjs/Materials/colorCurves" {
  29358. import { Effect } from "babylonjs/Materials/effect";
  29359. /**
  29360. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29361. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29362. * 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;
  29363. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29364. */
  29365. export class ColorCurves {
  29366. private _dirty;
  29367. private _tempColor;
  29368. private _globalCurve;
  29369. private _highlightsCurve;
  29370. private _midtonesCurve;
  29371. private _shadowsCurve;
  29372. private _positiveCurve;
  29373. private _negativeCurve;
  29374. private _globalHue;
  29375. private _globalDensity;
  29376. private _globalSaturation;
  29377. private _globalExposure;
  29378. /**
  29379. * Gets the global Hue value.
  29380. * 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).
  29381. */
  29382. /**
  29383. * Sets the global Hue value.
  29384. * 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).
  29385. */
  29386. globalHue: number;
  29387. /**
  29388. * Gets the global Density value.
  29389. * 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.
  29390. * Values less than zero provide a filter of opposite hue.
  29391. */
  29392. /**
  29393. * Sets the global Density value.
  29394. * 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.
  29395. * Values less than zero provide a filter of opposite hue.
  29396. */
  29397. globalDensity: number;
  29398. /**
  29399. * Gets the global Saturation value.
  29400. * 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.
  29401. */
  29402. /**
  29403. * Sets the global Saturation value.
  29404. * 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.
  29405. */
  29406. globalSaturation: number;
  29407. /**
  29408. * Gets the global Exposure 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 exposure and negative values decrease exposure.
  29410. */
  29411. /**
  29412. * Sets the global Exposure 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 exposure and negative values decrease exposure.
  29414. */
  29415. globalExposure: number;
  29416. private _highlightsHue;
  29417. private _highlightsDensity;
  29418. private _highlightsSaturation;
  29419. private _highlightsExposure;
  29420. /**
  29421. * Gets the highlights Hue value.
  29422. * 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).
  29423. */
  29424. /**
  29425. * Sets the highlights Hue value.
  29426. * 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).
  29427. */
  29428. highlightsHue: number;
  29429. /**
  29430. * Gets the highlights Density value.
  29431. * 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.
  29432. * Values less than zero provide a filter of opposite hue.
  29433. */
  29434. /**
  29435. * Sets the highlights Density value.
  29436. * 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.
  29437. * Values less than zero provide a filter of opposite hue.
  29438. */
  29439. highlightsDensity: number;
  29440. /**
  29441. * Gets the highlights Saturation value.
  29442. * 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.
  29443. */
  29444. /**
  29445. * Sets the highlights Saturation value.
  29446. * 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.
  29447. */
  29448. highlightsSaturation: number;
  29449. /**
  29450. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  29452. */
  29453. /**
  29454. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  29456. */
  29457. highlightsExposure: number;
  29458. private _midtonesHue;
  29459. private _midtonesDensity;
  29460. private _midtonesSaturation;
  29461. private _midtonesExposure;
  29462. /**
  29463. * Gets the midtones Hue value.
  29464. * 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).
  29465. */
  29466. /**
  29467. * Sets the midtones Hue value.
  29468. * 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).
  29469. */
  29470. midtonesHue: number;
  29471. /**
  29472. * Gets the midtones Density value.
  29473. * 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.
  29474. * Values less than zero provide a filter of opposite hue.
  29475. */
  29476. /**
  29477. * Sets the midtones Density value.
  29478. * 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.
  29479. * Values less than zero provide a filter of opposite hue.
  29480. */
  29481. midtonesDensity: number;
  29482. /**
  29483. * Gets the midtones Saturation value.
  29484. * 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.
  29485. */
  29486. /**
  29487. * Sets the midtones Saturation value.
  29488. * 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.
  29489. */
  29490. midtonesSaturation: number;
  29491. /**
  29492. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  29494. */
  29495. /**
  29496. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  29498. */
  29499. midtonesExposure: number;
  29500. private _shadowsHue;
  29501. private _shadowsDensity;
  29502. private _shadowsSaturation;
  29503. private _shadowsExposure;
  29504. /**
  29505. * Gets the shadows Hue value.
  29506. * 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).
  29507. */
  29508. /**
  29509. * Sets the shadows Hue value.
  29510. * 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).
  29511. */
  29512. shadowsHue: number;
  29513. /**
  29514. * Gets the shadows Density value.
  29515. * 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.
  29516. * Values less than zero provide a filter of opposite hue.
  29517. */
  29518. /**
  29519. * Sets the shadows Density value.
  29520. * 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.
  29521. * Values less than zero provide a filter of opposite hue.
  29522. */
  29523. shadowsDensity: number;
  29524. /**
  29525. * Gets the shadows Saturation value.
  29526. * 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.
  29527. */
  29528. /**
  29529. * Sets the shadows Saturation value.
  29530. * 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.
  29531. */
  29532. shadowsSaturation: number;
  29533. /**
  29534. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  29536. */
  29537. /**
  29538. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  29540. */
  29541. shadowsExposure: number;
  29542. /**
  29543. * Returns the class name
  29544. * @returns The class name
  29545. */
  29546. getClassName(): string;
  29547. /**
  29548. * Binds the color curves to the shader.
  29549. * @param colorCurves The color curve to bind
  29550. * @param effect The effect to bind to
  29551. * @param positiveUniform The positive uniform shader parameter
  29552. * @param neutralUniform The neutral uniform shader parameter
  29553. * @param negativeUniform The negative uniform shader parameter
  29554. */
  29555. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29556. /**
  29557. * Prepare the list of uniforms associated with the ColorCurves effects.
  29558. * @param uniformsList The list of uniforms used in the effect
  29559. */
  29560. static PrepareUniforms(uniformsList: string[]): void;
  29561. /**
  29562. * Returns color grading data based on a hue, density, saturation and exposure value.
  29563. * @param filterHue The hue of the color filter.
  29564. * @param filterDensity The density of the color filter.
  29565. * @param saturation The saturation.
  29566. * @param exposure The exposure.
  29567. * @param result The result data container.
  29568. */
  29569. private getColorGradingDataToRef;
  29570. /**
  29571. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29572. * @param value The input slider value in range [-100,100].
  29573. * @returns Adjusted value.
  29574. */
  29575. private static applyColorGradingSliderNonlinear;
  29576. /**
  29577. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29578. * @param hue The hue (H) input.
  29579. * @param saturation The saturation (S) input.
  29580. * @param brightness The brightness (B) input.
  29581. * @result An RGBA color represented as Vector4.
  29582. */
  29583. private static fromHSBToRef;
  29584. /**
  29585. * Returns a value clamped between min and max
  29586. * @param value The value to clamp
  29587. * @param min The minimum of value
  29588. * @param max The maximum of value
  29589. * @returns The clamped value.
  29590. */
  29591. private static clamp;
  29592. /**
  29593. * Clones the current color curve instance.
  29594. * @return The cloned curves
  29595. */
  29596. clone(): ColorCurves;
  29597. /**
  29598. * Serializes the current color curve instance to a json representation.
  29599. * @return a JSON representation
  29600. */
  29601. serialize(): any;
  29602. /**
  29603. * Parses the color curve from a json representation.
  29604. * @param source the JSON source to parse
  29605. * @return The parsed curves
  29606. */
  29607. static Parse(source: any): ColorCurves;
  29608. }
  29609. }
  29610. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29611. import { Observable } from "babylonjs/Misc/observable";
  29612. import { Nullable } from "babylonjs/types";
  29613. import { Color4 } from "babylonjs/Maths/math";
  29614. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29615. import { Effect } from "babylonjs/Materials/effect";
  29616. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29617. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29618. /**
  29619. * Interface to follow in your material defines to integrate easily the
  29620. * Image proccessing functions.
  29621. * @hidden
  29622. */
  29623. export interface IImageProcessingConfigurationDefines {
  29624. IMAGEPROCESSING: boolean;
  29625. VIGNETTE: boolean;
  29626. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29627. VIGNETTEBLENDMODEOPAQUE: boolean;
  29628. TONEMAPPING: boolean;
  29629. TONEMAPPING_ACES: boolean;
  29630. CONTRAST: boolean;
  29631. EXPOSURE: boolean;
  29632. COLORCURVES: boolean;
  29633. COLORGRADING: boolean;
  29634. COLORGRADING3D: boolean;
  29635. SAMPLER3DGREENDEPTH: boolean;
  29636. SAMPLER3DBGRMAP: boolean;
  29637. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29638. }
  29639. /**
  29640. * @hidden
  29641. */
  29642. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29643. IMAGEPROCESSING: boolean;
  29644. VIGNETTE: boolean;
  29645. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29646. VIGNETTEBLENDMODEOPAQUE: boolean;
  29647. TONEMAPPING: boolean;
  29648. TONEMAPPING_ACES: boolean;
  29649. CONTRAST: boolean;
  29650. COLORCURVES: boolean;
  29651. COLORGRADING: boolean;
  29652. COLORGRADING3D: boolean;
  29653. SAMPLER3DGREENDEPTH: boolean;
  29654. SAMPLER3DBGRMAP: boolean;
  29655. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29656. EXPOSURE: boolean;
  29657. constructor();
  29658. }
  29659. /**
  29660. * This groups together the common properties used for image processing either in direct forward pass
  29661. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29662. * or not.
  29663. */
  29664. export class ImageProcessingConfiguration {
  29665. /**
  29666. * Default tone mapping applied in BabylonJS.
  29667. */
  29668. static readonly TONEMAPPING_STANDARD: number;
  29669. /**
  29670. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29671. * to other engines rendering to increase portability.
  29672. */
  29673. static readonly TONEMAPPING_ACES: number;
  29674. /**
  29675. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29676. */
  29677. colorCurves: Nullable<ColorCurves>;
  29678. private _colorCurvesEnabled;
  29679. /**
  29680. * Gets wether the color curves effect is enabled.
  29681. */
  29682. /**
  29683. * Sets wether the color curves effect is enabled.
  29684. */
  29685. colorCurvesEnabled: boolean;
  29686. private _colorGradingTexture;
  29687. /**
  29688. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29689. */
  29690. /**
  29691. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29692. */
  29693. colorGradingTexture: Nullable<BaseTexture>;
  29694. private _colorGradingEnabled;
  29695. /**
  29696. * Gets wether the color grading effect is enabled.
  29697. */
  29698. /**
  29699. * Sets wether the color grading effect is enabled.
  29700. */
  29701. colorGradingEnabled: boolean;
  29702. private _colorGradingWithGreenDepth;
  29703. /**
  29704. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29705. */
  29706. /**
  29707. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29708. */
  29709. colorGradingWithGreenDepth: boolean;
  29710. private _colorGradingBGR;
  29711. /**
  29712. * Gets wether the color grading texture contains BGR values.
  29713. */
  29714. /**
  29715. * Sets wether the color grading texture contains BGR values.
  29716. */
  29717. colorGradingBGR: boolean;
  29718. /** @hidden */
  29719. _exposure: number;
  29720. /**
  29721. * Gets the Exposure used in the effect.
  29722. */
  29723. /**
  29724. * Sets the Exposure used in the effect.
  29725. */
  29726. exposure: number;
  29727. private _toneMappingEnabled;
  29728. /**
  29729. * Gets wether the tone mapping effect is enabled.
  29730. */
  29731. /**
  29732. * Sets wether the tone mapping effect is enabled.
  29733. */
  29734. toneMappingEnabled: boolean;
  29735. private _toneMappingType;
  29736. /**
  29737. * Gets the type of tone mapping effect.
  29738. */
  29739. /**
  29740. * Sets the type of tone mapping effect used in BabylonJS.
  29741. */
  29742. toneMappingType: number;
  29743. protected _contrast: number;
  29744. /**
  29745. * Gets the contrast used in the effect.
  29746. */
  29747. /**
  29748. * Sets the contrast used in the effect.
  29749. */
  29750. contrast: number;
  29751. /**
  29752. * Vignette stretch size.
  29753. */
  29754. vignetteStretch: number;
  29755. /**
  29756. * Vignette centre X Offset.
  29757. */
  29758. vignetteCentreX: number;
  29759. /**
  29760. * Vignette centre Y Offset.
  29761. */
  29762. vignetteCentreY: number;
  29763. /**
  29764. * Vignette weight or intensity of the vignette effect.
  29765. */
  29766. vignetteWeight: number;
  29767. /**
  29768. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29769. * if vignetteEnabled is set to true.
  29770. */
  29771. vignetteColor: Color4;
  29772. /**
  29773. * Camera field of view used by the Vignette effect.
  29774. */
  29775. vignetteCameraFov: number;
  29776. private _vignetteBlendMode;
  29777. /**
  29778. * Gets the vignette blend mode allowing different kind of effect.
  29779. */
  29780. /**
  29781. * Sets the vignette blend mode allowing different kind of effect.
  29782. */
  29783. vignetteBlendMode: number;
  29784. private _vignetteEnabled;
  29785. /**
  29786. * Gets wether the vignette effect is enabled.
  29787. */
  29788. /**
  29789. * Sets wether the vignette effect is enabled.
  29790. */
  29791. vignetteEnabled: boolean;
  29792. private _applyByPostProcess;
  29793. /**
  29794. * Gets wether the image processing is applied through a post process or not.
  29795. */
  29796. /**
  29797. * Sets wether the image processing is applied through a post process or not.
  29798. */
  29799. applyByPostProcess: boolean;
  29800. private _isEnabled;
  29801. /**
  29802. * Gets wether the image processing is enabled or not.
  29803. */
  29804. /**
  29805. * Sets wether the image processing is enabled or not.
  29806. */
  29807. isEnabled: boolean;
  29808. /**
  29809. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29810. */
  29811. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29812. /**
  29813. * Method called each time the image processing information changes requires to recompile the effect.
  29814. */
  29815. protected _updateParameters(): void;
  29816. /**
  29817. * Gets the current class name.
  29818. * @return "ImageProcessingConfiguration"
  29819. */
  29820. getClassName(): string;
  29821. /**
  29822. * Prepare the list of uniforms associated with the Image Processing effects.
  29823. * @param uniforms The list of uniforms used in the effect
  29824. * @param defines the list of defines currently in use
  29825. */
  29826. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29827. /**
  29828. * Prepare the list of samplers associated with the Image Processing effects.
  29829. * @param samplersList The list of uniforms used in the effect
  29830. * @param defines the list of defines currently in use
  29831. */
  29832. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29833. /**
  29834. * Prepare the list of defines associated to the shader.
  29835. * @param defines the list of defines to complete
  29836. * @param forPostProcess Define if we are currently in post process mode or not
  29837. */
  29838. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29839. /**
  29840. * Returns true if all the image processing information are ready.
  29841. * @returns True if ready, otherwise, false
  29842. */
  29843. isReady(): boolean;
  29844. /**
  29845. * Binds the image processing to the shader.
  29846. * @param effect The effect to bind to
  29847. * @param aspectRatio Define the current aspect ratio of the effect
  29848. */
  29849. bind(effect: Effect, aspectRatio?: number): void;
  29850. /**
  29851. * Clones the current image processing instance.
  29852. * @return The cloned image processing
  29853. */
  29854. clone(): ImageProcessingConfiguration;
  29855. /**
  29856. * Serializes the current image processing instance to a json representation.
  29857. * @return a JSON representation
  29858. */
  29859. serialize(): any;
  29860. /**
  29861. * Parses the image processing from a json representation.
  29862. * @param source the JSON source to parse
  29863. * @return The parsed image processing
  29864. */
  29865. static Parse(source: any): ImageProcessingConfiguration;
  29866. private static _VIGNETTEMODE_MULTIPLY;
  29867. private static _VIGNETTEMODE_OPAQUE;
  29868. /**
  29869. * Used to apply the vignette as a mix with the pixel color.
  29870. */
  29871. static readonly VIGNETTEMODE_MULTIPLY: number;
  29872. /**
  29873. * Used to apply the vignette as a replacement of the pixel color.
  29874. */
  29875. static readonly VIGNETTEMODE_OPAQUE: number;
  29876. }
  29877. }
  29878. declare module "babylonjs/Materials/fresnelParameters" {
  29879. import { Color3 } from "babylonjs/Maths/math";
  29880. /**
  29881. * This represents all the required information to add a fresnel effect on a material:
  29882. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29883. */
  29884. export class FresnelParameters {
  29885. private _isEnabled;
  29886. /**
  29887. * Define if the fresnel effect is enable or not.
  29888. */
  29889. isEnabled: boolean;
  29890. /**
  29891. * Define the color used on edges (grazing angle)
  29892. */
  29893. leftColor: Color3;
  29894. /**
  29895. * Define the color used on center
  29896. */
  29897. rightColor: Color3;
  29898. /**
  29899. * Define bias applied to computed fresnel term
  29900. */
  29901. bias: number;
  29902. /**
  29903. * Defined the power exponent applied to fresnel term
  29904. */
  29905. power: number;
  29906. /**
  29907. * Clones the current fresnel and its valuues
  29908. * @returns a clone fresnel configuration
  29909. */
  29910. clone(): FresnelParameters;
  29911. /**
  29912. * Serializes the current fresnel parameters to a JSON representation.
  29913. * @return the JSON serialization
  29914. */
  29915. serialize(): any;
  29916. /**
  29917. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29918. * @param parsedFresnelParameters Define the JSON representation
  29919. * @returns the parsed parameters
  29920. */
  29921. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29922. }
  29923. }
  29924. declare module "babylonjs/Misc/decorators" {
  29925. import { Nullable } from "babylonjs/types";
  29926. import { Scene } from "babylonjs/scene";
  29927. import { IAnimatable } from "babylonjs/Misc/tools";
  29928. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29929. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29937. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29938. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29939. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29940. /**
  29941. * Decorator used to define property that can be serialized as reference to a camera
  29942. * @param sourceName defines the name of the property to decorate
  29943. */
  29944. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29945. /**
  29946. * Class used to help serialization objects
  29947. */
  29948. export class SerializationHelper {
  29949. /** hidden */
  29950. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29951. /** hidden */
  29952. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29953. /** hidden */
  29954. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29955. /** hidden */
  29956. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29957. /**
  29958. * Appends the serialized animations from the source animations
  29959. * @param source Source containing the animations
  29960. * @param destination Target to store the animations
  29961. */
  29962. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29963. /**
  29964. * Static function used to serialized a specific entity
  29965. * @param entity defines the entity to serialize
  29966. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29967. * @returns a JSON compatible object representing the serialization of the entity
  29968. */
  29969. static Serialize<T>(entity: T, serializationObject?: any): any;
  29970. /**
  29971. * Creates a new entity from a serialization data object
  29972. * @param creationFunction defines a function used to instanciated the new entity
  29973. * @param source defines the source serialization data
  29974. * @param scene defines the hosting scene
  29975. * @param rootUrl defines the root url for resources
  29976. * @returns a new entity
  29977. */
  29978. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29979. /**
  29980. * Clones an object
  29981. * @param creationFunction defines the function used to instanciate the new object
  29982. * @param source defines the source object
  29983. * @returns the cloned object
  29984. */
  29985. static Clone<T>(creationFunction: () => T, source: T): T;
  29986. /**
  29987. * Instanciates a new object based on a source one (some data will be shared between both object)
  29988. * @param creationFunction defines the function used to instanciate the new object
  29989. * @param source defines the source object
  29990. * @returns the new object
  29991. */
  29992. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29993. }
  29994. }
  29995. declare module "babylonjs/Cameras/camera" {
  29996. import { SmartArray } from "babylonjs/Misc/smartArray";
  29997. import { Observable } from "babylonjs/Misc/observable";
  29998. import { Nullable } from "babylonjs/types";
  29999. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30000. import { Scene } from "babylonjs/scene";
  30001. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30002. import { Node } from "babylonjs/node";
  30003. import { Mesh } from "babylonjs/Meshes/mesh";
  30004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30005. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30006. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30008. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30009. import { Ray } from "babylonjs/Culling/ray";
  30010. /**
  30011. * This is the base class of all the camera used in the application.
  30012. * @see http://doc.babylonjs.com/features/cameras
  30013. */
  30014. export class Camera extends Node {
  30015. /** @hidden */
  30016. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30017. /**
  30018. * This is the default projection mode used by the cameras.
  30019. * It helps recreating a feeling of perspective and better appreciate depth.
  30020. * This is the best way to simulate real life cameras.
  30021. */
  30022. static readonly PERSPECTIVE_CAMERA: number;
  30023. /**
  30024. * This helps creating camera with an orthographic mode.
  30025. * 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.
  30026. */
  30027. static readonly ORTHOGRAPHIC_CAMERA: number;
  30028. /**
  30029. * This is the default FOV mode for perspective cameras.
  30030. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30031. */
  30032. static readonly FOVMODE_VERTICAL_FIXED: number;
  30033. /**
  30034. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30035. */
  30036. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30037. /**
  30038. * This specifies ther is no need for a camera rig.
  30039. * Basically only one eye is rendered corresponding to the camera.
  30040. */
  30041. static readonly RIG_MODE_NONE: number;
  30042. /**
  30043. * Simulates a camera Rig with one blue eye and one red eye.
  30044. * This can be use with 3d blue and red glasses.
  30045. */
  30046. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30047. /**
  30048. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30049. */
  30050. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30051. /**
  30052. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30053. */
  30054. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30055. /**
  30056. * Defines that both eyes of the camera will be rendered over under each other.
  30057. */
  30058. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30059. /**
  30060. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30061. */
  30062. static readonly RIG_MODE_VR: number;
  30063. /**
  30064. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30065. */
  30066. static readonly RIG_MODE_WEBVR: number;
  30067. /**
  30068. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30069. */
  30070. static readonly RIG_MODE_CUSTOM: number;
  30071. /**
  30072. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30073. */
  30074. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30075. /**
  30076. * @hidden
  30077. * Might be removed once multiview will be a thing
  30078. */
  30079. static UseAlternateWebVRRendering: boolean;
  30080. /**
  30081. * Define the input manager associated with the camera.
  30082. */
  30083. inputs: CameraInputsManager<Camera>;
  30084. /**
  30085. * Define the current local position of the camera in the scene
  30086. */
  30087. position: Vector3;
  30088. /**
  30089. * The vector the camera should consider as up.
  30090. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30091. */
  30092. upVector: Vector3;
  30093. /**
  30094. * Define the current limit on the left side for an orthographic camera
  30095. * In scene unit
  30096. */
  30097. orthoLeft: Nullable<number>;
  30098. /**
  30099. * Define the current limit on the right side for an orthographic camera
  30100. * In scene unit
  30101. */
  30102. orthoRight: Nullable<number>;
  30103. /**
  30104. * Define the current limit on the bottom side for an orthographic camera
  30105. * In scene unit
  30106. */
  30107. orthoBottom: Nullable<number>;
  30108. /**
  30109. * Define the current limit on the top side for an orthographic camera
  30110. * In scene unit
  30111. */
  30112. orthoTop: Nullable<number>;
  30113. /**
  30114. * Field Of View is set in Radians. (default is 0.8)
  30115. */
  30116. fov: number;
  30117. /**
  30118. * Define the minimum distance the camera can see from.
  30119. * This is important to note that the depth buffer are not infinite and the closer it starts
  30120. * the more your scene might encounter depth fighting issue.
  30121. */
  30122. minZ: number;
  30123. /**
  30124. * Define the maximum distance the camera can see to.
  30125. * This is important to note that the depth buffer are not infinite and the further it end
  30126. * the more your scene might encounter depth fighting issue.
  30127. */
  30128. maxZ: number;
  30129. /**
  30130. * Define the default inertia of the camera.
  30131. * This helps giving a smooth feeling to the camera movement.
  30132. */
  30133. inertia: number;
  30134. /**
  30135. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30136. */
  30137. mode: number;
  30138. /**
  30139. * Define wether the camera is intermediate.
  30140. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30141. */
  30142. isIntermediate: boolean;
  30143. /**
  30144. * Define the viewport of the camera.
  30145. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30146. */
  30147. viewport: Viewport;
  30148. /**
  30149. * Restricts the camera to viewing objects with the same layerMask.
  30150. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30151. */
  30152. layerMask: number;
  30153. /**
  30154. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30155. */
  30156. fovMode: number;
  30157. /**
  30158. * Rig mode of the camera.
  30159. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30160. * This is normally controlled byt the camera themselves as internal use.
  30161. */
  30162. cameraRigMode: number;
  30163. /**
  30164. * Defines the distance between both "eyes" in case of a RIG
  30165. */
  30166. interaxialDistance: number;
  30167. /**
  30168. * Defines if stereoscopic rendering is done side by side or over under.
  30169. */
  30170. isStereoscopicSideBySide: boolean;
  30171. /**
  30172. * 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
  30173. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30174. * else in the scene.
  30175. */
  30176. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30177. /**
  30178. * When set, the camera will render to this render target instead of the default canvas
  30179. */
  30180. outputRenderTarget: Nullable<RenderTargetTexture>;
  30181. /**
  30182. * Observable triggered when the camera view matrix has changed.
  30183. */
  30184. onViewMatrixChangedObservable: Observable<Camera>;
  30185. /**
  30186. * Observable triggered when the camera Projection matrix has changed.
  30187. */
  30188. onProjectionMatrixChangedObservable: Observable<Camera>;
  30189. /**
  30190. * Observable triggered when the inputs have been processed.
  30191. */
  30192. onAfterCheckInputsObservable: Observable<Camera>;
  30193. /**
  30194. * Observable triggered when reset has been called and applied to the camera.
  30195. */
  30196. onRestoreStateObservable: Observable<Camera>;
  30197. /** @hidden */
  30198. _cameraRigParams: any;
  30199. /** @hidden */
  30200. _rigCameras: Camera[];
  30201. /** @hidden */
  30202. _rigPostProcess: Nullable<PostProcess>;
  30203. protected _webvrViewMatrix: Matrix;
  30204. /** @hidden */
  30205. _skipRendering: boolean;
  30206. /** @hidden */
  30207. _alternateCamera: Camera;
  30208. /** @hidden */
  30209. _projectionMatrix: Matrix;
  30210. /** @hidden */
  30211. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30212. /** @hidden */
  30213. _activeMeshes: SmartArray<AbstractMesh>;
  30214. protected _globalPosition: Vector3;
  30215. /** hidden */
  30216. _computedViewMatrix: Matrix;
  30217. private _doNotComputeProjectionMatrix;
  30218. private _transformMatrix;
  30219. private _frustumPlanes;
  30220. private _refreshFrustumPlanes;
  30221. private _storedFov;
  30222. private _stateStored;
  30223. /**
  30224. * Instantiates a new camera object.
  30225. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30226. * @see http://doc.babylonjs.com/features/cameras
  30227. * @param name Defines the name of the camera in the scene
  30228. * @param position Defines the position of the camera
  30229. * @param scene Defines the scene the camera belongs too
  30230. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30231. */
  30232. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30233. /**
  30234. * Store current camera state (fov, position, etc..)
  30235. * @returns the camera
  30236. */
  30237. storeState(): Camera;
  30238. /**
  30239. * Restores the camera state values if it has been stored. You must call storeState() first
  30240. */
  30241. protected _restoreStateValues(): boolean;
  30242. /**
  30243. * Restored camera state. You must call storeState() first.
  30244. * @returns true if restored and false otherwise
  30245. */
  30246. restoreState(): boolean;
  30247. /**
  30248. * Gets the class name of the camera.
  30249. * @returns the class name
  30250. */
  30251. getClassName(): string;
  30252. /** @hidden */
  30253. readonly _isCamera: boolean;
  30254. /**
  30255. * Gets a string representation of the camera useful for debug purpose.
  30256. * @param fullDetails Defines that a more verboe level of logging is required
  30257. * @returns the string representation
  30258. */
  30259. toString(fullDetails?: boolean): string;
  30260. /**
  30261. * Gets the current world space position of the camera.
  30262. */
  30263. readonly globalPosition: Vector3;
  30264. /**
  30265. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30266. * @returns the active meshe list
  30267. */
  30268. getActiveMeshes(): SmartArray<AbstractMesh>;
  30269. /**
  30270. * Check wether a mesh is part of the current active mesh list of the camera
  30271. * @param mesh Defines the mesh to check
  30272. * @returns true if active, false otherwise
  30273. */
  30274. isActiveMesh(mesh: Mesh): boolean;
  30275. /**
  30276. * Is this camera ready to be used/rendered
  30277. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30278. * @return true if the camera is ready
  30279. */
  30280. isReady(completeCheck?: boolean): boolean;
  30281. /** @hidden */
  30282. _initCache(): void;
  30283. /** @hidden */
  30284. _updateCache(ignoreParentClass?: boolean): void;
  30285. /** @hidden */
  30286. _isSynchronized(): boolean;
  30287. /** @hidden */
  30288. _isSynchronizedViewMatrix(): boolean;
  30289. /** @hidden */
  30290. _isSynchronizedProjectionMatrix(): boolean;
  30291. /**
  30292. * Attach the input controls to a specific dom element to get the input from.
  30293. * @param element Defines the element the controls should be listened from
  30294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30295. */
  30296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30297. /**
  30298. * Detach the current controls from the specified dom element.
  30299. * @param element Defines the element to stop listening the inputs from
  30300. */
  30301. detachControl(element: HTMLElement): void;
  30302. /**
  30303. * Update the camera state according to the different inputs gathered during the frame.
  30304. */
  30305. update(): void;
  30306. /** @hidden */
  30307. _checkInputs(): void;
  30308. /** @hidden */
  30309. readonly rigCameras: Camera[];
  30310. /**
  30311. * Gets the post process used by the rig cameras
  30312. */
  30313. readonly rigPostProcess: Nullable<PostProcess>;
  30314. /**
  30315. * Internal, gets the first post proces.
  30316. * @returns the first post process to be run on this camera.
  30317. */
  30318. _getFirstPostProcess(): Nullable<PostProcess>;
  30319. private _cascadePostProcessesToRigCams;
  30320. /**
  30321. * Attach a post process to the camera.
  30322. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30323. * @param postProcess The post process to attach to the camera
  30324. * @param insertAt The position of the post process in case several of them are in use in the scene
  30325. * @returns the position the post process has been inserted at
  30326. */
  30327. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30328. /**
  30329. * Detach a post process to the camera.
  30330. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30331. * @param postProcess The post process to detach from the camera
  30332. */
  30333. detachPostProcess(postProcess: PostProcess): void;
  30334. /**
  30335. * Gets the current world matrix of the camera
  30336. */
  30337. getWorldMatrix(): Matrix;
  30338. /** @hidden */
  30339. _getViewMatrix(): Matrix;
  30340. /**
  30341. * Gets the current view matrix of the camera.
  30342. * @param force forces the camera to recompute the matrix without looking at the cached state
  30343. * @returns the view matrix
  30344. */
  30345. getViewMatrix(force?: boolean): Matrix;
  30346. /**
  30347. * Freeze the projection matrix.
  30348. * It will prevent the cache check of the camera projection compute and can speed up perf
  30349. * if no parameter of the camera are meant to change
  30350. * @param projection Defines manually a projection if necessary
  30351. */
  30352. freezeProjectionMatrix(projection?: Matrix): void;
  30353. /**
  30354. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30355. */
  30356. unfreezeProjectionMatrix(): void;
  30357. /**
  30358. * Gets the current projection matrix of the camera.
  30359. * @param force forces the camera to recompute the matrix without looking at the cached state
  30360. * @returns the projection matrix
  30361. */
  30362. getProjectionMatrix(force?: boolean): Matrix;
  30363. /**
  30364. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30365. * @returns a Matrix
  30366. */
  30367. getTransformationMatrix(): Matrix;
  30368. private _updateFrustumPlanes;
  30369. /**
  30370. * Checks if a cullable object (mesh...) is in the camera frustum
  30371. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30372. * @param target The object to check
  30373. * @returns true if the object is in frustum otherwise false
  30374. */
  30375. isInFrustum(target: ICullable): boolean;
  30376. /**
  30377. * Checks if a cullable object (mesh...) is in the camera frustum
  30378. * Unlike isInFrustum this cheks the full bounding box
  30379. * @param target The object to check
  30380. * @returns true if the object is in frustum otherwise false
  30381. */
  30382. isCompletelyInFrustum(target: ICullable): boolean;
  30383. /**
  30384. * Gets a ray in the forward direction from the camera.
  30385. * @param length Defines the length of the ray to create
  30386. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30387. * @param origin Defines the start point of the ray which defaults to the camera position
  30388. * @returns the forward ray
  30389. */
  30390. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30391. /**
  30392. * Releases resources associated with this node.
  30393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30395. */
  30396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30397. /**
  30398. * Gets the left camera of a rig setup in case of Rigged Camera
  30399. */
  30400. readonly leftCamera: Nullable<FreeCamera>;
  30401. /**
  30402. * Gets the right camera of a rig setup in case of Rigged Camera
  30403. */
  30404. readonly rightCamera: Nullable<FreeCamera>;
  30405. /**
  30406. * Gets the left camera target of a rig setup in case of Rigged Camera
  30407. * @returns the target position
  30408. */
  30409. getLeftTarget(): Nullable<Vector3>;
  30410. /**
  30411. * Gets the right camera target of a rig setup in case of Rigged Camera
  30412. * @returns the target position
  30413. */
  30414. getRightTarget(): Nullable<Vector3>;
  30415. /**
  30416. * @hidden
  30417. */
  30418. setCameraRigMode(mode: number, rigParams: any): void;
  30419. /** @hidden */
  30420. static _setStereoscopicRigMode(camera: Camera): void;
  30421. /** @hidden */
  30422. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30423. /** @hidden */
  30424. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30425. /** @hidden */
  30426. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30427. /** @hidden */
  30428. _getVRProjectionMatrix(): Matrix;
  30429. protected _updateCameraRotationMatrix(): void;
  30430. protected _updateWebVRCameraRotationMatrix(): void;
  30431. /**
  30432. * This function MUST be overwritten by the different WebVR cameras available.
  30433. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30434. * @hidden
  30435. */
  30436. _getWebVRProjectionMatrix(): Matrix;
  30437. /**
  30438. * This function MUST be overwritten by the different WebVR cameras available.
  30439. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30440. * @hidden
  30441. */
  30442. _getWebVRViewMatrix(): Matrix;
  30443. /** @hidden */
  30444. setCameraRigParameter(name: string, value: any): void;
  30445. /**
  30446. * needs to be overridden by children so sub has required properties to be copied
  30447. * @hidden
  30448. */
  30449. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30450. /**
  30451. * May need to be overridden by children
  30452. * @hidden
  30453. */
  30454. _updateRigCameras(): void;
  30455. /** @hidden */
  30456. _setupInputs(): void;
  30457. /**
  30458. * Serialiaze the camera setup to a json represention
  30459. * @returns the JSON representation
  30460. */
  30461. serialize(): any;
  30462. /**
  30463. * Clones the current camera.
  30464. * @param name The cloned camera name
  30465. * @returns the cloned camera
  30466. */
  30467. clone(name: string): Camera;
  30468. /**
  30469. * Gets the direction of the camera relative to a given local axis.
  30470. * @param localAxis Defines the reference axis to provide a relative direction.
  30471. * @return the direction
  30472. */
  30473. getDirection(localAxis: Vector3): Vector3;
  30474. /**
  30475. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30476. * @param localAxis Defines the reference axis to provide a relative direction.
  30477. * @param result Defines the vector to store the result in
  30478. */
  30479. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30480. /**
  30481. * Gets a camera constructor for a given camera type
  30482. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30483. * @param name The name of the camera the result will be able to instantiate
  30484. * @param scene The scene the result will construct the camera in
  30485. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30486. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30487. * @returns a factory method to construc the camera
  30488. */
  30489. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30490. /**
  30491. * Compute the world matrix of the camera.
  30492. * @returns the camera workd matrix
  30493. */
  30494. computeWorldMatrix(): Matrix;
  30495. /**
  30496. * Parse a JSON and creates the camera from the parsed information
  30497. * @param parsedCamera The JSON to parse
  30498. * @param scene The scene to instantiate the camera in
  30499. * @returns the newly constructed camera
  30500. */
  30501. static Parse(parsedCamera: any, scene: Scene): Camera;
  30502. }
  30503. }
  30504. declare module "babylonjs/Misc/tools" {
  30505. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30506. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30507. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30508. import { Observable } from "babylonjs/Misc/observable";
  30509. import { DomManagement } from "babylonjs/Misc/domManagement";
  30510. import { Camera } from "babylonjs/Cameras/camera";
  30511. import { Engine } from "babylonjs/Engines/engine";
  30512. import { Animation } from "babylonjs/Animations/animation";
  30513. /**
  30514. * Interface for any object that can request an animation frame
  30515. */
  30516. export interface ICustomAnimationFrameRequester {
  30517. /**
  30518. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30519. */
  30520. renderFunction?: Function;
  30521. /**
  30522. * Called to request the next frame to render to
  30523. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30524. */
  30525. requestAnimationFrame: Function;
  30526. /**
  30527. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30528. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30529. */
  30530. requestID?: number;
  30531. }
  30532. /**
  30533. * Interface containing an array of animations
  30534. */
  30535. export interface IAnimatable {
  30536. /**
  30537. * Array of animations
  30538. */
  30539. animations: Array<Animation>;
  30540. }
  30541. /** Interface used by value gradients (color, factor, ...) */
  30542. export interface IValueGradient {
  30543. /**
  30544. * Gets or sets the gradient value (between 0 and 1)
  30545. */
  30546. gradient: number;
  30547. }
  30548. /** Class used to store color4 gradient */
  30549. export class ColorGradient implements IValueGradient {
  30550. /**
  30551. * Gets or sets the gradient value (between 0 and 1)
  30552. */
  30553. gradient: number;
  30554. /**
  30555. * Gets or sets first associated color
  30556. */
  30557. color1: Color4;
  30558. /**
  30559. * Gets or sets second associated color
  30560. */
  30561. color2?: Color4;
  30562. /**
  30563. * Will get a color picked randomly between color1 and color2.
  30564. * If color2 is undefined then color1 will be used
  30565. * @param result defines the target Color4 to store the result in
  30566. */
  30567. getColorToRef(result: Color4): void;
  30568. }
  30569. /** Class used to store color 3 gradient */
  30570. export class Color3Gradient implements IValueGradient {
  30571. /**
  30572. * Gets or sets the gradient value (between 0 and 1)
  30573. */
  30574. gradient: number;
  30575. /**
  30576. * Gets or sets the associated color
  30577. */
  30578. color: Color3;
  30579. }
  30580. /** Class used to store factor gradient */
  30581. export class FactorGradient implements IValueGradient {
  30582. /**
  30583. * Gets or sets the gradient value (between 0 and 1)
  30584. */
  30585. gradient: number;
  30586. /**
  30587. * Gets or sets first associated factor
  30588. */
  30589. factor1: number;
  30590. /**
  30591. * Gets or sets second associated factor
  30592. */
  30593. factor2?: number;
  30594. /**
  30595. * Will get a number picked randomly between factor1 and factor2.
  30596. * If factor2 is undefined then factor1 will be used
  30597. * @returns the picked number
  30598. */
  30599. getFactor(): number;
  30600. }
  30601. /**
  30602. * @ignore
  30603. * Application error to support additional information when loading a file
  30604. */
  30605. export class LoadFileError extends Error {
  30606. /** defines the optional XHR request */
  30607. request?: XMLHttpRequest | undefined;
  30608. private static _setPrototypeOf;
  30609. /**
  30610. * Creates a new LoadFileError
  30611. * @param message defines the message of the error
  30612. * @param request defines the optional XHR request
  30613. */
  30614. constructor(message: string,
  30615. /** defines the optional XHR request */
  30616. request?: XMLHttpRequest | undefined);
  30617. }
  30618. /**
  30619. * Class used to define a retry strategy when error happens while loading assets
  30620. */
  30621. export class RetryStrategy {
  30622. /**
  30623. * Function used to defines an exponential back off strategy
  30624. * @param maxRetries defines the maximum number of retries (3 by default)
  30625. * @param baseInterval defines the interval between retries
  30626. * @returns the strategy function to use
  30627. */
  30628. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30629. }
  30630. /**
  30631. * File request interface
  30632. */
  30633. export interface IFileRequest {
  30634. /**
  30635. * Raised when the request is complete (success or error).
  30636. */
  30637. onCompleteObservable: Observable<IFileRequest>;
  30638. /**
  30639. * Aborts the request for a file.
  30640. */
  30641. abort: () => void;
  30642. }
  30643. /**
  30644. * Class containing a set of static utilities functions
  30645. */
  30646. export class Tools {
  30647. /**
  30648. * Gets or sets the base URL to use to load assets
  30649. */
  30650. static BaseUrl: string;
  30651. /**
  30652. * Enable/Disable Custom HTTP Request Headers globally.
  30653. * default = false
  30654. * @see CustomRequestHeaders
  30655. */
  30656. static UseCustomRequestHeaders: boolean;
  30657. /**
  30658. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30659. * i.e. when loading files, where the server/service expects an Authorization header.
  30660. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30661. */
  30662. static CustomRequestHeaders: {
  30663. [key: string]: string;
  30664. };
  30665. /**
  30666. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30667. */
  30668. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30669. /**
  30670. * Default behaviour for cors in the application.
  30671. * It can be a string if the expected behavior is identical in the entire app.
  30672. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30673. */
  30674. static CorsBehavior: string | ((url: string | string[]) => string);
  30675. /**
  30676. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30677. * @ignorenaming
  30678. */
  30679. static UseFallbackTexture: boolean;
  30680. /**
  30681. * Use this object to register external classes like custom textures or material
  30682. * to allow the laoders to instantiate them
  30683. */
  30684. static RegisteredExternalClasses: {
  30685. [key: string]: Object;
  30686. };
  30687. /**
  30688. * Texture content used if a texture cannot loaded
  30689. * @ignorenaming
  30690. */
  30691. static fallbackTexture: string;
  30692. /**
  30693. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30694. * @param u defines the coordinate on X axis
  30695. * @param v defines the coordinate on Y axis
  30696. * @param width defines the width of the source data
  30697. * @param height defines the height of the source data
  30698. * @param pixels defines the source byte array
  30699. * @param color defines the output color
  30700. */
  30701. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30702. /**
  30703. * Interpolates between a and b via alpha
  30704. * @param a The lower value (returned when alpha = 0)
  30705. * @param b The upper value (returned when alpha = 1)
  30706. * @param alpha The interpolation-factor
  30707. * @return The mixed value
  30708. */
  30709. static Mix(a: number, b: number, alpha: number): number;
  30710. /**
  30711. * Tries to instantiate a new object from a given class name
  30712. * @param className defines the class name to instantiate
  30713. * @returns the new object or null if the system was not able to do the instantiation
  30714. */
  30715. static Instantiate(className: string): any;
  30716. /**
  30717. * Provides a slice function that will work even on IE
  30718. * @param data defines the array to slice
  30719. * @param start defines the start of the data (optional)
  30720. * @param end defines the end of the data (optional)
  30721. * @returns the new sliced array
  30722. */
  30723. static Slice<T>(data: T, start?: number, end?: number): T;
  30724. /**
  30725. * Polyfill for setImmediate
  30726. * @param action defines the action to execute after the current execution block
  30727. */
  30728. static SetImmediate(action: () => void): void;
  30729. /**
  30730. * Function indicating if a number is an exponent of 2
  30731. * @param value defines the value to test
  30732. * @returns true if the value is an exponent of 2
  30733. */
  30734. static IsExponentOfTwo(value: number): boolean;
  30735. private static _tmpFloatArray;
  30736. /**
  30737. * Returns the nearest 32-bit single precision float representation of a Number
  30738. * @param value A Number. If the parameter is of a different type, it will get converted
  30739. * to a number or to NaN if it cannot be converted
  30740. * @returns number
  30741. */
  30742. static FloatRound(value: number): number;
  30743. /**
  30744. * Find the next highest power of two.
  30745. * @param x Number to start search from.
  30746. * @return Next highest power of two.
  30747. */
  30748. static CeilingPOT(x: number): number;
  30749. /**
  30750. * Find the next lowest power of two.
  30751. * @param x Number to start search from.
  30752. * @return Next lowest power of two.
  30753. */
  30754. static FloorPOT(x: number): number;
  30755. /**
  30756. * Find the nearest power of two.
  30757. * @param x Number to start search from.
  30758. * @return Next nearest power of two.
  30759. */
  30760. static NearestPOT(x: number): number;
  30761. /**
  30762. * Get the closest exponent of two
  30763. * @param value defines the value to approximate
  30764. * @param max defines the maximum value to return
  30765. * @param mode defines how to define the closest value
  30766. * @returns closest exponent of two of the given value
  30767. */
  30768. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30769. /**
  30770. * Extracts the filename from a path
  30771. * @param path defines the path to use
  30772. * @returns the filename
  30773. */
  30774. static GetFilename(path: string): string;
  30775. /**
  30776. * Extracts the "folder" part of a path (everything before the filename).
  30777. * @param uri The URI to extract the info from
  30778. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30779. * @returns The "folder" part of the path
  30780. */
  30781. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30782. /**
  30783. * Extracts text content from a DOM element hierarchy
  30784. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30785. */
  30786. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30787. /**
  30788. * Convert an angle in radians to degrees
  30789. * @param angle defines the angle to convert
  30790. * @returns the angle in degrees
  30791. */
  30792. static ToDegrees(angle: number): number;
  30793. /**
  30794. * Convert an angle in degrees to radians
  30795. * @param angle defines the angle to convert
  30796. * @returns the angle in radians
  30797. */
  30798. static ToRadians(angle: number): number;
  30799. /**
  30800. * Encode a buffer to a base64 string
  30801. * @param buffer defines the buffer to encode
  30802. * @returns the encoded string
  30803. */
  30804. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30805. /**
  30806. * Extracts minimum and maximum values from a list of indexed positions
  30807. * @param positions defines the positions to use
  30808. * @param indices defines the indices to the positions
  30809. * @param indexStart defines the start index
  30810. * @param indexCount defines the end index
  30811. * @param bias defines bias value to add to the result
  30812. * @return minimum and maximum values
  30813. */
  30814. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30815. minimum: Vector3;
  30816. maximum: Vector3;
  30817. };
  30818. /**
  30819. * Extracts minimum and maximum values from a list of positions
  30820. * @param positions defines the positions to use
  30821. * @param start defines the start index in the positions array
  30822. * @param count defines the number of positions to handle
  30823. * @param bias defines bias value to add to the result
  30824. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30825. * @return minimum and maximum values
  30826. */
  30827. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30828. minimum: Vector3;
  30829. maximum: Vector3;
  30830. };
  30831. /**
  30832. * Returns an array if obj is not an array
  30833. * @param obj defines the object to evaluate as an array
  30834. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30835. * @returns either obj directly if obj is an array or a new array containing obj
  30836. */
  30837. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30838. /**
  30839. * Gets the pointer prefix to use
  30840. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30841. */
  30842. static GetPointerPrefix(): string;
  30843. /**
  30844. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30845. * @param func - the function to be called
  30846. * @param requester - the object that will request the next frame. Falls back to window.
  30847. * @returns frame number
  30848. */
  30849. static QueueNewFrame(func: () => void, requester?: any): number;
  30850. /**
  30851. * Ask the browser to promote the current element to fullscreen rendering mode
  30852. * @param element defines the DOM element to promote
  30853. */
  30854. static RequestFullscreen(element: HTMLElement): void;
  30855. /**
  30856. * Asks the browser to exit fullscreen mode
  30857. */
  30858. static ExitFullscreen(): void;
  30859. /**
  30860. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30861. * @param url define the url we are trying
  30862. * @param element define the dom element where to configure the cors policy
  30863. */
  30864. static SetCorsBehavior(url: string | string[], element: {
  30865. crossOrigin: string | null;
  30866. }): void;
  30867. /**
  30868. * Removes unwanted characters from an url
  30869. * @param url defines the url to clean
  30870. * @returns the cleaned url
  30871. */
  30872. static CleanUrl(url: string): string;
  30873. /**
  30874. * Gets or sets a function used to pre-process url before using them to load assets
  30875. */
  30876. static PreprocessUrl: (url: string) => string;
  30877. /**
  30878. * Loads an image as an HTMLImageElement.
  30879. * @param input url string, ArrayBuffer, or Blob to load
  30880. * @param onLoad callback called when the image successfully loads
  30881. * @param onError callback called when the image fails to load
  30882. * @param offlineProvider offline provider for caching
  30883. * @returns the HTMLImageElement of the loaded image
  30884. */
  30885. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30886. /**
  30887. * Loads a file
  30888. * @param url url string, ArrayBuffer, or Blob to load
  30889. * @param onSuccess callback called when the file successfully loads
  30890. * @param onProgress callback called while file is loading (if the server supports this mode)
  30891. * @param offlineProvider defines the offline provider for caching
  30892. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30893. * @param onError callback called when the file fails to load
  30894. * @returns a file request object
  30895. */
  30896. 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;
  30897. /**
  30898. * Load a script (identified by an url). When the url returns, the
  30899. * content of this file is added into a new script element, attached to the DOM (body element)
  30900. * @param scriptUrl defines the url of the script to laod
  30901. * @param onSuccess defines the callback called when the script is loaded
  30902. * @param onError defines the callback to call if an error occurs
  30903. */
  30904. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30905. /**
  30906. * Loads a file from a blob
  30907. * @param fileToLoad defines the blob to use
  30908. * @param callback defines the callback to call when data is loaded
  30909. * @param progressCallback defines the callback to call during loading process
  30910. * @returns a file request object
  30911. */
  30912. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30913. /**
  30914. * Loads a file
  30915. * @param fileToLoad defines the file to load
  30916. * @param callback defines the callback to call when data is loaded
  30917. * @param progressCallBack defines the callback to call during loading process
  30918. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30919. * @returns a file request object
  30920. */
  30921. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30922. /**
  30923. * Creates a data url from a given string content
  30924. * @param content defines the content to convert
  30925. * @returns the new data url link
  30926. */
  30927. static FileAsURL(content: string): string;
  30928. /**
  30929. * Format the given number to a specific decimal format
  30930. * @param value defines the number to format
  30931. * @param decimals defines the number of decimals to use
  30932. * @returns the formatted string
  30933. */
  30934. static Format(value: number, decimals?: number): string;
  30935. /**
  30936. * Checks if a given vector is inside a specific range
  30937. * @param v defines the vector to test
  30938. * @param min defines the minimum range
  30939. * @param max defines the maximum range
  30940. */
  30941. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30942. /**
  30943. * Tries to copy an object by duplicating every property
  30944. * @param source defines the source object
  30945. * @param destination defines the target object
  30946. * @param doNotCopyList defines a list of properties to avoid
  30947. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30948. */
  30949. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30950. /**
  30951. * Gets a boolean indicating if the given object has no own property
  30952. * @param obj defines the object to test
  30953. * @returns true if object has no own property
  30954. */
  30955. static IsEmpty(obj: any): boolean;
  30956. /**
  30957. * Function used to register events at window level
  30958. * @param events defines the events to register
  30959. */
  30960. static RegisterTopRootEvents(events: {
  30961. name: string;
  30962. handler: Nullable<(e: FocusEvent) => any>;
  30963. }[]): void;
  30964. /**
  30965. * Function used to unregister events from window level
  30966. * @param events defines the events to unregister
  30967. */
  30968. static UnregisterTopRootEvents(events: {
  30969. name: string;
  30970. handler: Nullable<(e: FocusEvent) => any>;
  30971. }[]): void;
  30972. /**
  30973. * Dumps the current bound framebuffer
  30974. * @param width defines the rendering width
  30975. * @param height defines the rendering height
  30976. * @param engine defines the hosting engine
  30977. * @param successCallback defines the callback triggered once the data are available
  30978. * @param mimeType defines the mime type of the result
  30979. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30980. */
  30981. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30982. /**
  30983. * Converts the canvas data to blob.
  30984. * This acts as a polyfill for browsers not supporting the to blob function.
  30985. * @param canvas Defines the canvas to extract the data from
  30986. * @param successCallback Defines the callback triggered once the data are available
  30987. * @param mimeType Defines the mime type of the result
  30988. */
  30989. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30990. /**
  30991. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30992. * @param successCallback defines the callback triggered once the data are available
  30993. * @param mimeType defines the mime type of the result
  30994. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30995. */
  30996. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30997. /**
  30998. * Downloads a blob in the browser
  30999. * @param blob defines the blob to download
  31000. * @param fileName defines the name of the downloaded file
  31001. */
  31002. static Download(blob: Blob, fileName: string): void;
  31003. /**
  31004. * Captures a screenshot of the current rendering
  31005. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31006. * @param engine defines the rendering engine
  31007. * @param camera defines the source camera
  31008. * @param size This parameter can be set to a single number or to an object with the
  31009. * following (optional) properties: precision, width, height. If a single number is passed,
  31010. * it will be used for both width and height. If an object is passed, the screenshot size
  31011. * will be derived from the parameters. The precision property is a multiplier allowing
  31012. * rendering at a higher or lower resolution
  31013. * @param successCallback defines the callback receives a single parameter which contains the
  31014. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31015. * src parameter of an <img> to display it
  31016. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31017. * Check your browser for supported MIME types
  31018. */
  31019. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31020. /**
  31021. * Generates an image screenshot from the specified camera.
  31022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31023. * @param engine The engine to use for rendering
  31024. * @param camera The camera to use for rendering
  31025. * @param size This parameter can be set to a single number or to an object with the
  31026. * following (optional) properties: precision, width, height. If a single number is passed,
  31027. * it will be used for both width and height. If an object is passed, the screenshot size
  31028. * will be derived from the parameters. The precision property is a multiplier allowing
  31029. * rendering at a higher or lower resolution
  31030. * @param successCallback The callback receives a single parameter which contains the
  31031. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31032. * src parameter of an <img> to display it
  31033. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31034. * Check your browser for supported MIME types
  31035. * @param samples Texture samples (default: 1)
  31036. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31037. * @param fileName A name for for the downloaded file.
  31038. */
  31039. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31040. /**
  31041. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31042. * Be aware Math.random() could cause collisions, but:
  31043. * "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"
  31044. * @returns a pseudo random id
  31045. */
  31046. static RandomId(): string;
  31047. /**
  31048. * Test if the given uri is a base64 string
  31049. * @param uri The uri to test
  31050. * @return True if the uri is a base64 string or false otherwise
  31051. */
  31052. static IsBase64(uri: string): boolean;
  31053. /**
  31054. * Decode the given base64 uri.
  31055. * @param uri The uri to decode
  31056. * @return The decoded base64 data.
  31057. */
  31058. static DecodeBase64(uri: string): ArrayBuffer;
  31059. /**
  31060. * No log
  31061. */
  31062. static readonly NoneLogLevel: number;
  31063. /**
  31064. * Only message logs
  31065. */
  31066. static readonly MessageLogLevel: number;
  31067. /**
  31068. * Only warning logs
  31069. */
  31070. static readonly WarningLogLevel: number;
  31071. /**
  31072. * Only error logs
  31073. */
  31074. static readonly ErrorLogLevel: number;
  31075. /**
  31076. * All logs
  31077. */
  31078. static readonly AllLogLevel: number;
  31079. /**
  31080. * Gets a value indicating the number of loading errors
  31081. * @ignorenaming
  31082. */
  31083. static readonly errorsCount: number;
  31084. /**
  31085. * Callback called when a new log is added
  31086. */
  31087. static OnNewCacheEntry: (entry: string) => void;
  31088. /**
  31089. * Log a message to the console
  31090. * @param message defines the message to log
  31091. */
  31092. static Log(message: string): void;
  31093. /**
  31094. * Write a warning message to the console
  31095. * @param message defines the message to log
  31096. */
  31097. static Warn(message: string): void;
  31098. /**
  31099. * Write an error message to the console
  31100. * @param message defines the message to log
  31101. */
  31102. static Error(message: string): void;
  31103. /**
  31104. * Gets current log cache (list of logs)
  31105. */
  31106. static readonly LogCache: string;
  31107. /**
  31108. * Clears the log cache
  31109. */
  31110. static ClearLogCache(): void;
  31111. /**
  31112. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31113. */
  31114. static LogLevels: number;
  31115. /**
  31116. * Checks if the loaded document was accessed via `file:`-Protocol.
  31117. * @returns boolean
  31118. */
  31119. static IsFileURL(): boolean;
  31120. /**
  31121. * Checks if the window object exists
  31122. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31123. */
  31124. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31125. /**
  31126. * No performance log
  31127. */
  31128. static readonly PerformanceNoneLogLevel: number;
  31129. /**
  31130. * Use user marks to log performance
  31131. */
  31132. static readonly PerformanceUserMarkLogLevel: number;
  31133. /**
  31134. * Log performance to the console
  31135. */
  31136. static readonly PerformanceConsoleLogLevel: number;
  31137. private static _performance;
  31138. /**
  31139. * Sets the current performance log level
  31140. */
  31141. static PerformanceLogLevel: number;
  31142. private static _StartPerformanceCounterDisabled;
  31143. private static _EndPerformanceCounterDisabled;
  31144. private static _StartUserMark;
  31145. private static _EndUserMark;
  31146. private static _StartPerformanceConsole;
  31147. private static _EndPerformanceConsole;
  31148. /**
  31149. * Injects the @see CustomRequestHeaders into the given request
  31150. * @param request the request that should be used for injection
  31151. */
  31152. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31153. /**
  31154. * Starts a performance counter
  31155. */
  31156. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31157. /**
  31158. * Ends a specific performance coutner
  31159. */
  31160. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31161. /**
  31162. * Gets either window.performance.now() if supported or Date.now() else
  31163. */
  31164. static readonly Now: number;
  31165. /**
  31166. * This method will return the name of the class used to create the instance of the given object.
  31167. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31168. * @param object the object to get the class name from
  31169. * @param isType defines if the object is actually a type
  31170. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31171. */
  31172. static GetClassName(object: any, isType?: boolean): string;
  31173. /**
  31174. * Gets the first element of an array satisfying a given predicate
  31175. * @param array defines the array to browse
  31176. * @param predicate defines the predicate to use
  31177. * @returns null if not found or the element
  31178. */
  31179. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31180. /**
  31181. * This method will return the name of the full name of the class, including its owning module (if any).
  31182. * 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).
  31183. * @param object the object to get the class name from
  31184. * @param isType defines if the object is actually a type
  31185. * @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.
  31186. * @ignorenaming
  31187. */
  31188. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31189. /**
  31190. * Returns a promise that resolves after the given amount of time.
  31191. * @param delay Number of milliseconds to delay
  31192. * @returns Promise that resolves after the given amount of time
  31193. */
  31194. static DelayAsync(delay: number): Promise<void>;
  31195. /**
  31196. * Gets the current gradient from an array of IValueGradient
  31197. * @param ratio defines the current ratio to get
  31198. * @param gradients defines the array of IValueGradient
  31199. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31200. */
  31201. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31202. }
  31203. /**
  31204. * This class is used to track a performance counter which is number based.
  31205. * The user has access to many properties which give statistics of different nature.
  31206. *
  31207. * The implementer can track two kinds of Performance Counter: time and count.
  31208. * 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.
  31209. * 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.
  31210. */
  31211. export class PerfCounter {
  31212. /**
  31213. * Gets or sets a global boolean to turn on and off all the counters
  31214. */
  31215. static Enabled: boolean;
  31216. /**
  31217. * Returns the smallest value ever
  31218. */
  31219. readonly min: number;
  31220. /**
  31221. * Returns the biggest value ever
  31222. */
  31223. readonly max: number;
  31224. /**
  31225. * Returns the average value since the performance counter is running
  31226. */
  31227. readonly average: number;
  31228. /**
  31229. * Returns the average value of the last second the counter was monitored
  31230. */
  31231. readonly lastSecAverage: number;
  31232. /**
  31233. * Returns the current value
  31234. */
  31235. readonly current: number;
  31236. /**
  31237. * Gets the accumulated total
  31238. */
  31239. readonly total: number;
  31240. /**
  31241. * Gets the total value count
  31242. */
  31243. readonly count: number;
  31244. /**
  31245. * Creates a new counter
  31246. */
  31247. constructor();
  31248. /**
  31249. * Call this method to start monitoring a new frame.
  31250. * 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.
  31251. */
  31252. fetchNewFrame(): void;
  31253. /**
  31254. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31255. * @param newCount the count value to add to the monitored count
  31256. * @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.
  31257. */
  31258. addCount(newCount: number, fetchResult: boolean): void;
  31259. /**
  31260. * Start monitoring this performance counter
  31261. */
  31262. beginMonitoring(): void;
  31263. /**
  31264. * Compute the time lapsed since the previous beginMonitoring() call.
  31265. * @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
  31266. */
  31267. endMonitoring(newFrame?: boolean): void;
  31268. private _fetchResult;
  31269. private _startMonitoringTime;
  31270. private _min;
  31271. private _max;
  31272. private _average;
  31273. private _current;
  31274. private _totalValueCount;
  31275. private _totalAccumulated;
  31276. private _lastSecAverage;
  31277. private _lastSecAccumulated;
  31278. private _lastSecTime;
  31279. private _lastSecValueCount;
  31280. }
  31281. /**
  31282. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31283. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31284. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31285. * @param name The name of the class, case should be preserved
  31286. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31287. */
  31288. export function className(name: string, module?: string): (target: Object) => void;
  31289. /**
  31290. * An implementation of a loop for asynchronous functions.
  31291. */
  31292. export class AsyncLoop {
  31293. /**
  31294. * Defines the number of iterations for the loop
  31295. */
  31296. iterations: number;
  31297. /**
  31298. * Defines the current index of the loop.
  31299. */
  31300. index: number;
  31301. private _done;
  31302. private _fn;
  31303. private _successCallback;
  31304. /**
  31305. * Constructor.
  31306. * @param iterations the number of iterations.
  31307. * @param func the function to run each iteration
  31308. * @param successCallback the callback that will be called upon succesful execution
  31309. * @param offset starting offset.
  31310. */
  31311. constructor(
  31312. /**
  31313. * Defines the number of iterations for the loop
  31314. */
  31315. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31316. /**
  31317. * Execute the next iteration. Must be called after the last iteration was finished.
  31318. */
  31319. executeNext(): void;
  31320. /**
  31321. * Break the loop and run the success callback.
  31322. */
  31323. breakLoop(): void;
  31324. /**
  31325. * Create and run an async loop.
  31326. * @param iterations the number of iterations.
  31327. * @param fn the function to run each iteration
  31328. * @param successCallback the callback that will be called upon succesful execution
  31329. * @param offset starting offset.
  31330. * @returns the created async loop object
  31331. */
  31332. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31333. /**
  31334. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31335. * @param iterations total number of iterations
  31336. * @param syncedIterations number of synchronous iterations in each async iteration.
  31337. * @param fn the function to call each iteration.
  31338. * @param callback a success call back that will be called when iterating stops.
  31339. * @param breakFunction a break condition (optional)
  31340. * @param timeout timeout settings for the setTimeout function. default - 0.
  31341. * @returns the created async loop object
  31342. */
  31343. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31344. }
  31345. }
  31346. declare module "babylonjs/Collisions/collisionCoordinator" {
  31347. import { Nullable } from "babylonjs/types";
  31348. import { Scene } from "babylonjs/scene";
  31349. import { Vector3 } from "babylonjs/Maths/math";
  31350. import { Collider } from "babylonjs/Collisions/collider";
  31351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31352. /** @hidden */
  31353. export interface ICollisionCoordinator {
  31354. createCollider(): Collider;
  31355. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31356. init(scene: Scene): void;
  31357. }
  31358. /** @hidden */
  31359. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31360. private _scene;
  31361. private _scaledPosition;
  31362. private _scaledVelocity;
  31363. private _finalPosition;
  31364. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31365. createCollider(): Collider;
  31366. init(scene: Scene): void;
  31367. private _collideWithWorld;
  31368. }
  31369. }
  31370. declare module "babylonjs/Animations/animationGroup" {
  31371. import { Animatable } from "babylonjs/Animations/animatable";
  31372. import { Animation } from "babylonjs/Animations/animation";
  31373. import { Scene, IDisposable } from "babylonjs/scene";
  31374. import { Observable } from "babylonjs/Misc/observable";
  31375. import { Nullable } from "babylonjs/types";
  31376. /**
  31377. * This class defines the direct association between an animation and a target
  31378. */
  31379. export class TargetedAnimation {
  31380. /**
  31381. * Animation to perform
  31382. */
  31383. animation: Animation;
  31384. /**
  31385. * Target to animate
  31386. */
  31387. target: any;
  31388. }
  31389. /**
  31390. * Use this class to create coordinated animations on multiple targets
  31391. */
  31392. export class AnimationGroup implements IDisposable {
  31393. /** The name of the animation group */
  31394. name: string;
  31395. private _scene;
  31396. private _targetedAnimations;
  31397. private _animatables;
  31398. private _from;
  31399. private _to;
  31400. private _isStarted;
  31401. private _isPaused;
  31402. private _speedRatio;
  31403. /**
  31404. * Gets or sets the unique id of the node
  31405. */
  31406. uniqueId: number;
  31407. /**
  31408. * This observable will notify when one animation have ended
  31409. */
  31410. onAnimationEndObservable: Observable<TargetedAnimation>;
  31411. /**
  31412. * Observer raised when one animation loops
  31413. */
  31414. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31415. /**
  31416. * This observable will notify when all animations have ended.
  31417. */
  31418. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31419. /**
  31420. * This observable will notify when all animations have paused.
  31421. */
  31422. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31423. /**
  31424. * This observable will notify when all animations are playing.
  31425. */
  31426. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31427. /**
  31428. * Gets the first frame
  31429. */
  31430. readonly from: number;
  31431. /**
  31432. * Gets the last frame
  31433. */
  31434. readonly to: number;
  31435. /**
  31436. * Define if the animations are started
  31437. */
  31438. readonly isStarted: boolean;
  31439. /**
  31440. * Gets a value indicating that the current group is playing
  31441. */
  31442. readonly isPlaying: boolean;
  31443. /**
  31444. * Gets or sets the speed ratio to use for all animations
  31445. */
  31446. /**
  31447. * Gets or sets the speed ratio to use for all animations
  31448. */
  31449. speedRatio: number;
  31450. /**
  31451. * Gets the targeted animations for this animation group
  31452. */
  31453. readonly targetedAnimations: Array<TargetedAnimation>;
  31454. /**
  31455. * returning the list of animatables controlled by this animation group.
  31456. */
  31457. readonly animatables: Array<Animatable>;
  31458. /**
  31459. * Instantiates a new Animation Group.
  31460. * This helps managing several animations at once.
  31461. * @see http://doc.babylonjs.com/how_to/group
  31462. * @param name Defines the name of the group
  31463. * @param scene Defines the scene the group belongs to
  31464. */
  31465. constructor(
  31466. /** The name of the animation group */
  31467. name: string, scene?: Nullable<Scene>);
  31468. /**
  31469. * Add an animation (with its target) in the group
  31470. * @param animation defines the animation we want to add
  31471. * @param target defines the target of the animation
  31472. * @returns the TargetedAnimation object
  31473. */
  31474. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31475. /**
  31476. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31477. * It can add constant keys at begin or end
  31478. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31479. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31480. * @returns the animation group
  31481. */
  31482. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31483. /**
  31484. * Start all animations on given targets
  31485. * @param loop defines if animations must loop
  31486. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31487. * @param from defines the from key (optional)
  31488. * @param to defines the to key (optional)
  31489. * @returns the current animation group
  31490. */
  31491. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31492. /**
  31493. * Pause all animations
  31494. * @returns the animation group
  31495. */
  31496. pause(): AnimationGroup;
  31497. /**
  31498. * Play all animations to initial state
  31499. * This function will start() the animations if they were not started or will restart() them if they were paused
  31500. * @param loop defines if animations must loop
  31501. * @returns the animation group
  31502. */
  31503. play(loop?: boolean): AnimationGroup;
  31504. /**
  31505. * Reset all animations to initial state
  31506. * @returns the animation group
  31507. */
  31508. reset(): AnimationGroup;
  31509. /**
  31510. * Restart animations from key 0
  31511. * @returns the animation group
  31512. */
  31513. restart(): AnimationGroup;
  31514. /**
  31515. * Stop all animations
  31516. * @returns the animation group
  31517. */
  31518. stop(): AnimationGroup;
  31519. /**
  31520. * Set animation weight for all animatables
  31521. * @param weight defines the weight to use
  31522. * @return the animationGroup
  31523. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31524. */
  31525. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31526. /**
  31527. * Synchronize and normalize all animatables with a source animatable
  31528. * @param root defines the root animatable to synchronize with
  31529. * @return the animationGroup
  31530. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31531. */
  31532. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31533. /**
  31534. * Goes to a specific frame in this animation group
  31535. * @param frame the frame number to go to
  31536. * @return the animationGroup
  31537. */
  31538. goToFrame(frame: number): AnimationGroup;
  31539. /**
  31540. * Dispose all associated resources
  31541. */
  31542. dispose(): void;
  31543. private _checkAnimationGroupEnded;
  31544. /**
  31545. * Clone the current animation group and returns a copy
  31546. * @param newName defines the name of the new group
  31547. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31548. * @returns the new aniamtion group
  31549. */
  31550. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31551. /**
  31552. * Returns a new AnimationGroup object parsed from the source provided.
  31553. * @param parsedAnimationGroup defines the source
  31554. * @param scene defines the scene that will receive the animationGroup
  31555. * @returns a new AnimationGroup
  31556. */
  31557. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31558. /**
  31559. * Returns the string "AnimationGroup"
  31560. * @returns "AnimationGroup"
  31561. */
  31562. getClassName(): string;
  31563. /**
  31564. * Creates a detailled string about the object
  31565. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31566. * @returns a string representing the object
  31567. */
  31568. toString(fullDetails?: boolean): string;
  31569. }
  31570. }
  31571. declare module "babylonjs/scene" {
  31572. import { Nullable } from "babylonjs/types";
  31573. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31574. import { Observable } from "babylonjs/Misc/observable";
  31575. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31576. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31577. import { Geometry } from "babylonjs/Meshes/geometry";
  31578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31581. import { Mesh } from "babylonjs/Meshes/mesh";
  31582. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31583. import { Bone } from "babylonjs/Bones/bone";
  31584. import { Skeleton } from "babylonjs/Bones/skeleton";
  31585. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31586. import { Camera } from "babylonjs/Cameras/camera";
  31587. import { AbstractScene } from "babylonjs/abstractScene";
  31588. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31589. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31590. import { Material } from "babylonjs/Materials/material";
  31591. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31592. import { Effect } from "babylonjs/Materials/effect";
  31593. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31594. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31595. import { Light } from "babylonjs/Lights/light";
  31596. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31597. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31598. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31599. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31600. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31601. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31602. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31603. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31604. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31605. import { Engine } from "babylonjs/Engines/engine";
  31606. import { Node } from "babylonjs/node";
  31607. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31608. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31609. import { Ray } from "babylonjs/Culling/ray";
  31610. import { Animation } from "babylonjs/Animations/animation";
  31611. import { Animatable } from "babylonjs/Animations/animatable";
  31612. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31613. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31614. import { Collider } from "babylonjs/Collisions/collider";
  31615. /**
  31616. * Define an interface for all classes that will hold resources
  31617. */
  31618. export interface IDisposable {
  31619. /**
  31620. * Releases all held resources
  31621. */
  31622. dispose(): void;
  31623. }
  31624. /** Interface defining initialization parameters for Scene class */
  31625. export interface SceneOptions {
  31626. /**
  31627. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31628. * It will improve performance when the number of geometries becomes important.
  31629. */
  31630. useGeometryUniqueIdsMap?: boolean;
  31631. /**
  31632. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31633. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31634. */
  31635. useMaterialMeshMap?: boolean;
  31636. /**
  31637. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31638. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31639. */
  31640. useClonedMeshhMap?: boolean;
  31641. }
  31642. /**
  31643. * Represents a scene to be rendered by the engine.
  31644. * @see http://doc.babylonjs.com/features/scene
  31645. */
  31646. export class Scene extends AbstractScene implements IAnimatable {
  31647. private static _uniqueIdCounter;
  31648. /** The fog is deactivated */
  31649. static readonly FOGMODE_NONE: number;
  31650. /** The fog density is following an exponential function */
  31651. static readonly FOGMODE_EXP: number;
  31652. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31653. static readonly FOGMODE_EXP2: number;
  31654. /** The fog density is following a linear function. */
  31655. static readonly FOGMODE_LINEAR: number;
  31656. /**
  31657. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31659. */
  31660. static MinDeltaTime: number;
  31661. /**
  31662. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31664. */
  31665. static MaxDeltaTime: number;
  31666. /**
  31667. * Factory used to create the default material.
  31668. * @param name The name of the material to create
  31669. * @param scene The scene to create the material for
  31670. * @returns The default material
  31671. */
  31672. static DefaultMaterialFactory(scene: Scene): Material;
  31673. /**
  31674. * Factory used to create the a collision coordinator.
  31675. * @returns The collision coordinator
  31676. */
  31677. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31678. /** @hidden */
  31679. readonly _isScene: boolean;
  31680. /**
  31681. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31682. */
  31683. autoClear: boolean;
  31684. /**
  31685. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31686. */
  31687. autoClearDepthAndStencil: boolean;
  31688. /**
  31689. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31690. */
  31691. clearColor: Color4;
  31692. /**
  31693. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31694. */
  31695. ambientColor: Color3;
  31696. /** @hidden */
  31697. _environmentBRDFTexture: BaseTexture;
  31698. /** @hidden */
  31699. protected _environmentTexture: Nullable<BaseTexture>;
  31700. /**
  31701. * Texture used in all pbr material as the reflection texture.
  31702. * As in the majority of the scene they are the same (exception for multi room and so on),
  31703. * this is easier to reference from here than from all the materials.
  31704. */
  31705. /**
  31706. * Texture used in all pbr material as the reflection texture.
  31707. * As in the majority of the scene they are the same (exception for multi room and so on),
  31708. * this is easier to set here than in all the materials.
  31709. */
  31710. environmentTexture: Nullable<BaseTexture>;
  31711. /** @hidden */
  31712. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31713. /**
  31714. * Default image processing configuration used either in the rendering
  31715. * Forward main pass or through the imageProcessingPostProcess if present.
  31716. * As in the majority of the scene they are the same (exception for multi camera),
  31717. * this is easier to reference from here than from all the materials and post process.
  31718. *
  31719. * No setter as we it is a shared configuration, you can set the values instead.
  31720. */
  31721. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31722. private _forceWireframe;
  31723. /**
  31724. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31725. */
  31726. forceWireframe: boolean;
  31727. private _forcePointsCloud;
  31728. /**
  31729. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31730. */
  31731. forcePointsCloud: boolean;
  31732. /**
  31733. * Gets or sets the active clipplane 1
  31734. */
  31735. clipPlane: Nullable<Plane>;
  31736. /**
  31737. * Gets or sets the active clipplane 2
  31738. */
  31739. clipPlane2: Nullable<Plane>;
  31740. /**
  31741. * Gets or sets the active clipplane 3
  31742. */
  31743. clipPlane3: Nullable<Plane>;
  31744. /**
  31745. * Gets or sets the active clipplane 4
  31746. */
  31747. clipPlane4: Nullable<Plane>;
  31748. /**
  31749. * Gets or sets a boolean indicating if animations are enabled
  31750. */
  31751. animationsEnabled: boolean;
  31752. private _animationPropertiesOverride;
  31753. /**
  31754. * Gets or sets the animation properties override
  31755. */
  31756. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31757. /**
  31758. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31759. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31760. */
  31761. useConstantAnimationDeltaTime: boolean;
  31762. /**
  31763. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31764. * Please note that it requires to run a ray cast through the scene on every frame
  31765. */
  31766. constantlyUpdateMeshUnderPointer: boolean;
  31767. /**
  31768. * Defines the HTML cursor to use when hovering over interactive elements
  31769. */
  31770. hoverCursor: string;
  31771. /**
  31772. * Defines the HTML default cursor to use (empty by default)
  31773. */
  31774. defaultCursor: string;
  31775. /**
  31776. * This is used to call preventDefault() on pointer down
  31777. * in order to block unwanted artifacts like system double clicks
  31778. */
  31779. preventDefaultOnPointerDown: boolean;
  31780. /**
  31781. * This is used to call preventDefault() on pointer up
  31782. * in order to block unwanted artifacts like system double clicks
  31783. */
  31784. preventDefaultOnPointerUp: boolean;
  31785. /**
  31786. * Gets or sets user defined metadata
  31787. */
  31788. metadata: any;
  31789. /**
  31790. * For internal use only. Please do not use.
  31791. */
  31792. reservedDataStore: any;
  31793. /**
  31794. * Gets the name of the plugin used to load this scene (null by default)
  31795. */
  31796. loadingPluginName: string;
  31797. /**
  31798. * Use this array to add regular expressions used to disable offline support for specific urls
  31799. */
  31800. disableOfflineSupportExceptionRules: RegExp[];
  31801. /**
  31802. * An event triggered when the scene is disposed.
  31803. */
  31804. onDisposeObservable: Observable<Scene>;
  31805. private _onDisposeObserver;
  31806. /** Sets a function to be executed when this scene is disposed. */
  31807. onDispose: () => void;
  31808. /**
  31809. * An event triggered before rendering the scene (right after animations and physics)
  31810. */
  31811. onBeforeRenderObservable: Observable<Scene>;
  31812. private _onBeforeRenderObserver;
  31813. /** Sets a function to be executed before rendering this scene */
  31814. beforeRender: Nullable<() => void>;
  31815. /**
  31816. * An event triggered after rendering the scene
  31817. */
  31818. onAfterRenderObservable: Observable<Scene>;
  31819. private _onAfterRenderObserver;
  31820. /** Sets a function to be executed after rendering this scene */
  31821. afterRender: Nullable<() => void>;
  31822. /**
  31823. * An event triggered before animating the scene
  31824. */
  31825. onBeforeAnimationsObservable: Observable<Scene>;
  31826. /**
  31827. * An event triggered after animations processing
  31828. */
  31829. onAfterAnimationsObservable: Observable<Scene>;
  31830. /**
  31831. * An event triggered before draw calls are ready to be sent
  31832. */
  31833. onBeforeDrawPhaseObservable: Observable<Scene>;
  31834. /**
  31835. * An event triggered after draw calls have been sent
  31836. */
  31837. onAfterDrawPhaseObservable: Observable<Scene>;
  31838. /**
  31839. * An event triggered when the scene is ready
  31840. */
  31841. onReadyObservable: Observable<Scene>;
  31842. /**
  31843. * An event triggered before rendering a camera
  31844. */
  31845. onBeforeCameraRenderObservable: Observable<Camera>;
  31846. private _onBeforeCameraRenderObserver;
  31847. /** Sets a function to be executed before rendering a camera*/
  31848. beforeCameraRender: () => void;
  31849. /**
  31850. * An event triggered after rendering a camera
  31851. */
  31852. onAfterCameraRenderObservable: Observable<Camera>;
  31853. private _onAfterCameraRenderObserver;
  31854. /** Sets a function to be executed after rendering a camera*/
  31855. afterCameraRender: () => void;
  31856. /**
  31857. * An event triggered when active meshes evaluation is about to start
  31858. */
  31859. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31860. /**
  31861. * An event triggered when active meshes evaluation is done
  31862. */
  31863. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31864. /**
  31865. * An event triggered when particles rendering is about to start
  31866. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31867. */
  31868. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31869. /**
  31870. * An event triggered when particles rendering is done
  31871. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31872. */
  31873. onAfterParticlesRenderingObservable: Observable<Scene>;
  31874. /**
  31875. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31876. */
  31877. onDataLoadedObservable: Observable<Scene>;
  31878. /**
  31879. * An event triggered when a camera is created
  31880. */
  31881. onNewCameraAddedObservable: Observable<Camera>;
  31882. /**
  31883. * An event triggered when a camera is removed
  31884. */
  31885. onCameraRemovedObservable: Observable<Camera>;
  31886. /**
  31887. * An event triggered when a light is created
  31888. */
  31889. onNewLightAddedObservable: Observable<Light>;
  31890. /**
  31891. * An event triggered when a light is removed
  31892. */
  31893. onLightRemovedObservable: Observable<Light>;
  31894. /**
  31895. * An event triggered when a geometry is created
  31896. */
  31897. onNewGeometryAddedObservable: Observable<Geometry>;
  31898. /**
  31899. * An event triggered when a geometry is removed
  31900. */
  31901. onGeometryRemovedObservable: Observable<Geometry>;
  31902. /**
  31903. * An event triggered when a transform node is created
  31904. */
  31905. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31906. /**
  31907. * An event triggered when a transform node is removed
  31908. */
  31909. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31910. /**
  31911. * An event triggered when a mesh is created
  31912. */
  31913. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31914. /**
  31915. * An event triggered when a mesh is removed
  31916. */
  31917. onMeshRemovedObservable: Observable<AbstractMesh>;
  31918. /**
  31919. * An event triggered when a material is created
  31920. */
  31921. onNewMaterialAddedObservable: Observable<Material>;
  31922. /**
  31923. * An event triggered when a material is removed
  31924. */
  31925. onMaterialRemovedObservable: Observable<Material>;
  31926. /**
  31927. * An event triggered when a texture is created
  31928. */
  31929. onNewTextureAddedObservable: Observable<BaseTexture>;
  31930. /**
  31931. * An event triggered when a texture is removed
  31932. */
  31933. onTextureRemovedObservable: Observable<BaseTexture>;
  31934. /**
  31935. * An event triggered when render targets are about to be rendered
  31936. * Can happen multiple times per frame.
  31937. */
  31938. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31939. /**
  31940. * An event triggered when render targets were rendered.
  31941. * Can happen multiple times per frame.
  31942. */
  31943. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31944. /**
  31945. * An event triggered before calculating deterministic simulation step
  31946. */
  31947. onBeforeStepObservable: Observable<Scene>;
  31948. /**
  31949. * An event triggered after calculating deterministic simulation step
  31950. */
  31951. onAfterStepObservable: Observable<Scene>;
  31952. /**
  31953. * An event triggered when the activeCamera property is updated
  31954. */
  31955. onActiveCameraChanged: Observable<Scene>;
  31956. /**
  31957. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31958. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31959. * 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)
  31960. */
  31961. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31962. /**
  31963. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31964. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31965. * 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)
  31966. */
  31967. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31968. /**
  31969. * This Observable will when a mesh has been imported into the scene.
  31970. */
  31971. onMeshImportedObservable: Observable<AbstractMesh>;
  31972. /** @hidden */
  31973. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31974. /**
  31975. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31976. */
  31977. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31978. /**
  31979. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31980. */
  31981. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31982. /**
  31983. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31984. */
  31985. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31986. private _onPointerMove;
  31987. private _onPointerDown;
  31988. private _onPointerUp;
  31989. /** Callback called when a pointer move is detected */
  31990. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31991. /** Callback called when a pointer down is detected */
  31992. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31993. /** Callback called when a pointer up is detected */
  31994. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31995. /** Callback called when a pointer pick is detected */
  31996. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31997. /**
  31998. * 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).
  31999. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32000. */
  32001. onPrePointerObservable: Observable<PointerInfoPre>;
  32002. /**
  32003. * Observable event triggered each time an input event is received from the rendering canvas
  32004. */
  32005. onPointerObservable: Observable<PointerInfo>;
  32006. /**
  32007. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32008. */
  32009. readonly unTranslatedPointer: Vector2;
  32010. /** The distance in pixel that you have to move to prevent some events */
  32011. static DragMovementThreshold: number;
  32012. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32013. static LongPressDelay: number;
  32014. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32015. static DoubleClickDelay: number;
  32016. /** If you need to check double click without raising a single click at first click, enable this flag */
  32017. static ExclusiveDoubleClickMode: boolean;
  32018. private _initClickEvent;
  32019. private _initActionManager;
  32020. private _delayedSimpleClick;
  32021. private _delayedSimpleClickTimeout;
  32022. private _previousDelayedSimpleClickTimeout;
  32023. private _meshPickProceed;
  32024. private _previousButtonPressed;
  32025. private _currentPickResult;
  32026. private _previousPickResult;
  32027. private _totalPointersPressed;
  32028. private _doubleClickOccured;
  32029. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32030. cameraToUseForPointers: Nullable<Camera>;
  32031. private _pointerX;
  32032. private _pointerY;
  32033. private _unTranslatedPointerX;
  32034. private _unTranslatedPointerY;
  32035. private _startingPointerPosition;
  32036. private _previousStartingPointerPosition;
  32037. private _startingPointerTime;
  32038. private _previousStartingPointerTime;
  32039. private _pointerCaptures;
  32040. private _timeAccumulator;
  32041. private _currentStepId;
  32042. private _currentInternalStep;
  32043. /** @hidden */
  32044. _mirroredCameraPosition: Nullable<Vector3>;
  32045. /**
  32046. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32047. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32048. */
  32049. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32050. /**
  32051. * Observable event triggered each time an keyboard event is received from the hosting window
  32052. */
  32053. onKeyboardObservable: Observable<KeyboardInfo>;
  32054. private _onKeyDown;
  32055. private _onKeyUp;
  32056. private _onCanvasFocusObserver;
  32057. private _onCanvasBlurObserver;
  32058. private _useRightHandedSystem;
  32059. /**
  32060. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32061. */
  32062. useRightHandedSystem: boolean;
  32063. /**
  32064. * Sets the step Id used by deterministic lock step
  32065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32066. * @param newStepId defines the step Id
  32067. */
  32068. setStepId(newStepId: number): void;
  32069. /**
  32070. * Gets the step Id used by deterministic lock step
  32071. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32072. * @returns the step Id
  32073. */
  32074. getStepId(): number;
  32075. /**
  32076. * Gets the internal step used by deterministic lock step
  32077. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32078. * @returns the internal step
  32079. */
  32080. getInternalStep(): number;
  32081. private _fogEnabled;
  32082. /**
  32083. * Gets or sets a boolean indicating if fog is enabled on this scene
  32084. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32085. * (Default is true)
  32086. */
  32087. fogEnabled: boolean;
  32088. private _fogMode;
  32089. /**
  32090. * Gets or sets the fog mode to use
  32091. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32092. * | mode | value |
  32093. * | --- | --- |
  32094. * | FOGMODE_NONE | 0 |
  32095. * | FOGMODE_EXP | 1 |
  32096. * | FOGMODE_EXP2 | 2 |
  32097. * | FOGMODE_LINEAR | 3 |
  32098. */
  32099. fogMode: number;
  32100. /**
  32101. * Gets or sets the fog color to use
  32102. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32103. * (Default is Color3(0.2, 0.2, 0.3))
  32104. */
  32105. fogColor: Color3;
  32106. /**
  32107. * Gets or sets the fog density to use
  32108. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32109. * (Default is 0.1)
  32110. */
  32111. fogDensity: number;
  32112. /**
  32113. * Gets or sets the fog start distance to use
  32114. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32115. * (Default is 0)
  32116. */
  32117. fogStart: number;
  32118. /**
  32119. * Gets or sets the fog end distance to use
  32120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32121. * (Default is 1000)
  32122. */
  32123. fogEnd: number;
  32124. private _shadowsEnabled;
  32125. /**
  32126. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32127. */
  32128. shadowsEnabled: boolean;
  32129. private _lightsEnabled;
  32130. /**
  32131. * Gets or sets a boolean indicating if lights are enabled on this scene
  32132. */
  32133. lightsEnabled: boolean;
  32134. /** All of the active cameras added to this scene. */
  32135. activeCameras: Camera[];
  32136. private _activeCamera;
  32137. /** Gets or sets the current active camera */
  32138. activeCamera: Nullable<Camera>;
  32139. private _defaultMaterial;
  32140. /** The default material used on meshes when no material is affected */
  32141. /** The default material used on meshes when no material is affected */
  32142. defaultMaterial: Material;
  32143. private _texturesEnabled;
  32144. /**
  32145. * Gets or sets a boolean indicating if textures are enabled on this scene
  32146. */
  32147. texturesEnabled: boolean;
  32148. /**
  32149. * Gets or sets a boolean indicating if particles are enabled on this scene
  32150. */
  32151. particlesEnabled: boolean;
  32152. /**
  32153. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32154. */
  32155. spritesEnabled: boolean;
  32156. private _skeletonsEnabled;
  32157. /**
  32158. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32159. */
  32160. skeletonsEnabled: boolean;
  32161. /**
  32162. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32163. */
  32164. lensFlaresEnabled: boolean;
  32165. /**
  32166. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32167. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32168. */
  32169. collisionsEnabled: boolean;
  32170. private _collisionCoordinator;
  32171. /** @hidden */
  32172. readonly collisionCoordinator: ICollisionCoordinator;
  32173. /**
  32174. * Defines the gravity applied to this scene (used only for collisions)
  32175. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32176. */
  32177. gravity: Vector3;
  32178. /**
  32179. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32180. */
  32181. postProcessesEnabled: boolean;
  32182. /**
  32183. * The list of postprocesses added to the scene
  32184. */
  32185. postProcesses: PostProcess[];
  32186. /**
  32187. * Gets the current postprocess manager
  32188. */
  32189. postProcessManager: PostProcessManager;
  32190. /**
  32191. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32192. */
  32193. renderTargetsEnabled: boolean;
  32194. /**
  32195. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32196. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32197. */
  32198. dumpNextRenderTargets: boolean;
  32199. /**
  32200. * The list of user defined render targets added to the scene
  32201. */
  32202. customRenderTargets: RenderTargetTexture[];
  32203. /**
  32204. * Defines if texture loading must be delayed
  32205. * If true, textures will only be loaded when they need to be rendered
  32206. */
  32207. useDelayedTextureLoading: boolean;
  32208. /**
  32209. * Gets the list of meshes imported to the scene through SceneLoader
  32210. */
  32211. importedMeshesFiles: String[];
  32212. /**
  32213. * Gets or sets a boolean indicating if probes are enabled on this scene
  32214. */
  32215. probesEnabled: boolean;
  32216. /**
  32217. * Gets or sets the current offline provider to use to store scene data
  32218. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32219. */
  32220. offlineProvider: IOfflineProvider;
  32221. /**
  32222. * Gets or sets the action manager associated with the scene
  32223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32224. */
  32225. actionManager: AbstractActionManager;
  32226. private _meshesForIntersections;
  32227. /**
  32228. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32229. */
  32230. proceduralTexturesEnabled: boolean;
  32231. private _engine;
  32232. private _totalVertices;
  32233. /** @hidden */
  32234. _activeIndices: PerfCounter;
  32235. /** @hidden */
  32236. _activeParticles: PerfCounter;
  32237. /** @hidden */
  32238. _activeBones: PerfCounter;
  32239. private _animationRatio;
  32240. /** @hidden */
  32241. _animationTimeLast: number;
  32242. /** @hidden */
  32243. _animationTime: number;
  32244. /**
  32245. * Gets or sets a general scale for animation speed
  32246. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32247. */
  32248. animationTimeScale: number;
  32249. /** @hidden */
  32250. _cachedMaterial: Nullable<Material>;
  32251. /** @hidden */
  32252. _cachedEffect: Nullable<Effect>;
  32253. /** @hidden */
  32254. _cachedVisibility: Nullable<number>;
  32255. private _renderId;
  32256. private _frameId;
  32257. private _executeWhenReadyTimeoutId;
  32258. private _intermediateRendering;
  32259. private _viewUpdateFlag;
  32260. private _projectionUpdateFlag;
  32261. private _alternateViewUpdateFlag;
  32262. private _alternateProjectionUpdateFlag;
  32263. /** @hidden */
  32264. _toBeDisposed: Nullable<IDisposable>[];
  32265. private _activeRequests;
  32266. /** @hidden */
  32267. _pendingData: any[];
  32268. private _isDisposed;
  32269. /**
  32270. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32271. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32272. */
  32273. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32274. private _activeMeshes;
  32275. private _processedMaterials;
  32276. private _renderTargets;
  32277. /** @hidden */
  32278. _activeParticleSystems: SmartArray<IParticleSystem>;
  32279. private _activeSkeletons;
  32280. private _softwareSkinnedMeshes;
  32281. private _renderingManager;
  32282. /** @hidden */
  32283. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32284. private _transformMatrix;
  32285. private _sceneUbo;
  32286. private _alternateSceneUbo;
  32287. private _viewMatrix;
  32288. private _projectionMatrix;
  32289. private _alternateViewMatrix;
  32290. private _alternateProjectionMatrix;
  32291. private _alternateTransformMatrix;
  32292. private _useAlternateCameraConfiguration;
  32293. private _alternateRendering;
  32294. private _wheelEventName;
  32295. /** @hidden */
  32296. _forcedViewPosition: Nullable<Vector3>;
  32297. /** @hidden */
  32298. readonly _isAlternateRenderingEnabled: boolean;
  32299. private _frustumPlanes;
  32300. /**
  32301. * Gets the list of frustum planes (built from the active camera)
  32302. */
  32303. readonly frustumPlanes: Plane[];
  32304. /**
  32305. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32306. * This is useful if there are more lights that the maximum simulteanous authorized
  32307. */
  32308. requireLightSorting: boolean;
  32309. /** @hidden */
  32310. readonly useMaterialMeshMap: boolean;
  32311. /** @hidden */
  32312. readonly useClonedMeshhMap: boolean;
  32313. private _pointerOverMesh;
  32314. private _pickedDownMesh;
  32315. private _pickedUpMesh;
  32316. private _externalData;
  32317. private _uid;
  32318. /**
  32319. * @hidden
  32320. * Backing store of defined scene components.
  32321. */
  32322. _components: ISceneComponent[];
  32323. /**
  32324. * @hidden
  32325. * Backing store of defined scene components.
  32326. */
  32327. _serializableComponents: ISceneSerializableComponent[];
  32328. /**
  32329. * List of components to register on the next registration step.
  32330. */
  32331. private _transientComponents;
  32332. /**
  32333. * Registers the transient components if needed.
  32334. */
  32335. private _registerTransientComponents;
  32336. /**
  32337. * @hidden
  32338. * Add a component to the scene.
  32339. * Note that the ccomponent could be registered on th next frame if this is called after
  32340. * the register component stage.
  32341. * @param component Defines the component to add to the scene
  32342. */
  32343. _addComponent(component: ISceneComponent): void;
  32344. /**
  32345. * @hidden
  32346. * Gets a component from the scene.
  32347. * @param name defines the name of the component to retrieve
  32348. * @returns the component or null if not present
  32349. */
  32350. _getComponent(name: string): Nullable<ISceneComponent>;
  32351. /**
  32352. * @hidden
  32353. * Defines the actions happening before camera updates.
  32354. */
  32355. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32356. /**
  32357. * @hidden
  32358. * Defines the actions happening before clear the canvas.
  32359. */
  32360. _beforeClearStage: Stage<SimpleStageAction>;
  32361. /**
  32362. * @hidden
  32363. * Defines the actions when collecting render targets for the frame.
  32364. */
  32365. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32366. /**
  32367. * @hidden
  32368. * Defines the actions happening for one camera in the frame.
  32369. */
  32370. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32371. /**
  32372. * @hidden
  32373. * Defines the actions happening during the per mesh ready checks.
  32374. */
  32375. _isReadyForMeshStage: Stage<MeshStageAction>;
  32376. /**
  32377. * @hidden
  32378. * Defines the actions happening before evaluate active mesh checks.
  32379. */
  32380. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32381. /**
  32382. * @hidden
  32383. * Defines the actions happening during the evaluate sub mesh checks.
  32384. */
  32385. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32386. /**
  32387. * @hidden
  32388. * Defines the actions happening during the active mesh stage.
  32389. */
  32390. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32391. /**
  32392. * @hidden
  32393. * Defines the actions happening during the per camera render target step.
  32394. */
  32395. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32396. /**
  32397. * @hidden
  32398. * Defines the actions happening just before the active camera is drawing.
  32399. */
  32400. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32401. /**
  32402. * @hidden
  32403. * Defines the actions happening just before a render target is drawing.
  32404. */
  32405. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32406. /**
  32407. * @hidden
  32408. * Defines the actions happening just before a rendering group is drawing.
  32409. */
  32410. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32411. /**
  32412. * @hidden
  32413. * Defines the actions happening just before a mesh is drawing.
  32414. */
  32415. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32416. /**
  32417. * @hidden
  32418. * Defines the actions happening just after a mesh has been drawn.
  32419. */
  32420. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32421. /**
  32422. * @hidden
  32423. * Defines the actions happening just after a rendering group has been drawn.
  32424. */
  32425. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32426. /**
  32427. * @hidden
  32428. * Defines the actions happening just after the active camera has been drawn.
  32429. */
  32430. _afterCameraDrawStage: Stage<CameraStageAction>;
  32431. /**
  32432. * @hidden
  32433. * Defines the actions happening just after a render target has been drawn.
  32434. */
  32435. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32436. /**
  32437. * @hidden
  32438. * Defines the actions happening just after rendering all cameras and computing intersections.
  32439. */
  32440. _afterRenderStage: Stage<SimpleStageAction>;
  32441. /**
  32442. * @hidden
  32443. * Defines the actions happening when a pointer move event happens.
  32444. */
  32445. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32446. /**
  32447. * @hidden
  32448. * Defines the actions happening when a pointer down event happens.
  32449. */
  32450. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32451. /**
  32452. * @hidden
  32453. * Defines the actions happening when a pointer up event happens.
  32454. */
  32455. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32456. /**
  32457. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32458. */
  32459. private geometriesByUniqueId;
  32460. /**
  32461. * Creates a new Scene
  32462. * @param engine defines the engine to use to render this scene
  32463. * @param options defines the scene options
  32464. */
  32465. constructor(engine: Engine, options?: SceneOptions);
  32466. private _defaultMeshCandidates;
  32467. /**
  32468. * @hidden
  32469. */
  32470. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32471. private _defaultSubMeshCandidates;
  32472. /**
  32473. * @hidden
  32474. */
  32475. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32476. /**
  32477. * Sets the default candidate providers for the scene.
  32478. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32479. * and getCollidingSubMeshCandidates to their default function
  32480. */
  32481. setDefaultCandidateProviders(): void;
  32482. /**
  32483. * Gets the mesh that is currently under the pointer
  32484. */
  32485. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32486. /**
  32487. * Gets or sets the current on-screen X position of the pointer
  32488. */
  32489. pointerX: number;
  32490. /**
  32491. * Gets or sets the current on-screen Y position of the pointer
  32492. */
  32493. pointerY: number;
  32494. /**
  32495. * Gets the cached material (ie. the latest rendered one)
  32496. * @returns the cached material
  32497. */
  32498. getCachedMaterial(): Nullable<Material>;
  32499. /**
  32500. * Gets the cached effect (ie. the latest rendered one)
  32501. * @returns the cached effect
  32502. */
  32503. getCachedEffect(): Nullable<Effect>;
  32504. /**
  32505. * Gets the cached visibility state (ie. the latest rendered one)
  32506. * @returns the cached visibility state
  32507. */
  32508. getCachedVisibility(): Nullable<number>;
  32509. /**
  32510. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32511. * @param material defines the current material
  32512. * @param effect defines the current effect
  32513. * @param visibility defines the current visibility state
  32514. * @returns true if one parameter is not cached
  32515. */
  32516. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32517. /**
  32518. * Gets the engine associated with the scene
  32519. * @returns an Engine
  32520. */
  32521. getEngine(): Engine;
  32522. /**
  32523. * Gets the total number of vertices rendered per frame
  32524. * @returns the total number of vertices rendered per frame
  32525. */
  32526. getTotalVertices(): number;
  32527. /**
  32528. * Gets the performance counter for total vertices
  32529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32530. */
  32531. readonly totalVerticesPerfCounter: PerfCounter;
  32532. /**
  32533. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32534. * @returns the total number of active indices rendered per frame
  32535. */
  32536. getActiveIndices(): number;
  32537. /**
  32538. * Gets the performance counter for active indices
  32539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32540. */
  32541. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32542. /**
  32543. * Gets the total number of active particles rendered per frame
  32544. * @returns the total number of active particles rendered per frame
  32545. */
  32546. getActiveParticles(): number;
  32547. /**
  32548. * Gets the performance counter for active particles
  32549. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32550. */
  32551. readonly activeParticlesPerfCounter: PerfCounter;
  32552. /**
  32553. * Gets the total number of active bones rendered per frame
  32554. * @returns the total number of active bones rendered per frame
  32555. */
  32556. getActiveBones(): number;
  32557. /**
  32558. * Gets the performance counter for active bones
  32559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32560. */
  32561. readonly activeBonesPerfCounter: PerfCounter;
  32562. /**
  32563. * Gets the array of active meshes
  32564. * @returns an array of AbstractMesh
  32565. */
  32566. getActiveMeshes(): SmartArray<AbstractMesh>;
  32567. /**
  32568. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32569. * @returns a number
  32570. */
  32571. getAnimationRatio(): number;
  32572. /**
  32573. * Gets an unique Id for the current render phase
  32574. * @returns a number
  32575. */
  32576. getRenderId(): number;
  32577. /**
  32578. * Gets an unique Id for the current frame
  32579. * @returns a number
  32580. */
  32581. getFrameId(): number;
  32582. /** Call this function if you want to manually increment the render Id*/
  32583. incrementRenderId(): void;
  32584. private _updatePointerPosition;
  32585. private _createUbo;
  32586. private _createAlternateUbo;
  32587. private _setRayOnPointerInfo;
  32588. /**
  32589. * Use this method to simulate a pointer move on a mesh
  32590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32593. * @returns the current scene
  32594. */
  32595. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32596. private _processPointerMove;
  32597. private _checkPrePointerObservable;
  32598. /**
  32599. * Use this method to simulate a pointer down on a mesh
  32600. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32601. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32602. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32603. * @returns the current scene
  32604. */
  32605. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32606. private _processPointerDown;
  32607. /**
  32608. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32613. * @returns the current scene
  32614. */
  32615. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32616. private _processPointerUp;
  32617. /**
  32618. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32619. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32620. * @returns true if the pointer was captured
  32621. */
  32622. isPointerCaptured(pointerId?: number): boolean;
  32623. /** @hidden */
  32624. _isPointerSwiping(): boolean;
  32625. /**
  32626. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32627. * @param attachUp defines if you want to attach events to pointerup
  32628. * @param attachDown defines if you want to attach events to pointerdown
  32629. * @param attachMove defines if you want to attach events to pointermove
  32630. */
  32631. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32632. /** Detaches all event handlers*/
  32633. detachControl(): void;
  32634. /**
  32635. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32636. * Delay loaded resources are not taking in account
  32637. * @return true if all required resources are ready
  32638. */
  32639. isReady(): boolean;
  32640. /** Resets all cached information relative to material (including effect and visibility) */
  32641. resetCachedMaterial(): void;
  32642. /**
  32643. * Registers a function to be called before every frame render
  32644. * @param func defines the function to register
  32645. */
  32646. registerBeforeRender(func: () => void): void;
  32647. /**
  32648. * Unregisters a function called before every frame render
  32649. * @param func defines the function to unregister
  32650. */
  32651. unregisterBeforeRender(func: () => void): void;
  32652. /**
  32653. * Registers a function to be called after every frame render
  32654. * @param func defines the function to register
  32655. */
  32656. registerAfterRender(func: () => void): void;
  32657. /**
  32658. * Unregisters a function called after every frame render
  32659. * @param func defines the function to unregister
  32660. */
  32661. unregisterAfterRender(func: () => void): void;
  32662. private _executeOnceBeforeRender;
  32663. /**
  32664. * The provided function will run before render once and will be disposed afterwards.
  32665. * A timeout delay can be provided so that the function will be executed in N ms.
  32666. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32667. * @param func The function to be executed.
  32668. * @param timeout optional delay in ms
  32669. */
  32670. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32671. /** @hidden */
  32672. _addPendingData(data: any): void;
  32673. /** @hidden */
  32674. _removePendingData(data: any): void;
  32675. /**
  32676. * Returns the number of items waiting to be loaded
  32677. * @returns the number of items waiting to be loaded
  32678. */
  32679. getWaitingItemsCount(): number;
  32680. /**
  32681. * Returns a boolean indicating if the scene is still loading data
  32682. */
  32683. readonly isLoading: boolean;
  32684. /**
  32685. * Registers a function to be executed when the scene is ready
  32686. * @param {Function} func - the function to be executed
  32687. */
  32688. executeWhenReady(func: () => void): void;
  32689. /**
  32690. * Returns a promise that resolves when the scene is ready
  32691. * @returns A promise that resolves when the scene is ready
  32692. */
  32693. whenReadyAsync(): Promise<void>;
  32694. /** @hidden */
  32695. _checkIsReady(): void;
  32696. /**
  32697. * Gets all animatable attached to the scene
  32698. */
  32699. readonly animatables: Animatable[];
  32700. /**
  32701. * Resets the last animation time frame.
  32702. * Useful to override when animations start running when loading a scene for the first time.
  32703. */
  32704. resetLastAnimationTimeFrame(): void;
  32705. /** @hidden */
  32706. _switchToAlternateCameraConfiguration(active: boolean): void;
  32707. /**
  32708. * Gets the current view matrix
  32709. * @returns a Matrix
  32710. */
  32711. getViewMatrix(): Matrix;
  32712. /**
  32713. * Gets the current projection matrix
  32714. * @returns a Matrix
  32715. */
  32716. getProjectionMatrix(): Matrix;
  32717. /**
  32718. * Gets the current transform matrix
  32719. * @returns a Matrix made of View * Projection
  32720. */
  32721. getTransformMatrix(): Matrix;
  32722. /**
  32723. * Sets the current transform matrix
  32724. * @param view defines the View matrix to use
  32725. * @param projection defines the Projection matrix to use
  32726. */
  32727. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32728. /** @hidden */
  32729. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32730. /**
  32731. * Gets the uniform buffer used to store scene data
  32732. * @returns a UniformBuffer
  32733. */
  32734. getSceneUniformBuffer(): UniformBuffer;
  32735. /**
  32736. * Gets an unique (relatively to the current scene) Id
  32737. * @returns an unique number for the scene
  32738. */
  32739. getUniqueId(): number;
  32740. /**
  32741. * Add a mesh to the list of scene's meshes
  32742. * @param newMesh defines the mesh to add
  32743. * @param recursive if all child meshes should also be added to the scene
  32744. */
  32745. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32746. /**
  32747. * Remove a mesh for the list of scene's meshes
  32748. * @param toRemove defines the mesh to remove
  32749. * @param recursive if all child meshes should also be removed from the scene
  32750. * @returns the index where the mesh was in the mesh list
  32751. */
  32752. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32753. /**
  32754. * Add a transform node to the list of scene's transform nodes
  32755. * @param newTransformNode defines the transform node to add
  32756. */
  32757. addTransformNode(newTransformNode: TransformNode): void;
  32758. /**
  32759. * Remove a transform node for the list of scene's transform nodes
  32760. * @param toRemove defines the transform node to remove
  32761. * @returns the index where the transform node was in the transform node list
  32762. */
  32763. removeTransformNode(toRemove: TransformNode): number;
  32764. /**
  32765. * Remove a skeleton for the list of scene's skeletons
  32766. * @param toRemove defines the skeleton to remove
  32767. * @returns the index where the skeleton was in the skeleton list
  32768. */
  32769. removeSkeleton(toRemove: Skeleton): number;
  32770. /**
  32771. * Remove a morph target for the list of scene's morph targets
  32772. * @param toRemove defines the morph target to remove
  32773. * @returns the index where the morph target was in the morph target list
  32774. */
  32775. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32776. /**
  32777. * Remove a light for the list of scene's lights
  32778. * @param toRemove defines the light to remove
  32779. * @returns the index where the light was in the light list
  32780. */
  32781. removeLight(toRemove: Light): number;
  32782. /**
  32783. * Remove a camera for the list of scene's cameras
  32784. * @param toRemove defines the camera to remove
  32785. * @returns the index where the camera was in the camera list
  32786. */
  32787. removeCamera(toRemove: Camera): number;
  32788. /**
  32789. * Remove a particle system for the list of scene's particle systems
  32790. * @param toRemove defines the particle system to remove
  32791. * @returns the index where the particle system was in the particle system list
  32792. */
  32793. removeParticleSystem(toRemove: IParticleSystem): number;
  32794. /**
  32795. * Remove a animation for the list of scene's animations
  32796. * @param toRemove defines the animation to remove
  32797. * @returns the index where the animation was in the animation list
  32798. */
  32799. removeAnimation(toRemove: Animation): number;
  32800. /**
  32801. * Removes the given animation group from this scene.
  32802. * @param toRemove The animation group to remove
  32803. * @returns The index of the removed animation group
  32804. */
  32805. removeAnimationGroup(toRemove: AnimationGroup): number;
  32806. /**
  32807. * Removes the given multi-material from this scene.
  32808. * @param toRemove The multi-material to remove
  32809. * @returns The index of the removed multi-material
  32810. */
  32811. removeMultiMaterial(toRemove: MultiMaterial): number;
  32812. /**
  32813. * Removes the given material from this scene.
  32814. * @param toRemove The material to remove
  32815. * @returns The index of the removed material
  32816. */
  32817. removeMaterial(toRemove: Material): number;
  32818. /**
  32819. * Removes the given action manager from this scene.
  32820. * @param toRemove The action manager to remove
  32821. * @returns The index of the removed action manager
  32822. */
  32823. removeActionManager(toRemove: AbstractActionManager): number;
  32824. /**
  32825. * Removes the given texture from this scene.
  32826. * @param toRemove The texture to remove
  32827. * @returns The index of the removed texture
  32828. */
  32829. removeTexture(toRemove: BaseTexture): number;
  32830. /**
  32831. * Adds the given light to this scene
  32832. * @param newLight The light to add
  32833. */
  32834. addLight(newLight: Light): void;
  32835. /**
  32836. * Sorts the list list based on light priorities
  32837. */
  32838. sortLightsByPriority(): void;
  32839. /**
  32840. * Adds the given camera to this scene
  32841. * @param newCamera The camera to add
  32842. */
  32843. addCamera(newCamera: Camera): void;
  32844. /**
  32845. * Adds the given skeleton to this scene
  32846. * @param newSkeleton The skeleton to add
  32847. */
  32848. addSkeleton(newSkeleton: Skeleton): void;
  32849. /**
  32850. * Adds the given particle system to this scene
  32851. * @param newParticleSystem The particle system to add
  32852. */
  32853. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32854. /**
  32855. * Adds the given animation to this scene
  32856. * @param newAnimation The animation to add
  32857. */
  32858. addAnimation(newAnimation: Animation): void;
  32859. /**
  32860. * Adds the given animation group to this scene.
  32861. * @param newAnimationGroup The animation group to add
  32862. */
  32863. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32864. /**
  32865. * Adds the given multi-material to this scene
  32866. * @param newMultiMaterial The multi-material to add
  32867. */
  32868. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32869. /**
  32870. * Adds the given material to this scene
  32871. * @param newMaterial The material to add
  32872. */
  32873. addMaterial(newMaterial: Material): void;
  32874. /**
  32875. * Adds the given morph target to this scene
  32876. * @param newMorphTargetManager The morph target to add
  32877. */
  32878. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32879. /**
  32880. * Adds the given geometry to this scene
  32881. * @param newGeometry The geometry to add
  32882. */
  32883. addGeometry(newGeometry: Geometry): void;
  32884. /**
  32885. * Adds the given action manager to this scene
  32886. * @param newActionManager The action manager to add
  32887. */
  32888. addActionManager(newActionManager: AbstractActionManager): void;
  32889. /**
  32890. * Adds the given texture to this scene.
  32891. * @param newTexture The texture to add
  32892. */
  32893. addTexture(newTexture: BaseTexture): void;
  32894. /**
  32895. * Switch active camera
  32896. * @param newCamera defines the new active camera
  32897. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32898. */
  32899. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32900. /**
  32901. * sets the active camera of the scene using its ID
  32902. * @param id defines the camera's ID
  32903. * @return the new active camera or null if none found.
  32904. */
  32905. setActiveCameraByID(id: string): Nullable<Camera>;
  32906. /**
  32907. * sets the active camera of the scene using its name
  32908. * @param name defines the camera's name
  32909. * @returns the new active camera or null if none found.
  32910. */
  32911. setActiveCameraByName(name: string): Nullable<Camera>;
  32912. /**
  32913. * get an animation group using its name
  32914. * @param name defines the material's name
  32915. * @return the animation group or null if none found.
  32916. */
  32917. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32918. /**
  32919. * get a material using its id
  32920. * @param id defines the material's ID
  32921. * @return the material or null if none found.
  32922. */
  32923. getMaterialByID(id: string): Nullable<Material>;
  32924. /**
  32925. * Gets a material using its name
  32926. * @param name defines the material's name
  32927. * @return the material or null if none found.
  32928. */
  32929. getMaterialByName(name: string): Nullable<Material>;
  32930. /**
  32931. * Gets a camera using its id
  32932. * @param id defines the id to look for
  32933. * @returns the camera or null if not found
  32934. */
  32935. getCameraByID(id: string): Nullable<Camera>;
  32936. /**
  32937. * Gets a camera using its unique id
  32938. * @param uniqueId defines the unique id to look for
  32939. * @returns the camera or null if not found
  32940. */
  32941. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32942. /**
  32943. * Gets a camera using its name
  32944. * @param name defines the camera's name
  32945. * @return the camera or null if none found.
  32946. */
  32947. getCameraByName(name: string): Nullable<Camera>;
  32948. /**
  32949. * Gets a bone using its id
  32950. * @param id defines the bone's id
  32951. * @return the bone or null if not found
  32952. */
  32953. getBoneByID(id: string): Nullable<Bone>;
  32954. /**
  32955. * Gets a bone using its id
  32956. * @param name defines the bone's name
  32957. * @return the bone or null if not found
  32958. */
  32959. getBoneByName(name: string): Nullable<Bone>;
  32960. /**
  32961. * Gets a light node using its name
  32962. * @param name defines the the light's name
  32963. * @return the light or null if none found.
  32964. */
  32965. getLightByName(name: string): Nullable<Light>;
  32966. /**
  32967. * Gets a light node using its id
  32968. * @param id defines the light's id
  32969. * @return the light or null if none found.
  32970. */
  32971. getLightByID(id: string): Nullable<Light>;
  32972. /**
  32973. * Gets a light node using its scene-generated unique ID
  32974. * @param uniqueId defines the light's unique id
  32975. * @return the light or null if none found.
  32976. */
  32977. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32978. /**
  32979. * Gets a particle system by id
  32980. * @param id defines the particle system id
  32981. * @return the corresponding system or null if none found
  32982. */
  32983. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32984. /**
  32985. * Gets a geometry using its ID
  32986. * @param id defines the geometry's id
  32987. * @return the geometry or null if none found.
  32988. */
  32989. getGeometryByID(id: string): Nullable<Geometry>;
  32990. private _getGeometryByUniqueID;
  32991. /**
  32992. * Add a new geometry to this scene
  32993. * @param geometry defines the geometry to be added to the scene.
  32994. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32995. * @return a boolean defining if the geometry was added or not
  32996. */
  32997. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32998. /**
  32999. * Removes an existing geometry
  33000. * @param geometry defines the geometry to be removed from the scene
  33001. * @return a boolean defining if the geometry was removed or not
  33002. */
  33003. removeGeometry(geometry: Geometry): boolean;
  33004. /**
  33005. * Gets the list of geometries attached to the scene
  33006. * @returns an array of Geometry
  33007. */
  33008. getGeometries(): Geometry[];
  33009. /**
  33010. * Gets the first added mesh found of a given ID
  33011. * @param id defines the id to search for
  33012. * @return the mesh found or null if not found at all
  33013. */
  33014. getMeshByID(id: string): Nullable<AbstractMesh>;
  33015. /**
  33016. * Gets a list of meshes using their id
  33017. * @param id defines the id to search for
  33018. * @returns a list of meshes
  33019. */
  33020. getMeshesByID(id: string): Array<AbstractMesh>;
  33021. /**
  33022. * Gets the first added transform node found of a given ID
  33023. * @param id defines the id to search for
  33024. * @return the found transform node or null if not found at all.
  33025. */
  33026. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33027. /**
  33028. * Gets a list of transform nodes using their id
  33029. * @param id defines the id to search for
  33030. * @returns a list of transform nodes
  33031. */
  33032. getTransformNodesByID(id: string): Array<TransformNode>;
  33033. /**
  33034. * Gets a mesh with its auto-generated unique id
  33035. * @param uniqueId defines the unique id to search for
  33036. * @return the found mesh or null if not found at all.
  33037. */
  33038. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33039. /**
  33040. * Gets a the last added mesh using a given id
  33041. * @param id defines the id to search for
  33042. * @return the found mesh or null if not found at all.
  33043. */
  33044. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33045. /**
  33046. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33047. * @param id defines the id to search for
  33048. * @return the found node or null if not found at all
  33049. */
  33050. getLastEntryByID(id: string): Nullable<Node>;
  33051. /**
  33052. * Gets a node (Mesh, Camera, Light) using a given id
  33053. * @param id defines the id to search for
  33054. * @return the found node or null if not found at all
  33055. */
  33056. getNodeByID(id: string): Nullable<Node>;
  33057. /**
  33058. * Gets a node (Mesh, Camera, Light) using a given name
  33059. * @param name defines the name to search for
  33060. * @return the found node or null if not found at all.
  33061. */
  33062. getNodeByName(name: string): Nullable<Node>;
  33063. /**
  33064. * Gets a mesh using a given name
  33065. * @param name defines the name to search for
  33066. * @return the found mesh or null if not found at all.
  33067. */
  33068. getMeshByName(name: string): Nullable<AbstractMesh>;
  33069. /**
  33070. * Gets a transform node using a given name
  33071. * @param name defines the name to search for
  33072. * @return the found transform node or null if not found at all.
  33073. */
  33074. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33075. /**
  33076. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33077. * @param id defines the id to search for
  33078. * @return the found skeleton or null if not found at all.
  33079. */
  33080. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33081. /**
  33082. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33083. * @param id defines the id to search for
  33084. * @return the found skeleton or null if not found at all.
  33085. */
  33086. getSkeletonById(id: string): Nullable<Skeleton>;
  33087. /**
  33088. * Gets a skeleton using a given name
  33089. * @param name defines the name to search for
  33090. * @return the found skeleton or null if not found at all.
  33091. */
  33092. getSkeletonByName(name: string): Nullable<Skeleton>;
  33093. /**
  33094. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33095. * @param id defines the id to search for
  33096. * @return the found morph target manager or null if not found at all.
  33097. */
  33098. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33099. /**
  33100. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33101. * @param id defines the id to search for
  33102. * @return the found morph target or null if not found at all.
  33103. */
  33104. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33105. /**
  33106. * Gets a boolean indicating if the given mesh is active
  33107. * @param mesh defines the mesh to look for
  33108. * @returns true if the mesh is in the active list
  33109. */
  33110. isActiveMesh(mesh: AbstractMesh): boolean;
  33111. /**
  33112. * Return a unique id as a string which can serve as an identifier for the scene
  33113. */
  33114. readonly uid: string;
  33115. /**
  33116. * Add an externaly attached data from its key.
  33117. * This method call will fail and return false, if such key already exists.
  33118. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33119. * @param key the unique key that identifies the data
  33120. * @param data the data object to associate to the key for this Engine instance
  33121. * @return true if no such key were already present and the data was added successfully, false otherwise
  33122. */
  33123. addExternalData<T>(key: string, data: T): boolean;
  33124. /**
  33125. * Get an externaly attached data from its key
  33126. * @param key the unique key that identifies the data
  33127. * @return the associated data, if present (can be null), or undefined if not present
  33128. */
  33129. getExternalData<T>(key: string): Nullable<T>;
  33130. /**
  33131. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33132. * @param key the unique key that identifies the data
  33133. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33134. * @return the associated data, can be null if the factory returned null.
  33135. */
  33136. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33137. /**
  33138. * Remove an externaly attached data from the Engine instance
  33139. * @param key the unique key that identifies the data
  33140. * @return true if the data was successfully removed, false if it doesn't exist
  33141. */
  33142. removeExternalData(key: string): boolean;
  33143. private _evaluateSubMesh;
  33144. /**
  33145. * Clear the processed materials smart array preventing retention point in material dispose.
  33146. */
  33147. freeProcessedMaterials(): void;
  33148. private _preventFreeActiveMeshesAndRenderingGroups;
  33149. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33150. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33151. * when disposing several meshes in a row or a hierarchy of meshes.
  33152. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33153. */
  33154. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33155. /**
  33156. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33157. */
  33158. freeActiveMeshes(): void;
  33159. /**
  33160. * Clear the info related to rendering groups preventing retention points during dispose.
  33161. */
  33162. freeRenderingGroups(): void;
  33163. /** @hidden */
  33164. _isInIntermediateRendering(): boolean;
  33165. /**
  33166. * Lambda returning the list of potentially active meshes.
  33167. */
  33168. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33169. /**
  33170. * Lambda returning the list of potentially active sub meshes.
  33171. */
  33172. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33173. /**
  33174. * Lambda returning the list of potentially intersecting sub meshes.
  33175. */
  33176. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33177. /**
  33178. * Lambda returning the list of potentially colliding sub meshes.
  33179. */
  33180. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33181. private _activeMeshesFrozen;
  33182. /**
  33183. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33184. * @returns the current scene
  33185. */
  33186. freezeActiveMeshes(): Scene;
  33187. /**
  33188. * Use this function to restart evaluating active meshes on every frame
  33189. * @returns the current scene
  33190. */
  33191. unfreezeActiveMeshes(): Scene;
  33192. private _evaluateActiveMeshes;
  33193. private _activeMesh;
  33194. /**
  33195. * Update the transform matrix to update from the current active camera
  33196. * @param force defines a boolean used to force the update even if cache is up to date
  33197. */
  33198. updateTransformMatrix(force?: boolean): void;
  33199. /**
  33200. * 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)
  33201. * @param alternateCamera defines the camera to use
  33202. */
  33203. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33204. /** @hidden */
  33205. _allowPostProcessClearColor: boolean;
  33206. private _renderForCamera;
  33207. private _processSubCameras;
  33208. private _checkIntersections;
  33209. /** @hidden */
  33210. _advancePhysicsEngineStep(step: number): void;
  33211. /**
  33212. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33213. */
  33214. getDeterministicFrameTime: () => number;
  33215. /** @hidden */
  33216. _animate(): void;
  33217. /**
  33218. * Render the scene
  33219. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33220. */
  33221. render(updateCameras?: boolean): void;
  33222. /**
  33223. * Freeze all materials
  33224. * A frozen material will not be updatable but should be faster to render
  33225. */
  33226. freezeMaterials(): void;
  33227. /**
  33228. * Unfreeze all materials
  33229. * A frozen material will not be updatable but should be faster to render
  33230. */
  33231. unfreezeMaterials(): void;
  33232. /**
  33233. * Releases all held ressources
  33234. */
  33235. dispose(): void;
  33236. /**
  33237. * Gets if the scene is already disposed
  33238. */
  33239. readonly isDisposed: boolean;
  33240. /**
  33241. * Call this function to reduce memory footprint of the scene.
  33242. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33243. */
  33244. clearCachedVertexData(): void;
  33245. /**
  33246. * This function will remove the local cached buffer data from texture.
  33247. * It will save memory but will prevent the texture from being rebuilt
  33248. */
  33249. cleanCachedTextureBuffer(): void;
  33250. /**
  33251. * Get the world extend vectors with an optional filter
  33252. *
  33253. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33254. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33255. */
  33256. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33257. min: Vector3;
  33258. max: Vector3;
  33259. };
  33260. /**
  33261. * Creates a ray that can be used to pick in the scene
  33262. * @param x defines the x coordinate of the origin (on-screen)
  33263. * @param y defines the y coordinate of the origin (on-screen)
  33264. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33265. * @param camera defines the camera to use for the picking
  33266. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33267. * @returns a Ray
  33268. */
  33269. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33270. /**
  33271. * Creates a ray that can be used to pick in the scene
  33272. * @param x defines the x coordinate of the origin (on-screen)
  33273. * @param y defines the y coordinate of the origin (on-screen)
  33274. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33275. * @param result defines the ray where to store the picking ray
  33276. * @param camera defines the camera to use for the picking
  33277. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33278. * @returns the current scene
  33279. */
  33280. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33281. /**
  33282. * Creates a ray that can be used to pick in the scene
  33283. * @param x defines the x coordinate of the origin (on-screen)
  33284. * @param y defines the y coordinate of the origin (on-screen)
  33285. * @param camera defines the camera to use for the picking
  33286. * @returns a Ray
  33287. */
  33288. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33289. /**
  33290. * Creates a ray that can be used to pick in the scene
  33291. * @param x defines the x coordinate of the origin (on-screen)
  33292. * @param y defines the y coordinate of the origin (on-screen)
  33293. * @param result defines the ray where to store the picking ray
  33294. * @param camera defines the camera to use for the picking
  33295. * @returns the current scene
  33296. */
  33297. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33298. /** Launch a ray to try to pick a mesh in the scene
  33299. * @param x position on screen
  33300. * @param y position on screen
  33301. * @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
  33302. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33303. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33304. * @returns a PickingInfo
  33305. */
  33306. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33307. /** Use the given ray to pick a mesh in the scene
  33308. * @param ray The ray to use to pick meshes
  33309. * @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
  33310. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33311. * @returns a PickingInfo
  33312. */
  33313. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33314. /**
  33315. * Launch a ray to try to pick a mesh in the scene
  33316. * @param x X position on screen
  33317. * @param y Y position on screen
  33318. * @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
  33319. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33320. * @returns an array of PickingInfo
  33321. */
  33322. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33323. /**
  33324. * Launch a ray to try to pick a mesh in the scene
  33325. * @param ray Ray to use
  33326. * @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
  33327. * @returns an array of PickingInfo
  33328. */
  33329. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33330. /**
  33331. * Force the value of meshUnderPointer
  33332. * @param mesh defines the mesh to use
  33333. */
  33334. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33335. /**
  33336. * Gets the mesh under the pointer
  33337. * @returns a Mesh or null if no mesh is under the pointer
  33338. */
  33339. getPointerOverMesh(): Nullable<AbstractMesh>;
  33340. /** @hidden */
  33341. _rebuildGeometries(): void;
  33342. /** @hidden */
  33343. _rebuildTextures(): void;
  33344. private _getByTags;
  33345. /**
  33346. * Get a list of meshes by tags
  33347. * @param tagsQuery defines the tags query to use
  33348. * @param forEach defines a predicate used to filter results
  33349. * @returns an array of Mesh
  33350. */
  33351. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33352. /**
  33353. * Get a list of cameras by tags
  33354. * @param tagsQuery defines the tags query to use
  33355. * @param forEach defines a predicate used to filter results
  33356. * @returns an array of Camera
  33357. */
  33358. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33359. /**
  33360. * Get a list of lights by tags
  33361. * @param tagsQuery defines the tags query to use
  33362. * @param forEach defines a predicate used to filter results
  33363. * @returns an array of Light
  33364. */
  33365. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33366. /**
  33367. * Get a list of materials by tags
  33368. * @param tagsQuery defines the tags query to use
  33369. * @param forEach defines a predicate used to filter results
  33370. * @returns an array of Material
  33371. */
  33372. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33373. /**
  33374. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33375. * This allowed control for front to back rendering or reversly depending of the special needs.
  33376. *
  33377. * @param renderingGroupId The rendering group id corresponding to its index
  33378. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33379. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33380. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33381. */
  33382. 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;
  33383. /**
  33384. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33385. *
  33386. * @param renderingGroupId The rendering group id corresponding to its index
  33387. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33388. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33389. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33390. */
  33391. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33392. /**
  33393. * Gets the current auto clear configuration for one rendering group of the rendering
  33394. * manager.
  33395. * @param index the rendering group index to get the information for
  33396. * @returns The auto clear setup for the requested rendering group
  33397. */
  33398. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33399. private _blockMaterialDirtyMechanism;
  33400. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33401. blockMaterialDirtyMechanism: boolean;
  33402. /**
  33403. * Will flag all materials as dirty to trigger new shader compilation
  33404. * @param flag defines the flag used to specify which material part must be marked as dirty
  33405. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33406. */
  33407. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33408. /** @hidden */
  33409. _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;
  33410. /** @hidden */
  33411. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33412. }
  33413. }
  33414. declare module "babylonjs/assetContainer" {
  33415. import { AbstractScene } from "babylonjs/abstractScene";
  33416. import { Scene } from "babylonjs/scene";
  33417. import { Mesh } from "babylonjs/Meshes/mesh";
  33418. /**
  33419. * Set of assets to keep when moving a scene into an asset container.
  33420. */
  33421. export class KeepAssets extends AbstractScene {
  33422. }
  33423. /**
  33424. * Container with a set of assets that can be added or removed from a scene.
  33425. */
  33426. export class AssetContainer extends AbstractScene {
  33427. /**
  33428. * The scene the AssetContainer belongs to.
  33429. */
  33430. scene: Scene;
  33431. /**
  33432. * Instantiates an AssetContainer.
  33433. * @param scene The scene the AssetContainer belongs to.
  33434. */
  33435. constructor(scene: Scene);
  33436. /**
  33437. * Adds all the assets from the container to the scene.
  33438. */
  33439. addAllToScene(): void;
  33440. /**
  33441. * Removes all the assets in the container from the scene
  33442. */
  33443. removeAllFromScene(): void;
  33444. /**
  33445. * Disposes all the assets in the container
  33446. */
  33447. dispose(): void;
  33448. private _moveAssets;
  33449. /**
  33450. * Removes all the assets contained in the scene and adds them to the container.
  33451. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33452. */
  33453. moveAllFromScene(keepAssets?: KeepAssets): void;
  33454. /**
  33455. * 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.
  33456. * @returns the root mesh
  33457. */
  33458. createRootMesh(): Mesh;
  33459. }
  33460. }
  33461. declare module "babylonjs/abstractScene" {
  33462. import { Scene } from "babylonjs/scene";
  33463. import { Nullable } from "babylonjs/types";
  33464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33465. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33466. import { Geometry } from "babylonjs/Meshes/geometry";
  33467. import { Skeleton } from "babylonjs/Bones/skeleton";
  33468. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33469. import { AssetContainer } from "babylonjs/assetContainer";
  33470. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33471. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33473. import { Material } from "babylonjs/Materials/material";
  33474. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33475. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33476. import { Camera } from "babylonjs/Cameras/camera";
  33477. import { Light } from "babylonjs/Lights/light";
  33478. import { Node } from "babylonjs/node";
  33479. import { Animation } from "babylonjs/Animations/animation";
  33480. /**
  33481. * Defines how the parser contract is defined.
  33482. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33483. */
  33484. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33485. /**
  33486. * Defines how the individual parser contract is defined.
  33487. * These parser can parse an individual asset
  33488. */
  33489. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33490. /**
  33491. * Base class of the scene acting as a container for the different elements composing a scene.
  33492. * This class is dynamically extended by the different components of the scene increasing
  33493. * flexibility and reducing coupling
  33494. */
  33495. export abstract class AbstractScene {
  33496. /**
  33497. * Stores the list of available parsers in the application.
  33498. */
  33499. private static _BabylonFileParsers;
  33500. /**
  33501. * Stores the list of available individual parsers in the application.
  33502. */
  33503. private static _IndividualBabylonFileParsers;
  33504. /**
  33505. * Adds a parser in the list of available ones
  33506. * @param name Defines the name of the parser
  33507. * @param parser Defines the parser to add
  33508. */
  33509. static AddParser(name: string, parser: BabylonFileParser): void;
  33510. /**
  33511. * Gets a general parser from the list of avaialble ones
  33512. * @param name Defines the name of the parser
  33513. * @returns the requested parser or null
  33514. */
  33515. static GetParser(name: string): Nullable<BabylonFileParser>;
  33516. /**
  33517. * Adds n individual parser in the list of available ones
  33518. * @param name Defines the name of the parser
  33519. * @param parser Defines the parser to add
  33520. */
  33521. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33522. /**
  33523. * Gets an individual parser from the list of avaialble ones
  33524. * @param name Defines the name of the parser
  33525. * @returns the requested parser or null
  33526. */
  33527. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33528. /**
  33529. * Parser json data and populate both a scene and its associated container object
  33530. * @param jsonData Defines the data to parse
  33531. * @param scene Defines the scene to parse the data for
  33532. * @param container Defines the container attached to the parsing sequence
  33533. * @param rootUrl Defines the root url of the data
  33534. */
  33535. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33536. /**
  33537. * Gets the list of root nodes (ie. nodes with no parent)
  33538. */
  33539. rootNodes: Node[];
  33540. /** All of the cameras added to this scene
  33541. * @see http://doc.babylonjs.com/babylon101/cameras
  33542. */
  33543. cameras: Camera[];
  33544. /**
  33545. * All of the lights added to this scene
  33546. * @see http://doc.babylonjs.com/babylon101/lights
  33547. */
  33548. lights: Light[];
  33549. /**
  33550. * All of the (abstract) meshes added to this scene
  33551. */
  33552. meshes: AbstractMesh[];
  33553. /**
  33554. * The list of skeletons added to the scene
  33555. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33556. */
  33557. skeletons: Skeleton[];
  33558. /**
  33559. * All of the particle systems added to this scene
  33560. * @see http://doc.babylonjs.com/babylon101/particles
  33561. */
  33562. particleSystems: IParticleSystem[];
  33563. /**
  33564. * Gets a list of Animations associated with the scene
  33565. */
  33566. animations: Animation[];
  33567. /**
  33568. * All of the animation groups added to this scene
  33569. * @see http://doc.babylonjs.com/how_to/group
  33570. */
  33571. animationGroups: AnimationGroup[];
  33572. /**
  33573. * All of the multi-materials added to this scene
  33574. * @see http://doc.babylonjs.com/how_to/multi_materials
  33575. */
  33576. multiMaterials: MultiMaterial[];
  33577. /**
  33578. * All of the materials added to this scene
  33579. * In the context of a Scene, it is not supposed to be modified manually.
  33580. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33581. * Note also that the order of the Material wihin the array is not significant and might change.
  33582. * @see http://doc.babylonjs.com/babylon101/materials
  33583. */
  33584. materials: Material[];
  33585. /**
  33586. * The list of morph target managers added to the scene
  33587. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33588. */
  33589. morphTargetManagers: MorphTargetManager[];
  33590. /**
  33591. * The list of geometries used in the scene.
  33592. */
  33593. geometries: Geometry[];
  33594. /**
  33595. * All of the tranform nodes added to this scene
  33596. * In the context of a Scene, it is not supposed to be modified manually.
  33597. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33598. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33599. * @see http://doc.babylonjs.com/how_to/transformnode
  33600. */
  33601. transformNodes: TransformNode[];
  33602. /**
  33603. * ActionManagers available on the scene.
  33604. */
  33605. actionManagers: AbstractActionManager[];
  33606. /**
  33607. * Textures to keep.
  33608. */
  33609. textures: BaseTexture[];
  33610. }
  33611. }
  33612. declare module "babylonjs/Audio/sound" {
  33613. import { Observable } from "babylonjs/Misc/observable";
  33614. import { Vector3 } from "babylonjs/Maths/math";
  33615. import { Nullable } from "babylonjs/types";
  33616. import { Scene } from "babylonjs/scene";
  33617. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33618. /**
  33619. * Defines a sound that can be played in the application.
  33620. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33622. */
  33623. export class Sound {
  33624. /**
  33625. * The name of the sound in the scene.
  33626. */
  33627. name: string;
  33628. /**
  33629. * Does the sound autoplay once loaded.
  33630. */
  33631. autoplay: boolean;
  33632. /**
  33633. * Does the sound loop after it finishes playing once.
  33634. */
  33635. loop: boolean;
  33636. /**
  33637. * Does the sound use a custom attenuation curve to simulate the falloff
  33638. * happening when the source gets further away from the camera.
  33639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33640. */
  33641. useCustomAttenuation: boolean;
  33642. /**
  33643. * The sound track id this sound belongs to.
  33644. */
  33645. soundTrackId: number;
  33646. /**
  33647. * Is this sound currently played.
  33648. */
  33649. isPlaying: boolean;
  33650. /**
  33651. * Is this sound currently paused.
  33652. */
  33653. isPaused: boolean;
  33654. /**
  33655. * Does this sound enables spatial sound.
  33656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33657. */
  33658. spatialSound: boolean;
  33659. /**
  33660. * Define the reference distance the sound should be heard perfectly.
  33661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33662. */
  33663. refDistance: number;
  33664. /**
  33665. * Define the roll off factor of spatial sounds.
  33666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33667. */
  33668. rolloffFactor: number;
  33669. /**
  33670. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33672. */
  33673. maxDistance: number;
  33674. /**
  33675. * Define the distance attenuation model the sound will follow.
  33676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33677. */
  33678. distanceModel: string;
  33679. /**
  33680. * @hidden
  33681. * Back Compat
  33682. **/
  33683. onended: () => any;
  33684. /**
  33685. * Observable event when the current playing sound finishes.
  33686. */
  33687. onEndedObservable: Observable<Sound>;
  33688. private _panningModel;
  33689. private _playbackRate;
  33690. private _streaming;
  33691. private _startTime;
  33692. private _startOffset;
  33693. private _position;
  33694. /** @hidden */
  33695. _positionInEmitterSpace: boolean;
  33696. private _localDirection;
  33697. private _volume;
  33698. private _isReadyToPlay;
  33699. private _isDirectional;
  33700. private _readyToPlayCallback;
  33701. private _audioBuffer;
  33702. private _soundSource;
  33703. private _streamingSource;
  33704. private _soundPanner;
  33705. private _soundGain;
  33706. private _inputAudioNode;
  33707. private _outputAudioNode;
  33708. private _coneInnerAngle;
  33709. private _coneOuterAngle;
  33710. private _coneOuterGain;
  33711. private _scene;
  33712. private _connectedTransformNode;
  33713. private _customAttenuationFunction;
  33714. private _registerFunc;
  33715. private _isOutputConnected;
  33716. private _htmlAudioElement;
  33717. private _urlType;
  33718. /** @hidden */
  33719. static _SceneComponentInitialization: (scene: Scene) => void;
  33720. /**
  33721. * Create a sound and attach it to a scene
  33722. * @param name Name of your sound
  33723. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33724. * @param scene defines the scene the sound belongs to
  33725. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33726. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33727. */
  33728. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33729. /**
  33730. * Release the sound and its associated resources
  33731. */
  33732. dispose(): void;
  33733. /**
  33734. * Gets if the sounds is ready to be played or not.
  33735. * @returns true if ready, otherwise false
  33736. */
  33737. isReady(): boolean;
  33738. private _soundLoaded;
  33739. /**
  33740. * Sets the data of the sound from an audiobuffer
  33741. * @param audioBuffer The audioBuffer containing the data
  33742. */
  33743. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33744. /**
  33745. * Updates the current sounds options such as maxdistance, loop...
  33746. * @param options A JSON object containing values named as the object properties
  33747. */
  33748. updateOptions(options: any): void;
  33749. private _createSpatialParameters;
  33750. private _updateSpatialParameters;
  33751. /**
  33752. * Switch the panning model to HRTF:
  33753. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33755. */
  33756. switchPanningModelToHRTF(): void;
  33757. /**
  33758. * Switch the panning model to Equal Power:
  33759. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33761. */
  33762. switchPanningModelToEqualPower(): void;
  33763. private _switchPanningModel;
  33764. /**
  33765. * Connect this sound to a sound track audio node like gain...
  33766. * @param soundTrackAudioNode the sound track audio node to connect to
  33767. */
  33768. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33769. /**
  33770. * Transform this sound into a directional source
  33771. * @param coneInnerAngle Size of the inner cone in degree
  33772. * @param coneOuterAngle Size of the outer cone in degree
  33773. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33774. */
  33775. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33776. /**
  33777. * Gets or sets the inner angle for the directional cone.
  33778. */
  33779. /**
  33780. * Gets or sets the inner angle for the directional cone.
  33781. */
  33782. directionalConeInnerAngle: number;
  33783. /**
  33784. * Gets or sets the outer angle for the directional cone.
  33785. */
  33786. /**
  33787. * Gets or sets the outer angle for the directional cone.
  33788. */
  33789. directionalConeOuterAngle: number;
  33790. /**
  33791. * Sets the position of the emitter if spatial sound is enabled
  33792. * @param newPosition Defines the new posisiton
  33793. */
  33794. setPosition(newPosition: Vector3): void;
  33795. /**
  33796. * Sets the local direction of the emitter if spatial sound is enabled
  33797. * @param newLocalDirection Defines the new local direction
  33798. */
  33799. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33800. private _updateDirection;
  33801. /** @hidden */
  33802. updateDistanceFromListener(): void;
  33803. /**
  33804. * Sets a new custom attenuation function for the sound.
  33805. * @param callback Defines the function used for the attenuation
  33806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33807. */
  33808. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33809. /**
  33810. * Play the sound
  33811. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33812. * @param offset (optional) Start the sound setting it at a specific time
  33813. */
  33814. play(time?: number, offset?: number): void;
  33815. private _onended;
  33816. /**
  33817. * Stop the sound
  33818. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33819. */
  33820. stop(time?: number): void;
  33821. /**
  33822. * Put the sound in pause
  33823. */
  33824. pause(): void;
  33825. /**
  33826. * Sets a dedicated volume for this sounds
  33827. * @param newVolume Define the new volume of the sound
  33828. * @param time Define in how long the sound should be at this value
  33829. */
  33830. setVolume(newVolume: number, time?: number): void;
  33831. /**
  33832. * Set the sound play back rate
  33833. * @param newPlaybackRate Define the playback rate the sound should be played at
  33834. */
  33835. setPlaybackRate(newPlaybackRate: number): void;
  33836. /**
  33837. * Gets the volume of the sound.
  33838. * @returns the volume of the sound
  33839. */
  33840. getVolume(): number;
  33841. /**
  33842. * Attach the sound to a dedicated mesh
  33843. * @param transformNode The transform node to connect the sound with
  33844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33845. */
  33846. attachToMesh(transformNode: TransformNode): void;
  33847. /**
  33848. * Detach the sound from the previously attached mesh
  33849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33850. */
  33851. detachFromMesh(): void;
  33852. private _onRegisterAfterWorldMatrixUpdate;
  33853. /**
  33854. * Clone the current sound in the scene.
  33855. * @returns the new sound clone
  33856. */
  33857. clone(): Nullable<Sound>;
  33858. /**
  33859. * Gets the current underlying audio buffer containing the data
  33860. * @returns the audio buffer
  33861. */
  33862. getAudioBuffer(): Nullable<AudioBuffer>;
  33863. /**
  33864. * Serializes the Sound in a JSON representation
  33865. * @returns the JSON representation of the sound
  33866. */
  33867. serialize(): any;
  33868. /**
  33869. * Parse a JSON representation of a sound to innstantiate in a given scene
  33870. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33871. * @param scene Define the scene the new parsed sound should be created in
  33872. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33873. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33874. * @returns the newly parsed sound
  33875. */
  33876. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33877. }
  33878. }
  33879. declare module "babylonjs/Actions/directAudioActions" {
  33880. import { Action } from "babylonjs/Actions/action";
  33881. import { Condition } from "babylonjs/Actions/condition";
  33882. import { Sound } from "babylonjs/Audio/sound";
  33883. /**
  33884. * This defines an action helpful to play a defined sound on a triggered action.
  33885. */
  33886. export class PlaySoundAction extends Action {
  33887. private _sound;
  33888. /**
  33889. * Instantiate the action
  33890. * @param triggerOptions defines the trigger options
  33891. * @param sound defines the sound to play
  33892. * @param condition defines the trigger related conditions
  33893. */
  33894. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33895. /** @hidden */
  33896. _prepare(): void;
  33897. /**
  33898. * Execute the action and play the sound.
  33899. */
  33900. execute(): void;
  33901. /**
  33902. * Serializes the actions and its related information.
  33903. * @param parent defines the object to serialize in
  33904. * @returns the serialized object
  33905. */
  33906. serialize(parent: any): any;
  33907. }
  33908. /**
  33909. * This defines an action helpful to stop a defined sound on a triggered action.
  33910. */
  33911. export class StopSoundAction extends Action {
  33912. private _sound;
  33913. /**
  33914. * Instantiate the action
  33915. * @param triggerOptions defines the trigger options
  33916. * @param sound defines the sound to stop
  33917. * @param condition defines the trigger related conditions
  33918. */
  33919. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33920. /** @hidden */
  33921. _prepare(): void;
  33922. /**
  33923. * Execute the action and stop the sound.
  33924. */
  33925. execute(): void;
  33926. /**
  33927. * Serializes the actions and its related information.
  33928. * @param parent defines the object to serialize in
  33929. * @returns the serialized object
  33930. */
  33931. serialize(parent: any): any;
  33932. }
  33933. }
  33934. declare module "babylonjs/Actions/interpolateValueAction" {
  33935. import { Action } from "babylonjs/Actions/action";
  33936. import { Condition } from "babylonjs/Actions/condition";
  33937. import { Observable } from "babylonjs/Misc/observable";
  33938. /**
  33939. * This defines an action responsible to change the value of a property
  33940. * by interpolating between its current value and the newly set one once triggered.
  33941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33942. */
  33943. export class InterpolateValueAction extends Action {
  33944. /**
  33945. * Defines the path of the property where the value should be interpolated
  33946. */
  33947. propertyPath: string;
  33948. /**
  33949. * Defines the target value at the end of the interpolation.
  33950. */
  33951. value: any;
  33952. /**
  33953. * Defines the time it will take for the property to interpolate to the value.
  33954. */
  33955. duration: number;
  33956. /**
  33957. * Defines if the other scene animations should be stopped when the action has been triggered
  33958. */
  33959. stopOtherAnimations?: boolean;
  33960. /**
  33961. * Defines a callback raised once the interpolation animation has been done.
  33962. */
  33963. onInterpolationDone?: () => void;
  33964. /**
  33965. * Observable triggered once the interpolation animation has been done.
  33966. */
  33967. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33968. private _target;
  33969. private _effectiveTarget;
  33970. private _property;
  33971. /**
  33972. * Instantiate the action
  33973. * @param triggerOptions defines the trigger options
  33974. * @param target defines the object containing the value to interpolate
  33975. * @param propertyPath defines the path to the property in the target object
  33976. * @param value defines the target value at the end of the interpolation
  33977. * @param duration deines the time it will take for the property to interpolate to the value.
  33978. * @param condition defines the trigger related conditions
  33979. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33980. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33981. */
  33982. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33983. /** @hidden */
  33984. _prepare(): void;
  33985. /**
  33986. * Execute the action starts the value interpolation.
  33987. */
  33988. execute(): void;
  33989. /**
  33990. * Serializes the actions and its related information.
  33991. * @param parent defines the object to serialize in
  33992. * @returns the serialized object
  33993. */
  33994. serialize(parent: any): any;
  33995. }
  33996. }
  33997. declare module "babylonjs/Actions/index" {
  33998. export * from "babylonjs/Actions/action";
  33999. export * from "babylonjs/Actions/actionEvent";
  34000. export * from "babylonjs/Actions/actionManager";
  34001. export * from "babylonjs/Actions/condition";
  34002. export * from "babylonjs/Actions/directActions";
  34003. export * from "babylonjs/Actions/directAudioActions";
  34004. export * from "babylonjs/Actions/interpolateValueAction";
  34005. }
  34006. declare module "babylonjs/Animations/index" {
  34007. export * from "babylonjs/Animations/animatable";
  34008. export * from "babylonjs/Animations/animation";
  34009. export * from "babylonjs/Animations/animationGroup";
  34010. export * from "babylonjs/Animations/animationPropertiesOverride";
  34011. export * from "babylonjs/Animations/easing";
  34012. export * from "babylonjs/Animations/runtimeAnimation";
  34013. export * from "babylonjs/Animations/animationEvent";
  34014. export * from "babylonjs/Animations/animationGroup";
  34015. export * from "babylonjs/Animations/animationKey";
  34016. export * from "babylonjs/Animations/animationRange";
  34017. }
  34018. declare module "babylonjs/Audio/soundTrack" {
  34019. import { Sound } from "babylonjs/Audio/sound";
  34020. import { Analyser } from "babylonjs/Audio/analyser";
  34021. import { Scene } from "babylonjs/scene";
  34022. /**
  34023. * Options allowed during the creation of a sound track.
  34024. */
  34025. export interface ISoundTrackOptions {
  34026. /**
  34027. * The volume the sound track should take during creation
  34028. */
  34029. volume?: number;
  34030. /**
  34031. * Define if the sound track is the main sound track of the scene
  34032. */
  34033. mainTrack?: boolean;
  34034. }
  34035. /**
  34036. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34037. * It will be also used in a future release to apply effects on a specific track.
  34038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34039. */
  34040. export class SoundTrack {
  34041. /**
  34042. * The unique identifier of the sound track in the scene.
  34043. */
  34044. id: number;
  34045. /**
  34046. * The list of sounds included in the sound track.
  34047. */
  34048. soundCollection: Array<Sound>;
  34049. private _outputAudioNode;
  34050. private _scene;
  34051. private _isMainTrack;
  34052. private _connectedAnalyser;
  34053. private _options;
  34054. private _isInitialized;
  34055. /**
  34056. * Creates a new sound track.
  34057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34058. * @param scene Define the scene the sound track belongs to
  34059. * @param options
  34060. */
  34061. constructor(scene: Scene, options?: ISoundTrackOptions);
  34062. private _initializeSoundTrackAudioGraph;
  34063. /**
  34064. * Release the sound track and its associated resources
  34065. */
  34066. dispose(): void;
  34067. /**
  34068. * Adds a sound to this sound track
  34069. * @param sound define the cound to add
  34070. * @ignoreNaming
  34071. */
  34072. AddSound(sound: Sound): void;
  34073. /**
  34074. * Removes a sound to this sound track
  34075. * @param sound define the cound to remove
  34076. * @ignoreNaming
  34077. */
  34078. RemoveSound(sound: Sound): void;
  34079. /**
  34080. * Set a global volume for the full sound track.
  34081. * @param newVolume Define the new volume of the sound track
  34082. */
  34083. setVolume(newVolume: number): void;
  34084. /**
  34085. * Switch the panning model to HRTF:
  34086. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34088. */
  34089. switchPanningModelToHRTF(): void;
  34090. /**
  34091. * Switch the panning model to Equal Power:
  34092. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34094. */
  34095. switchPanningModelToEqualPower(): void;
  34096. /**
  34097. * Connect the sound track to an audio analyser allowing some amazing
  34098. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34100. * @param analyser The analyser to connect to the engine
  34101. */
  34102. connectToAnalyser(analyser: Analyser): void;
  34103. }
  34104. }
  34105. declare module "babylonjs/Audio/audioSceneComponent" {
  34106. import { Sound } from "babylonjs/Audio/sound";
  34107. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34108. import { Nullable } from "babylonjs/types";
  34109. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34110. import { Scene } from "babylonjs/scene";
  34111. import { AbstractScene } from "babylonjs/abstractScene";
  34112. module "babylonjs/abstractScene" {
  34113. interface AbstractScene {
  34114. /**
  34115. * The list of sounds used in the scene.
  34116. */
  34117. sounds: Nullable<Array<Sound>>;
  34118. }
  34119. }
  34120. module "babylonjs/scene" {
  34121. interface Scene {
  34122. /**
  34123. * @hidden
  34124. * Backing field
  34125. */
  34126. _mainSoundTrack: SoundTrack;
  34127. /**
  34128. * The main sound track played by the scene.
  34129. * It cotains your primary collection of sounds.
  34130. */
  34131. mainSoundTrack: SoundTrack;
  34132. /**
  34133. * The list of sound tracks added to the scene
  34134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34135. */
  34136. soundTracks: Nullable<Array<SoundTrack>>;
  34137. /**
  34138. * Gets a sound using a given name
  34139. * @param name defines the name to search for
  34140. * @return the found sound or null if not found at all.
  34141. */
  34142. getSoundByName(name: string): Nullable<Sound>;
  34143. /**
  34144. * Gets or sets if audio support is enabled
  34145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34146. */
  34147. audioEnabled: boolean;
  34148. /**
  34149. * Gets or sets if audio will be output to headphones
  34150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34151. */
  34152. headphone: boolean;
  34153. }
  34154. }
  34155. /**
  34156. * Defines the sound scene component responsible to manage any sounds
  34157. * in a given scene.
  34158. */
  34159. export class AudioSceneComponent implements ISceneSerializableComponent {
  34160. /**
  34161. * The component name helpfull to identify the component in the list of scene components.
  34162. */
  34163. readonly name: string;
  34164. /**
  34165. * The scene the component belongs to.
  34166. */
  34167. scene: Scene;
  34168. private _audioEnabled;
  34169. /**
  34170. * Gets whether audio is enabled or not.
  34171. * Please use related enable/disable method to switch state.
  34172. */
  34173. readonly audioEnabled: boolean;
  34174. private _headphone;
  34175. /**
  34176. * Gets whether audio is outputing to headphone or not.
  34177. * Please use the according Switch methods to change output.
  34178. */
  34179. readonly headphone: boolean;
  34180. /**
  34181. * Creates a new instance of the component for the given scene
  34182. * @param scene Defines the scene to register the component in
  34183. */
  34184. constructor(scene: Scene);
  34185. /**
  34186. * Registers the component in a given scene
  34187. */
  34188. register(): void;
  34189. /**
  34190. * Rebuilds the elements related to this component in case of
  34191. * context lost for instance.
  34192. */
  34193. rebuild(): void;
  34194. /**
  34195. * Serializes the component data to the specified json object
  34196. * @param serializationObject The object to serialize to
  34197. */
  34198. serialize(serializationObject: any): void;
  34199. /**
  34200. * Adds all the element from the container to the scene
  34201. * @param container the container holding the elements
  34202. */
  34203. addFromContainer(container: AbstractScene): void;
  34204. /**
  34205. * Removes all the elements in the container from the scene
  34206. * @param container contains the elements to remove
  34207. */
  34208. removeFromContainer(container: AbstractScene): void;
  34209. /**
  34210. * Disposes the component and the associated ressources.
  34211. */
  34212. dispose(): void;
  34213. /**
  34214. * Disables audio in the associated scene.
  34215. */
  34216. disableAudio(): void;
  34217. /**
  34218. * Enables audio in the associated scene.
  34219. */
  34220. enableAudio(): void;
  34221. /**
  34222. * Switch audio to headphone output.
  34223. */
  34224. switchAudioModeForHeadphones(): void;
  34225. /**
  34226. * Switch audio to normal speakers.
  34227. */
  34228. switchAudioModeForNormalSpeakers(): void;
  34229. private _afterRender;
  34230. }
  34231. }
  34232. declare module "babylonjs/Audio/weightedsound" {
  34233. import { Sound } from "babylonjs/Audio/sound";
  34234. /**
  34235. * Wraps one or more Sound objects and selects one with random weight for playback.
  34236. */
  34237. export class WeightedSound {
  34238. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34239. loop: boolean;
  34240. private _coneInnerAngle;
  34241. private _coneOuterAngle;
  34242. private _volume;
  34243. /** A Sound is currently playing. */
  34244. isPlaying: boolean;
  34245. /** A Sound is currently paused. */
  34246. isPaused: boolean;
  34247. private _sounds;
  34248. private _weights;
  34249. private _currentIndex?;
  34250. /**
  34251. * Creates a new WeightedSound from the list of sounds given.
  34252. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34253. * @param sounds Array of Sounds that will be selected from.
  34254. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34255. */
  34256. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34257. /**
  34258. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34259. */
  34260. /**
  34261. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34262. */
  34263. directionalConeInnerAngle: number;
  34264. /**
  34265. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34266. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34267. */
  34268. /**
  34269. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34270. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34271. */
  34272. directionalConeOuterAngle: number;
  34273. /**
  34274. * Playback volume.
  34275. */
  34276. /**
  34277. * Playback volume.
  34278. */
  34279. volume: number;
  34280. private _onended;
  34281. /**
  34282. * Suspend playback
  34283. */
  34284. pause(): void;
  34285. /**
  34286. * Stop playback
  34287. */
  34288. stop(): void;
  34289. /**
  34290. * Start playback.
  34291. * @param startOffset Position the clip head at a specific time in seconds.
  34292. */
  34293. play(startOffset?: number): void;
  34294. }
  34295. }
  34296. declare module "babylonjs/Audio/index" {
  34297. export * from "babylonjs/Audio/analyser";
  34298. export * from "babylonjs/Audio/audioEngine";
  34299. export * from "babylonjs/Audio/audioSceneComponent";
  34300. export * from "babylonjs/Audio/sound";
  34301. export * from "babylonjs/Audio/soundTrack";
  34302. export * from "babylonjs/Audio/weightedsound";
  34303. }
  34304. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34305. import { Behavior } from "babylonjs/Behaviors/behavior";
  34306. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34307. import { BackEase } from "babylonjs/Animations/easing";
  34308. /**
  34309. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34311. */
  34312. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34313. /**
  34314. * Gets the name of the behavior.
  34315. */
  34316. readonly name: string;
  34317. /**
  34318. * The easing function used by animations
  34319. */
  34320. static EasingFunction: BackEase;
  34321. /**
  34322. * The easing mode used by animations
  34323. */
  34324. static EasingMode: number;
  34325. /**
  34326. * The duration of the animation, in milliseconds
  34327. */
  34328. transitionDuration: number;
  34329. /**
  34330. * Length of the distance animated by the transition when lower radius is reached
  34331. */
  34332. lowerRadiusTransitionRange: number;
  34333. /**
  34334. * Length of the distance animated by the transition when upper radius is reached
  34335. */
  34336. upperRadiusTransitionRange: number;
  34337. private _autoTransitionRange;
  34338. /**
  34339. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34340. */
  34341. /**
  34342. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34343. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34344. */
  34345. autoTransitionRange: boolean;
  34346. private _attachedCamera;
  34347. private _onAfterCheckInputsObserver;
  34348. private _onMeshTargetChangedObserver;
  34349. /**
  34350. * Initializes the behavior.
  34351. */
  34352. init(): void;
  34353. /**
  34354. * Attaches the behavior to its arc rotate camera.
  34355. * @param camera Defines the camera to attach the behavior to
  34356. */
  34357. attach(camera: ArcRotateCamera): void;
  34358. /**
  34359. * Detaches the behavior from its current arc rotate camera.
  34360. */
  34361. detach(): void;
  34362. private _radiusIsAnimating;
  34363. private _radiusBounceTransition;
  34364. private _animatables;
  34365. private _cachedWheelPrecision;
  34366. /**
  34367. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34368. * @param radiusLimit The limit to check against.
  34369. * @return Bool to indicate if at limit.
  34370. */
  34371. private _isRadiusAtLimit;
  34372. /**
  34373. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34374. * @param radiusDelta The delta by which to animate to. Can be negative.
  34375. */
  34376. private _applyBoundRadiusAnimation;
  34377. /**
  34378. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34379. */
  34380. protected _clearAnimationLocks(): void;
  34381. /**
  34382. * Stops and removes all animations that have been applied to the camera
  34383. */
  34384. stopAllAnimations(): void;
  34385. }
  34386. }
  34387. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34388. import { Behavior } from "babylonjs/Behaviors/behavior";
  34389. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34390. import { ExponentialEase } from "babylonjs/Animations/easing";
  34391. import { Nullable } from "babylonjs/types";
  34392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34393. import { Vector3 } from "babylonjs/Maths/math";
  34394. /**
  34395. * 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.
  34396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34397. */
  34398. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34399. /**
  34400. * Gets the name of the behavior.
  34401. */
  34402. readonly name: string;
  34403. private _mode;
  34404. private _radiusScale;
  34405. private _positionScale;
  34406. private _defaultElevation;
  34407. private _elevationReturnTime;
  34408. private _elevationReturnWaitTime;
  34409. private _zoomStopsAnimation;
  34410. private _framingTime;
  34411. /**
  34412. * The easing function used by animations
  34413. */
  34414. static EasingFunction: ExponentialEase;
  34415. /**
  34416. * The easing mode used by animations
  34417. */
  34418. static EasingMode: number;
  34419. /**
  34420. * Sets the current mode used by the behavior
  34421. */
  34422. /**
  34423. * Gets current mode used by the behavior.
  34424. */
  34425. mode: number;
  34426. /**
  34427. * Sets the scale applied to the radius (1 by default)
  34428. */
  34429. /**
  34430. * Gets the scale applied to the radius
  34431. */
  34432. radiusScale: number;
  34433. /**
  34434. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34435. */
  34436. /**
  34437. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34438. */
  34439. positionScale: number;
  34440. /**
  34441. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34442. * behaviour is triggered, in radians.
  34443. */
  34444. /**
  34445. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34446. * behaviour is triggered, in radians.
  34447. */
  34448. defaultElevation: number;
  34449. /**
  34450. * Sets the time (in milliseconds) taken to return to the default beta position.
  34451. * Negative value indicates camera should not return to default.
  34452. */
  34453. /**
  34454. * Gets the time (in milliseconds) taken to return to the default beta position.
  34455. * Negative value indicates camera should not return to default.
  34456. */
  34457. elevationReturnTime: number;
  34458. /**
  34459. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34460. */
  34461. /**
  34462. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34463. */
  34464. elevationReturnWaitTime: number;
  34465. /**
  34466. * Sets the flag that indicates if user zooming should stop animation.
  34467. */
  34468. /**
  34469. * Gets the flag that indicates if user zooming should stop animation.
  34470. */
  34471. zoomStopsAnimation: boolean;
  34472. /**
  34473. * Sets the transition time when framing the mesh, in milliseconds
  34474. */
  34475. /**
  34476. * Gets the transition time when framing the mesh, in milliseconds
  34477. */
  34478. framingTime: number;
  34479. /**
  34480. * Define if the behavior should automatically change the configured
  34481. * camera limits and sensibilities.
  34482. */
  34483. autoCorrectCameraLimitsAndSensibility: boolean;
  34484. private _onPrePointerObservableObserver;
  34485. private _onAfterCheckInputsObserver;
  34486. private _onMeshTargetChangedObserver;
  34487. private _attachedCamera;
  34488. private _isPointerDown;
  34489. private _lastInteractionTime;
  34490. /**
  34491. * Initializes the behavior.
  34492. */
  34493. init(): void;
  34494. /**
  34495. * Attaches the behavior to its arc rotate camera.
  34496. * @param camera Defines the camera to attach the behavior to
  34497. */
  34498. attach(camera: ArcRotateCamera): void;
  34499. /**
  34500. * Detaches the behavior from its current arc rotate camera.
  34501. */
  34502. detach(): void;
  34503. private _animatables;
  34504. private _betaIsAnimating;
  34505. private _betaTransition;
  34506. private _radiusTransition;
  34507. private _vectorTransition;
  34508. /**
  34509. * Targets the given mesh and updates zoom level accordingly.
  34510. * @param mesh The mesh to target.
  34511. * @param radius Optional. If a cached radius position already exists, overrides default.
  34512. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34513. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34514. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34515. */
  34516. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34517. /**
  34518. * Targets the given mesh with its children 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34526. /**
  34527. * Targets the given meshes with their children and updates zoom level accordingly.
  34528. * @param meshes 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. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34535. /**
  34536. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34537. * @param minimumWorld Determines the smaller position of the bounding box extend
  34538. * @param maximumWorld Determines the bigger position of the bounding box extend
  34539. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34540. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34541. */
  34542. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34543. /**
  34544. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34545. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34546. * frustum width.
  34547. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34548. * to fully enclose the mesh in the viewing frustum.
  34549. */
  34550. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34551. /**
  34552. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34553. * is automatically returned to its default position (expected to be above ground plane).
  34554. */
  34555. private _maintainCameraAboveGround;
  34556. /**
  34557. * Returns the frustum slope based on the canvas ratio and camera FOV
  34558. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34559. */
  34560. private _getFrustumSlope;
  34561. /**
  34562. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34563. */
  34564. private _clearAnimationLocks;
  34565. /**
  34566. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34567. */
  34568. private _applyUserInteraction;
  34569. /**
  34570. * Stops and removes all animations that have been applied to the camera
  34571. */
  34572. stopAllAnimations(): void;
  34573. /**
  34574. * Gets a value indicating if the user is moving the camera
  34575. */
  34576. readonly isUserIsMoving: boolean;
  34577. /**
  34578. * The camera can move all the way towards the mesh.
  34579. */
  34580. static IgnoreBoundsSizeMode: number;
  34581. /**
  34582. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34583. */
  34584. static FitFrustumSidesMode: number;
  34585. }
  34586. }
  34587. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34588. import { Nullable } from "babylonjs/types";
  34589. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34591. /**
  34592. * Manage the pointers inputs to control an arc rotate camera.
  34593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34594. */
  34595. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34596. /**
  34597. * Defines the camera the input is attached to.
  34598. */
  34599. camera: ArcRotateCamera;
  34600. /**
  34601. * Defines the buttons associated with the input to handle camera move.
  34602. */
  34603. buttons: number[];
  34604. /**
  34605. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34606. */
  34607. angularSensibilityX: number;
  34608. /**
  34609. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34610. */
  34611. angularSensibilityY: number;
  34612. /**
  34613. * Defines the pointer pinch precision or how fast is the camera zooming.
  34614. */
  34615. pinchPrecision: number;
  34616. /**
  34617. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34618. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34619. */
  34620. pinchDeltaPercentage: number;
  34621. /**
  34622. * Defines the pointer panning sensibility or how fast is the camera moving.
  34623. */
  34624. panningSensibility: number;
  34625. /**
  34626. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34627. */
  34628. multiTouchPanning: boolean;
  34629. /**
  34630. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34631. */
  34632. multiTouchPanAndZoom: boolean;
  34633. /**
  34634. * Revers pinch action direction.
  34635. */
  34636. pinchInwards: boolean;
  34637. private _isPanClick;
  34638. private _pointerInput;
  34639. private _observer;
  34640. private _onMouseMove;
  34641. private _onGestureStart;
  34642. private _onGesture;
  34643. private _MSGestureHandler;
  34644. private _onLostFocus;
  34645. private _onContextMenu;
  34646. /**
  34647. * Attach the input controls to a specific dom element to get the input from.
  34648. * @param element Defines the element the controls should be listened from
  34649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34650. */
  34651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34652. /**
  34653. * Detach the current controls from the specified dom element.
  34654. * @param element Defines the element to stop listening the inputs from
  34655. */
  34656. detachControl(element: Nullable<HTMLElement>): void;
  34657. /**
  34658. * Gets the class name of the current intput.
  34659. * @returns the class name
  34660. */
  34661. getClassName(): string;
  34662. /**
  34663. * Get the friendly name associated with the input class.
  34664. * @returns the input friendly name
  34665. */
  34666. getSimpleName(): string;
  34667. }
  34668. }
  34669. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34670. import { Nullable } from "babylonjs/types";
  34671. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34672. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34673. /**
  34674. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34676. */
  34677. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34678. /**
  34679. * Defines the camera the input is attached to.
  34680. */
  34681. camera: ArcRotateCamera;
  34682. /**
  34683. * Defines the list of key codes associated with the up action (increase alpha)
  34684. */
  34685. keysUp: number[];
  34686. /**
  34687. * Defines the list of key codes associated with the down action (decrease alpha)
  34688. */
  34689. keysDown: number[];
  34690. /**
  34691. * Defines the list of key codes associated with the left action (increase beta)
  34692. */
  34693. keysLeft: number[];
  34694. /**
  34695. * Defines the list of key codes associated with the right action (decrease beta)
  34696. */
  34697. keysRight: number[];
  34698. /**
  34699. * Defines the list of key codes associated with the reset action.
  34700. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34701. */
  34702. keysReset: number[];
  34703. /**
  34704. * Defines the panning sensibility of the inputs.
  34705. * (How fast is the camera paning)
  34706. */
  34707. panningSensibility: number;
  34708. /**
  34709. * Defines the zooming sensibility of the inputs.
  34710. * (How fast is the camera zooming)
  34711. */
  34712. zoomingSensibility: number;
  34713. /**
  34714. * Defines wether maintaining the alt key down switch the movement mode from
  34715. * orientation to zoom.
  34716. */
  34717. useAltToZoom: boolean;
  34718. /**
  34719. * Rotation speed of the camera
  34720. */
  34721. angularSpeed: number;
  34722. private _keys;
  34723. private _ctrlPressed;
  34724. private _altPressed;
  34725. private _onCanvasBlurObserver;
  34726. private _onKeyboardObserver;
  34727. private _engine;
  34728. private _scene;
  34729. /**
  34730. * Attach the input controls to a specific dom element to get the input from.
  34731. * @param element Defines the element the controls should be listened from
  34732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34733. */
  34734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34735. /**
  34736. * Detach the current controls from the specified dom element.
  34737. * @param element Defines the element to stop listening the inputs from
  34738. */
  34739. detachControl(element: Nullable<HTMLElement>): void;
  34740. /**
  34741. * Update the current camera state depending on the inputs that have been used this frame.
  34742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34743. */
  34744. checkInputs(): void;
  34745. /**
  34746. * Gets the class name of the current intput.
  34747. * @returns the class name
  34748. */
  34749. getClassName(): string;
  34750. /**
  34751. * Get the friendly name associated with the input class.
  34752. * @returns the input friendly name
  34753. */
  34754. getSimpleName(): string;
  34755. }
  34756. }
  34757. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34758. import { Nullable } from "babylonjs/types";
  34759. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34760. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34761. /**
  34762. * Manage the mouse wheel inputs to control an arc rotate camera.
  34763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34764. */
  34765. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34766. /**
  34767. * Defines the camera the input is attached to.
  34768. */
  34769. camera: ArcRotateCamera;
  34770. /**
  34771. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34772. */
  34773. wheelPrecision: number;
  34774. /**
  34775. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34776. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34777. */
  34778. wheelDeltaPercentage: number;
  34779. private _wheel;
  34780. private _observer;
  34781. /**
  34782. * Attach the input controls to a specific dom element to get the input from.
  34783. * @param element Defines the element the controls should be listened from
  34784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34785. */
  34786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34787. /**
  34788. * Detach the current controls from the specified dom element.
  34789. * @param element Defines the element to stop listening the inputs from
  34790. */
  34791. detachControl(element: Nullable<HTMLElement>): void;
  34792. /**
  34793. * Gets the class name of the current intput.
  34794. * @returns the class name
  34795. */
  34796. getClassName(): string;
  34797. /**
  34798. * Get the friendly name associated with the input class.
  34799. * @returns the input friendly name
  34800. */
  34801. getSimpleName(): string;
  34802. }
  34803. }
  34804. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34805. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34806. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34807. /**
  34808. * Default Inputs manager for the ArcRotateCamera.
  34809. * It groups all the default supported inputs for ease of use.
  34810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34811. */
  34812. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34813. /**
  34814. * Instantiates a new ArcRotateCameraInputsManager.
  34815. * @param camera Defines the camera the inputs belong to
  34816. */
  34817. constructor(camera: ArcRotateCamera);
  34818. /**
  34819. * Add mouse wheel input support to the input manager.
  34820. * @returns the current input manager
  34821. */
  34822. addMouseWheel(): ArcRotateCameraInputsManager;
  34823. /**
  34824. * Add pointers input support to the input manager.
  34825. * @returns the current input manager
  34826. */
  34827. addPointers(): ArcRotateCameraInputsManager;
  34828. /**
  34829. * Add keyboard input support to the input manager.
  34830. * @returns the current input manager
  34831. */
  34832. addKeyboard(): ArcRotateCameraInputsManager;
  34833. }
  34834. }
  34835. declare module "babylonjs/Cameras/arcRotateCamera" {
  34836. import { Observable } from "babylonjs/Misc/observable";
  34837. import { Nullable } from "babylonjs/types";
  34838. import { Scene } from "babylonjs/scene";
  34839. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34841. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34842. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34843. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34844. import { Camera } from "babylonjs/Cameras/camera";
  34845. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34846. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34847. import { Collider } from "babylonjs/Collisions/collider";
  34848. /**
  34849. * This represents an orbital type of camera.
  34850. *
  34851. * 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.
  34852. * 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.
  34853. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34854. */
  34855. export class ArcRotateCamera extends TargetCamera {
  34856. /**
  34857. * Defines the rotation angle of the camera along the longitudinal axis.
  34858. */
  34859. alpha: number;
  34860. /**
  34861. * Defines the rotation angle of the camera along the latitudinal axis.
  34862. */
  34863. beta: number;
  34864. /**
  34865. * Defines the radius of the camera from it s target point.
  34866. */
  34867. radius: number;
  34868. protected _target: Vector3;
  34869. protected _targetHost: Nullable<AbstractMesh>;
  34870. /**
  34871. * Defines the target point of the camera.
  34872. * The camera looks towards it form the radius distance.
  34873. */
  34874. target: Vector3;
  34875. /**
  34876. * Current inertia value on the longitudinal axis.
  34877. * The bigger this number the longer it will take for the camera to stop.
  34878. */
  34879. inertialAlphaOffset: number;
  34880. /**
  34881. * Current inertia value on the latitudinal axis.
  34882. * The bigger this number the longer it will take for the camera to stop.
  34883. */
  34884. inertialBetaOffset: number;
  34885. /**
  34886. * Current inertia value on the radius axis.
  34887. * The bigger this number the longer it will take for the camera to stop.
  34888. */
  34889. inertialRadiusOffset: number;
  34890. /**
  34891. * Minimum allowed angle on the longitudinal axis.
  34892. * This can help limiting how the Camera is able to move in the scene.
  34893. */
  34894. lowerAlphaLimit: Nullable<number>;
  34895. /**
  34896. * Maximum allowed angle on the longitudinal axis.
  34897. * This can help limiting how the Camera is able to move in the scene.
  34898. */
  34899. upperAlphaLimit: Nullable<number>;
  34900. /**
  34901. * Minimum allowed angle on the latitudinal axis.
  34902. * This can help limiting how the Camera is able to move in the scene.
  34903. */
  34904. lowerBetaLimit: number;
  34905. /**
  34906. * Maximum allowed angle on the latitudinal axis.
  34907. * This can help limiting how the Camera is able to move in the scene.
  34908. */
  34909. upperBetaLimit: number;
  34910. /**
  34911. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34912. * This can help limiting how the Camera is able to move in the scene.
  34913. */
  34914. lowerRadiusLimit: Nullable<number>;
  34915. /**
  34916. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34917. * This can help limiting how the Camera is able to move in the scene.
  34918. */
  34919. upperRadiusLimit: Nullable<number>;
  34920. /**
  34921. * Defines the current inertia value used during panning of the camera along the X axis.
  34922. */
  34923. inertialPanningX: number;
  34924. /**
  34925. * Defines the current inertia value used during panning of the camera along the Y axis.
  34926. */
  34927. inertialPanningY: number;
  34928. /**
  34929. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34930. * Basically if your fingers moves away from more than this distance you will be considered
  34931. * in pinch mode.
  34932. */
  34933. pinchToPanMaxDistance: number;
  34934. /**
  34935. * Defines the maximum distance the camera can pan.
  34936. * This could help keeping the cammera always in your scene.
  34937. */
  34938. panningDistanceLimit: Nullable<number>;
  34939. /**
  34940. * Defines the target of the camera before paning.
  34941. */
  34942. panningOriginTarget: Vector3;
  34943. /**
  34944. * Defines the value of the inertia used during panning.
  34945. * 0 would mean stop inertia and one would mean no decelleration at all.
  34946. */
  34947. panningInertia: number;
  34948. /**
  34949. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34950. */
  34951. angularSensibilityX: number;
  34952. /**
  34953. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34954. */
  34955. angularSensibilityY: number;
  34956. /**
  34957. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34958. */
  34959. pinchPrecision: number;
  34960. /**
  34961. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34962. * It will be used instead of pinchDeltaPrecision if different from 0.
  34963. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34964. */
  34965. pinchDeltaPercentage: number;
  34966. /**
  34967. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34968. */
  34969. panningSensibility: number;
  34970. /**
  34971. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34972. */
  34973. keysUp: number[];
  34974. /**
  34975. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34976. */
  34977. keysDown: number[];
  34978. /**
  34979. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34980. */
  34981. keysLeft: number[];
  34982. /**
  34983. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34984. */
  34985. keysRight: number[];
  34986. /**
  34987. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34988. */
  34989. wheelPrecision: number;
  34990. /**
  34991. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34992. * It will be used instead of pinchDeltaPrecision if different from 0.
  34993. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34994. */
  34995. wheelDeltaPercentage: number;
  34996. /**
  34997. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34998. */
  34999. zoomOnFactor: number;
  35000. /**
  35001. * Defines a screen offset for the camera position.
  35002. */
  35003. targetScreenOffset: Vector2;
  35004. /**
  35005. * Allows the camera to be completely reversed.
  35006. * If false the camera can not arrive upside down.
  35007. */
  35008. allowUpsideDown: boolean;
  35009. /**
  35010. * Define if double tap/click is used to restore the previously saved state of the camera.
  35011. */
  35012. useInputToRestoreState: boolean;
  35013. /** @hidden */
  35014. _viewMatrix: Matrix;
  35015. /** @hidden */
  35016. _useCtrlForPanning: boolean;
  35017. /** @hidden */
  35018. _panningMouseButton: number;
  35019. /**
  35020. * Defines the input associated to the camera.
  35021. */
  35022. inputs: ArcRotateCameraInputsManager;
  35023. /** @hidden */
  35024. _reset: () => void;
  35025. /**
  35026. * Defines the allowed panning axis.
  35027. */
  35028. panningAxis: Vector3;
  35029. protected _localDirection: Vector3;
  35030. protected _transformedDirection: Vector3;
  35031. private _bouncingBehavior;
  35032. /**
  35033. * Gets the bouncing behavior of the camera if it has been enabled.
  35034. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35035. */
  35036. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35037. /**
  35038. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35039. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35040. */
  35041. useBouncingBehavior: boolean;
  35042. private _framingBehavior;
  35043. /**
  35044. * Gets the framing behavior of the camera if it has been enabled.
  35045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35046. */
  35047. readonly framingBehavior: Nullable<FramingBehavior>;
  35048. /**
  35049. * Defines if the framing behavior of the camera is enabled on the camera.
  35050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35051. */
  35052. useFramingBehavior: boolean;
  35053. private _autoRotationBehavior;
  35054. /**
  35055. * Gets the auto rotation behavior of the camera if it has been enabled.
  35056. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35057. */
  35058. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35059. /**
  35060. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35061. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35062. */
  35063. useAutoRotationBehavior: boolean;
  35064. /**
  35065. * Observable triggered when the mesh target has been changed on the camera.
  35066. */
  35067. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35068. /**
  35069. * Event raised when the camera is colliding with a mesh.
  35070. */
  35071. onCollide: (collidedMesh: AbstractMesh) => void;
  35072. /**
  35073. * Defines whether the camera should check collision with the objects oh the scene.
  35074. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35075. */
  35076. checkCollisions: boolean;
  35077. /**
  35078. * Defines the collision radius of the camera.
  35079. * This simulates a sphere around the camera.
  35080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35081. */
  35082. collisionRadius: Vector3;
  35083. protected _collider: Collider;
  35084. protected _previousPosition: Vector3;
  35085. protected _collisionVelocity: Vector3;
  35086. protected _newPosition: Vector3;
  35087. protected _previousAlpha: number;
  35088. protected _previousBeta: number;
  35089. protected _previousRadius: number;
  35090. protected _collisionTriggered: boolean;
  35091. protected _targetBoundingCenter: Nullable<Vector3>;
  35092. private _computationVector;
  35093. private _tempAxisVector;
  35094. private _tempAxisRotationMatrix;
  35095. /**
  35096. * Instantiates a new ArcRotateCamera in a given scene
  35097. * @param name Defines the name of the camera
  35098. * @param alpha Defines the camera rotation along the logitudinal axis
  35099. * @param beta Defines the camera rotation along the latitudinal axis
  35100. * @param radius Defines the camera distance from its target
  35101. * @param target Defines the camera target
  35102. * @param scene Defines the scene the camera belongs to
  35103. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35104. */
  35105. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35106. /** @hidden */
  35107. _initCache(): void;
  35108. /** @hidden */
  35109. _updateCache(ignoreParentClass?: boolean): void;
  35110. protected _getTargetPosition(): Vector3;
  35111. private _storedAlpha;
  35112. private _storedBeta;
  35113. private _storedRadius;
  35114. private _storedTarget;
  35115. /**
  35116. * Stores the current state of the camera (alpha, beta, radius and target)
  35117. * @returns the camera itself
  35118. */
  35119. storeState(): Camera;
  35120. /**
  35121. * @hidden
  35122. * Restored camera state. You must call storeState() first
  35123. */
  35124. _restoreStateValues(): boolean;
  35125. /** @hidden */
  35126. _isSynchronizedViewMatrix(): boolean;
  35127. /**
  35128. * Attached controls to the current camera.
  35129. * @param element Defines the element the controls should be listened from
  35130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35131. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35132. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35133. */
  35134. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35135. /**
  35136. * Detach the current controls from the camera.
  35137. * The camera will stop reacting to inputs.
  35138. * @param element Defines the element to stop listening the inputs from
  35139. */
  35140. detachControl(element: HTMLElement): void;
  35141. /** @hidden */
  35142. _checkInputs(): void;
  35143. protected _checkLimits(): void;
  35144. /**
  35145. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35146. */
  35147. rebuildAnglesAndRadius(): void;
  35148. /**
  35149. * Use a position to define the current camera related information like aplha, beta and radius
  35150. * @param position Defines the position to set the camera at
  35151. */
  35152. setPosition(position: Vector3): void;
  35153. /**
  35154. * Defines the target the camera should look at.
  35155. * This will automatically adapt alpha beta and radius to fit within the new target.
  35156. * @param target Defines the new target as a Vector or a mesh
  35157. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35158. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35159. */
  35160. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35161. /** @hidden */
  35162. _getViewMatrix(): Matrix;
  35163. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35164. /**
  35165. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35166. * @param meshes Defines the mesh to zoom on
  35167. * @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)
  35168. */
  35169. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35170. /**
  35171. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35172. * The target will be changed but the radius
  35173. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35174. * @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)
  35175. */
  35176. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35177. min: Vector3;
  35178. max: Vector3;
  35179. distance: number;
  35180. }, doNotUpdateMaxZ?: boolean): void;
  35181. /**
  35182. * @override
  35183. * Override Camera.createRigCamera
  35184. */
  35185. createRigCamera(name: string, cameraIndex: number): Camera;
  35186. /**
  35187. * @hidden
  35188. * @override
  35189. * Override Camera._updateRigCameras
  35190. */
  35191. _updateRigCameras(): void;
  35192. /**
  35193. * Destroy the camera and release the current resources hold by it.
  35194. */
  35195. dispose(): void;
  35196. /**
  35197. * Gets the current object class name.
  35198. * @return the class name
  35199. */
  35200. getClassName(): string;
  35201. }
  35202. }
  35203. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35204. import { Behavior } from "babylonjs/Behaviors/behavior";
  35205. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35206. /**
  35207. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35208. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35209. */
  35210. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35211. /**
  35212. * Gets the name of the behavior.
  35213. */
  35214. readonly name: string;
  35215. private _zoomStopsAnimation;
  35216. private _idleRotationSpeed;
  35217. private _idleRotationWaitTime;
  35218. private _idleRotationSpinupTime;
  35219. /**
  35220. * Sets the flag that indicates if user zooming should stop animation.
  35221. */
  35222. /**
  35223. * Gets the flag that indicates if user zooming should stop animation.
  35224. */
  35225. zoomStopsAnimation: boolean;
  35226. /**
  35227. * Sets the default speed at which the camera rotates around the model.
  35228. */
  35229. /**
  35230. * Gets the default speed at which the camera rotates around the model.
  35231. */
  35232. idleRotationSpeed: number;
  35233. /**
  35234. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35235. */
  35236. /**
  35237. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35238. */
  35239. idleRotationWaitTime: number;
  35240. /**
  35241. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35242. */
  35243. /**
  35244. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35245. */
  35246. idleRotationSpinupTime: number;
  35247. /**
  35248. * Gets a value indicating if the camera is currently rotating because of this behavior
  35249. */
  35250. readonly rotationInProgress: boolean;
  35251. private _onPrePointerObservableObserver;
  35252. private _onAfterCheckInputsObserver;
  35253. private _attachedCamera;
  35254. private _isPointerDown;
  35255. private _lastFrameTime;
  35256. private _lastInteractionTime;
  35257. private _cameraRotationSpeed;
  35258. /**
  35259. * Initializes the behavior.
  35260. */
  35261. init(): void;
  35262. /**
  35263. * Attaches the behavior to its arc rotate camera.
  35264. * @param camera Defines the camera to attach the behavior to
  35265. */
  35266. attach(camera: ArcRotateCamera): void;
  35267. /**
  35268. * Detaches the behavior from its current arc rotate camera.
  35269. */
  35270. detach(): void;
  35271. /**
  35272. * Returns true if user is scrolling.
  35273. * @return true if user is scrolling.
  35274. */
  35275. private _userIsZooming;
  35276. private _lastFrameRadius;
  35277. private _shouldAnimationStopForInteraction;
  35278. /**
  35279. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35280. */
  35281. private _applyUserInteraction;
  35282. private _userIsMoving;
  35283. }
  35284. }
  35285. declare module "babylonjs/Behaviors/Cameras/index" {
  35286. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35287. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35288. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35289. }
  35290. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35291. import { Mesh } from "babylonjs/Meshes/mesh";
  35292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35293. import { Behavior } from "babylonjs/Behaviors/behavior";
  35294. /**
  35295. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35296. */
  35297. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35298. private ui;
  35299. /**
  35300. * The name of the behavior
  35301. */
  35302. name: string;
  35303. /**
  35304. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35305. */
  35306. distanceAwayFromFace: number;
  35307. /**
  35308. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35309. */
  35310. distanceAwayFromBottomOfFace: number;
  35311. private _faceVectors;
  35312. private _target;
  35313. private _scene;
  35314. private _onRenderObserver;
  35315. private _tmpMatrix;
  35316. private _tmpVector;
  35317. /**
  35318. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35319. * @param ui The transform node that should be attched to the mesh
  35320. */
  35321. constructor(ui: TransformNode);
  35322. /**
  35323. * Initializes the behavior
  35324. */
  35325. init(): void;
  35326. private _closestFace;
  35327. private _zeroVector;
  35328. private _lookAtTmpMatrix;
  35329. private _lookAtToRef;
  35330. /**
  35331. * Attaches the AttachToBoxBehavior to the passed in mesh
  35332. * @param target The mesh that the specified node will be attached to
  35333. */
  35334. attach(target: Mesh): void;
  35335. /**
  35336. * Detaches the behavior from the mesh
  35337. */
  35338. detach(): void;
  35339. }
  35340. }
  35341. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35342. import { Behavior } from "babylonjs/Behaviors/behavior";
  35343. import { Mesh } from "babylonjs/Meshes/mesh";
  35344. /**
  35345. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35346. */
  35347. export class FadeInOutBehavior implements Behavior<Mesh> {
  35348. /**
  35349. * Time in milliseconds to delay before fading in (Default: 0)
  35350. */
  35351. delay: number;
  35352. /**
  35353. * Time in milliseconds for the mesh to fade in (Default: 300)
  35354. */
  35355. fadeInTime: number;
  35356. private _millisecondsPerFrame;
  35357. private _hovered;
  35358. private _hoverValue;
  35359. private _ownerNode;
  35360. /**
  35361. * Instatiates the FadeInOutBehavior
  35362. */
  35363. constructor();
  35364. /**
  35365. * The name of the behavior
  35366. */
  35367. readonly name: string;
  35368. /**
  35369. * Initializes the behavior
  35370. */
  35371. init(): void;
  35372. /**
  35373. * Attaches the fade behavior on the passed in mesh
  35374. * @param ownerNode The mesh that will be faded in/out once attached
  35375. */
  35376. attach(ownerNode: Mesh): void;
  35377. /**
  35378. * Detaches the behavior from the mesh
  35379. */
  35380. detach(): void;
  35381. /**
  35382. * Triggers the mesh to begin fading in or out
  35383. * @param value if the object should fade in or out (true to fade in)
  35384. */
  35385. fadeIn(value: boolean): void;
  35386. private _update;
  35387. private _setAllVisibility;
  35388. }
  35389. }
  35390. declare module "babylonjs/Misc/pivotTools" {
  35391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35392. /**
  35393. * Class containing a set of static utilities functions for managing Pivots
  35394. * @hidden
  35395. */
  35396. export class PivotTools {
  35397. private static _PivotCached;
  35398. private static _OldPivotPoint;
  35399. private static _PivotTranslation;
  35400. private static _PivotTmpVector;
  35401. /** @hidden */
  35402. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35403. /** @hidden */
  35404. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35405. }
  35406. }
  35407. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35408. import { Scene } from "babylonjs/scene";
  35409. import { Vector4, Plane } from "babylonjs/Maths/math";
  35410. import { Mesh } from "babylonjs/Meshes/mesh";
  35411. /**
  35412. * Class containing static functions to help procedurally build meshes
  35413. */
  35414. export class PlaneBuilder {
  35415. /**
  35416. * Creates a plane mesh
  35417. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35418. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35419. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35423. * @param name defines the name of the mesh
  35424. * @param options defines the options used to create the mesh
  35425. * @param scene defines the hosting scene
  35426. * @returns the plane mesh
  35427. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35428. */
  35429. static CreatePlane(name: string, options: {
  35430. size?: number;
  35431. width?: number;
  35432. height?: number;
  35433. sideOrientation?: number;
  35434. frontUVs?: Vector4;
  35435. backUVs?: Vector4;
  35436. updatable?: boolean;
  35437. sourcePlane?: Plane;
  35438. }, scene: Scene): Mesh;
  35439. }
  35440. }
  35441. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35442. import { Behavior } from "babylonjs/Behaviors/behavior";
  35443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35444. import { Observable } from "babylonjs/Misc/observable";
  35445. import { Vector3 } from "babylonjs/Maths/math";
  35446. import { Ray } from "babylonjs/Culling/ray";
  35447. import "babylonjs/Meshes/Builders/planeBuilder";
  35448. /**
  35449. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35450. */
  35451. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35452. private static _AnyMouseID;
  35453. private _attachedNode;
  35454. private _dragPlane;
  35455. private _scene;
  35456. private _pointerObserver;
  35457. private _beforeRenderObserver;
  35458. private static _planeScene;
  35459. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35460. /**
  35461. * 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)
  35462. */
  35463. maxDragAngle: number;
  35464. /**
  35465. * @hidden
  35466. */
  35467. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35468. /**
  35469. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35470. */
  35471. currentDraggingPointerID: number;
  35472. /**
  35473. * The last position where the pointer hit the drag plane in world space
  35474. */
  35475. lastDragPosition: Vector3;
  35476. /**
  35477. * If the behavior is currently in a dragging state
  35478. */
  35479. dragging: boolean;
  35480. /**
  35481. * 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)
  35482. */
  35483. dragDeltaRatio: number;
  35484. /**
  35485. * If the drag plane orientation should be updated during the dragging (Default: true)
  35486. */
  35487. updateDragPlane: boolean;
  35488. private _debugMode;
  35489. private _moving;
  35490. /**
  35491. * Fires each time the attached mesh is dragged with the pointer
  35492. * * delta between last drag position and current drag position in world space
  35493. * * dragDistance along the drag axis
  35494. * * dragPlaneNormal normal of the current drag plane used during the drag
  35495. * * dragPlanePoint in world space where the drag intersects the drag plane
  35496. */
  35497. onDragObservable: Observable<{
  35498. delta: Vector3;
  35499. dragPlanePoint: Vector3;
  35500. dragPlaneNormal: Vector3;
  35501. dragDistance: number;
  35502. pointerId: number;
  35503. }>;
  35504. /**
  35505. * Fires each time a drag begins (eg. mouse down on mesh)
  35506. */
  35507. onDragStartObservable: Observable<{
  35508. dragPlanePoint: Vector3;
  35509. pointerId: number;
  35510. }>;
  35511. /**
  35512. * Fires each time a drag ends (eg. mouse release after drag)
  35513. */
  35514. onDragEndObservable: Observable<{
  35515. dragPlanePoint: Vector3;
  35516. pointerId: number;
  35517. }>;
  35518. /**
  35519. * If the attached mesh should be moved when dragged
  35520. */
  35521. moveAttached: boolean;
  35522. /**
  35523. * If the drag behavior will react to drag events (Default: true)
  35524. */
  35525. enabled: boolean;
  35526. /**
  35527. * If camera controls should be detached during the drag
  35528. */
  35529. detachCameraControls: boolean;
  35530. /**
  35531. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35532. */
  35533. useObjectOrienationForDragging: boolean;
  35534. private _options;
  35535. /**
  35536. * Creates a pointer drag behavior that can be attached to a mesh
  35537. * @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)
  35538. */
  35539. constructor(options?: {
  35540. dragAxis?: Vector3;
  35541. dragPlaneNormal?: Vector3;
  35542. });
  35543. /**
  35544. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35545. */
  35546. validateDrag: (targetPosition: Vector3) => boolean;
  35547. /**
  35548. * The name of the behavior
  35549. */
  35550. readonly name: string;
  35551. /**
  35552. * Initializes the behavior
  35553. */
  35554. init(): void;
  35555. private _tmpVector;
  35556. private _alternatePickedPoint;
  35557. private _worldDragAxis;
  35558. private _targetPosition;
  35559. private _attachedElement;
  35560. /**
  35561. * Attaches the drag behavior the passed in mesh
  35562. * @param ownerNode The mesh that will be dragged around once attached
  35563. */
  35564. attach(ownerNode: AbstractMesh): void;
  35565. /**
  35566. * Force relase the drag action by code.
  35567. */
  35568. releaseDrag(): void;
  35569. private _startDragRay;
  35570. private _lastPointerRay;
  35571. /**
  35572. * Simulates the start of a pointer drag event on the behavior
  35573. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35574. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35575. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35576. */
  35577. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35578. private _startDrag;
  35579. private _dragDelta;
  35580. private _moveDrag;
  35581. private _pickWithRayOnDragPlane;
  35582. private _pointA;
  35583. private _pointB;
  35584. private _pointC;
  35585. private _lineA;
  35586. private _lineB;
  35587. private _localAxis;
  35588. private _lookAt;
  35589. private _updateDragPlanePosition;
  35590. /**
  35591. * Detaches the behavior from the mesh
  35592. */
  35593. detach(): void;
  35594. }
  35595. }
  35596. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35597. import { Mesh } from "babylonjs/Meshes/mesh";
  35598. import { Behavior } from "babylonjs/Behaviors/behavior";
  35599. /**
  35600. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35601. */
  35602. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35603. private _dragBehaviorA;
  35604. private _dragBehaviorB;
  35605. private _startDistance;
  35606. private _initialScale;
  35607. private _targetScale;
  35608. private _ownerNode;
  35609. private _sceneRenderObserver;
  35610. /**
  35611. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35612. */
  35613. constructor();
  35614. /**
  35615. * The name of the behavior
  35616. */
  35617. readonly name: string;
  35618. /**
  35619. * Initializes the behavior
  35620. */
  35621. init(): void;
  35622. private _getCurrentDistance;
  35623. /**
  35624. * Attaches the scale behavior the passed in mesh
  35625. * @param ownerNode The mesh that will be scaled around once attached
  35626. */
  35627. attach(ownerNode: Mesh): void;
  35628. /**
  35629. * Detaches the behavior from the mesh
  35630. */
  35631. detach(): void;
  35632. }
  35633. }
  35634. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35635. import { Behavior } from "babylonjs/Behaviors/behavior";
  35636. import { Mesh } from "babylonjs/Meshes/mesh";
  35637. import { Observable } from "babylonjs/Misc/observable";
  35638. /**
  35639. * 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
  35640. */
  35641. export class SixDofDragBehavior implements Behavior<Mesh> {
  35642. private static _virtualScene;
  35643. private _ownerNode;
  35644. private _sceneRenderObserver;
  35645. private _scene;
  35646. private _targetPosition;
  35647. private _virtualOriginMesh;
  35648. private _virtualDragMesh;
  35649. private _pointerObserver;
  35650. private _moving;
  35651. private _startingOrientation;
  35652. /**
  35653. * 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)
  35654. */
  35655. private zDragFactor;
  35656. /**
  35657. * If the object should rotate to face the drag origin
  35658. */
  35659. rotateDraggedObject: boolean;
  35660. /**
  35661. * If the behavior is currently in a dragging state
  35662. */
  35663. dragging: boolean;
  35664. /**
  35665. * 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)
  35666. */
  35667. dragDeltaRatio: number;
  35668. /**
  35669. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35670. */
  35671. currentDraggingPointerID: number;
  35672. /**
  35673. * If camera controls should be detached during the drag
  35674. */
  35675. detachCameraControls: boolean;
  35676. /**
  35677. * Fires each time a drag starts
  35678. */
  35679. onDragStartObservable: Observable<{}>;
  35680. /**
  35681. * Fires each time a drag ends (eg. mouse release after drag)
  35682. */
  35683. onDragEndObservable: Observable<{}>;
  35684. /**
  35685. * 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
  35686. */
  35687. constructor();
  35688. /**
  35689. * The name of the behavior
  35690. */
  35691. readonly name: string;
  35692. /**
  35693. * Initializes the behavior
  35694. */
  35695. init(): void;
  35696. /**
  35697. * Attaches the scale behavior the passed in mesh
  35698. * @param ownerNode The mesh that will be scaled around once attached
  35699. */
  35700. attach(ownerNode: Mesh): void;
  35701. /**
  35702. * Detaches the behavior from the mesh
  35703. */
  35704. detach(): void;
  35705. }
  35706. }
  35707. declare module "babylonjs/Behaviors/Meshes/index" {
  35708. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35709. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35710. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35711. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35712. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35713. }
  35714. declare module "babylonjs/Behaviors/index" {
  35715. export * from "babylonjs/Behaviors/behavior";
  35716. export * from "babylonjs/Behaviors/Cameras/index";
  35717. export * from "babylonjs/Behaviors/Meshes/index";
  35718. }
  35719. declare module "babylonjs/Bones/boneIKController" {
  35720. import { Bone } from "babylonjs/Bones/bone";
  35721. import { Vector3 } from "babylonjs/Maths/math";
  35722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35723. import { Nullable } from "babylonjs/types";
  35724. /**
  35725. * Class used to apply inverse kinematics to bones
  35726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35727. */
  35728. export class BoneIKController {
  35729. private static _tmpVecs;
  35730. private static _tmpQuat;
  35731. private static _tmpMats;
  35732. /**
  35733. * Gets or sets the target mesh
  35734. */
  35735. targetMesh: AbstractMesh;
  35736. /** Gets or sets the mesh used as pole */
  35737. poleTargetMesh: AbstractMesh;
  35738. /**
  35739. * Gets or sets the bone used as pole
  35740. */
  35741. poleTargetBone: Nullable<Bone>;
  35742. /**
  35743. * Gets or sets the target position
  35744. */
  35745. targetPosition: Vector3;
  35746. /**
  35747. * Gets or sets the pole target position
  35748. */
  35749. poleTargetPosition: Vector3;
  35750. /**
  35751. * Gets or sets the pole target local offset
  35752. */
  35753. poleTargetLocalOffset: Vector3;
  35754. /**
  35755. * Gets or sets the pole angle
  35756. */
  35757. poleAngle: number;
  35758. /**
  35759. * Gets or sets the mesh associated with the controller
  35760. */
  35761. mesh: AbstractMesh;
  35762. /**
  35763. * 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)
  35764. */
  35765. slerpAmount: number;
  35766. private _bone1Quat;
  35767. private _bone1Mat;
  35768. private _bone2Ang;
  35769. private _bone1;
  35770. private _bone2;
  35771. private _bone1Length;
  35772. private _bone2Length;
  35773. private _maxAngle;
  35774. private _maxReach;
  35775. private _rightHandedSystem;
  35776. private _bendAxis;
  35777. private _slerping;
  35778. private _adjustRoll;
  35779. /**
  35780. * Gets or sets maximum allowed angle
  35781. */
  35782. maxAngle: number;
  35783. /**
  35784. * Creates a new BoneIKController
  35785. * @param mesh defines the mesh to control
  35786. * @param bone defines the bone to control
  35787. * @param options defines options to set up the controller
  35788. */
  35789. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35790. targetMesh?: AbstractMesh;
  35791. poleTargetMesh?: AbstractMesh;
  35792. poleTargetBone?: Bone;
  35793. poleTargetLocalOffset?: Vector3;
  35794. poleAngle?: number;
  35795. bendAxis?: Vector3;
  35796. maxAngle?: number;
  35797. slerpAmount?: number;
  35798. });
  35799. private _setMaxAngle;
  35800. /**
  35801. * Force the controller to update the bones
  35802. */
  35803. update(): void;
  35804. }
  35805. }
  35806. declare module "babylonjs/Bones/boneLookController" {
  35807. import { Vector3, Space } from "babylonjs/Maths/math";
  35808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35809. import { Bone } from "babylonjs/Bones/bone";
  35810. /**
  35811. * Class used to make a bone look toward a point in space
  35812. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35813. */
  35814. export class BoneLookController {
  35815. private static _tmpVecs;
  35816. private static _tmpQuat;
  35817. private static _tmpMats;
  35818. /**
  35819. * The target Vector3 that the bone will look at
  35820. */
  35821. target: Vector3;
  35822. /**
  35823. * The mesh that the bone is attached to
  35824. */
  35825. mesh: AbstractMesh;
  35826. /**
  35827. * The bone that will be looking to the target
  35828. */
  35829. bone: Bone;
  35830. /**
  35831. * The up axis of the coordinate system that is used when the bone is rotated
  35832. */
  35833. upAxis: Vector3;
  35834. /**
  35835. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35836. */
  35837. upAxisSpace: Space;
  35838. /**
  35839. * Used to make an adjustment to the yaw of the bone
  35840. */
  35841. adjustYaw: number;
  35842. /**
  35843. * Used to make an adjustment to the pitch of the bone
  35844. */
  35845. adjustPitch: number;
  35846. /**
  35847. * Used to make an adjustment to the roll of the bone
  35848. */
  35849. adjustRoll: number;
  35850. /**
  35851. * 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)
  35852. */
  35853. slerpAmount: number;
  35854. private _minYaw;
  35855. private _maxYaw;
  35856. private _minPitch;
  35857. private _maxPitch;
  35858. private _minYawSin;
  35859. private _minYawCos;
  35860. private _maxYawSin;
  35861. private _maxYawCos;
  35862. private _midYawConstraint;
  35863. private _minPitchTan;
  35864. private _maxPitchTan;
  35865. private _boneQuat;
  35866. private _slerping;
  35867. private _transformYawPitch;
  35868. private _transformYawPitchInv;
  35869. private _firstFrameSkipped;
  35870. private _yawRange;
  35871. private _fowardAxis;
  35872. /**
  35873. * Gets or sets the minimum yaw angle that the bone can look to
  35874. */
  35875. minYaw: number;
  35876. /**
  35877. * Gets or sets the maximum yaw angle that the bone can look to
  35878. */
  35879. maxYaw: number;
  35880. /**
  35881. * Gets or sets the minimum pitch angle that the bone can look to
  35882. */
  35883. minPitch: number;
  35884. /**
  35885. * Gets or sets the maximum pitch angle that the bone can look to
  35886. */
  35887. maxPitch: number;
  35888. /**
  35889. * Create a BoneLookController
  35890. * @param mesh the mesh that the bone belongs to
  35891. * @param bone the bone that will be looking to the target
  35892. * @param target the target Vector3 to look at
  35893. * @param options optional settings:
  35894. * * maxYaw: the maximum angle the bone will yaw to
  35895. * * minYaw: the minimum angle the bone will yaw to
  35896. * * maxPitch: the maximum angle the bone will pitch to
  35897. * * minPitch: the minimum angle the bone will yaw to
  35898. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35899. * * upAxis: the up axis of the coordinate system
  35900. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35901. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35902. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35903. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35904. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35905. * * adjustRoll: used to make an adjustment to the roll of the bone
  35906. **/
  35907. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35908. maxYaw?: number;
  35909. minYaw?: number;
  35910. maxPitch?: number;
  35911. minPitch?: number;
  35912. slerpAmount?: number;
  35913. upAxis?: Vector3;
  35914. upAxisSpace?: Space;
  35915. yawAxis?: Vector3;
  35916. pitchAxis?: Vector3;
  35917. adjustYaw?: number;
  35918. adjustPitch?: number;
  35919. adjustRoll?: number;
  35920. });
  35921. /**
  35922. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35923. */
  35924. update(): void;
  35925. private _getAngleDiff;
  35926. private _getAngleBetween;
  35927. private _isAngleBetween;
  35928. }
  35929. }
  35930. declare module "babylonjs/Bones/index" {
  35931. export * from "babylonjs/Bones/bone";
  35932. export * from "babylonjs/Bones/boneIKController";
  35933. export * from "babylonjs/Bones/boneLookController";
  35934. export * from "babylonjs/Bones/skeleton";
  35935. }
  35936. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35937. import { Nullable } from "babylonjs/types";
  35938. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35939. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35940. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35941. /**
  35942. * Manage the gamepad inputs to control an arc rotate camera.
  35943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35944. */
  35945. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35946. /**
  35947. * Defines the camera the input is attached to.
  35948. */
  35949. camera: ArcRotateCamera;
  35950. /**
  35951. * Defines the gamepad the input is gathering event from.
  35952. */
  35953. gamepad: Nullable<Gamepad>;
  35954. /**
  35955. * Defines the gamepad rotation sensiblity.
  35956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35957. */
  35958. gamepadRotationSensibility: number;
  35959. /**
  35960. * Defines the gamepad move sensiblity.
  35961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35962. */
  35963. gamepadMoveSensibility: number;
  35964. private _onGamepadConnectedObserver;
  35965. private _onGamepadDisconnectedObserver;
  35966. /**
  35967. * Attach the input controls to a specific dom element to get the input from.
  35968. * @param element Defines the element the controls should be listened from
  35969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35970. */
  35971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35972. /**
  35973. * Detach the current controls from the specified dom element.
  35974. * @param element Defines the element to stop listening the inputs from
  35975. */
  35976. detachControl(element: Nullable<HTMLElement>): void;
  35977. /**
  35978. * Update the current camera state depending on the inputs that have been used this frame.
  35979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35980. */
  35981. checkInputs(): void;
  35982. /**
  35983. * Gets the class name of the current intput.
  35984. * @returns the class name
  35985. */
  35986. getClassName(): string;
  35987. /**
  35988. * Get the friendly name associated with the input class.
  35989. * @returns the input friendly name
  35990. */
  35991. getSimpleName(): string;
  35992. }
  35993. }
  35994. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  35995. import { Nullable } from "babylonjs/types";
  35996. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35997. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35998. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35999. interface ArcRotateCameraInputsManager {
  36000. /**
  36001. * Add orientation input support to the input manager.
  36002. * @returns the current input manager
  36003. */
  36004. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36005. }
  36006. }
  36007. /**
  36008. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36010. */
  36011. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36012. /**
  36013. * Defines the camera the input is attached to.
  36014. */
  36015. camera: ArcRotateCamera;
  36016. /**
  36017. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36018. */
  36019. alphaCorrection: number;
  36020. /**
  36021. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36022. */
  36023. gammaCorrection: number;
  36024. private _alpha;
  36025. private _gamma;
  36026. private _dirty;
  36027. private _deviceOrientationHandler;
  36028. /**
  36029. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36030. */
  36031. constructor();
  36032. /**
  36033. * Attach the input controls to a specific dom element to get the input from.
  36034. * @param element Defines the element the controls should be listened from
  36035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36036. */
  36037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36038. /** @hidden */
  36039. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36040. /**
  36041. * Update the current camera state depending on the inputs that have been used this frame.
  36042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36043. */
  36044. checkInputs(): void;
  36045. /**
  36046. * Detach the current controls from the specified dom element.
  36047. * @param element Defines the element to stop listening the inputs from
  36048. */
  36049. detachControl(element: Nullable<HTMLElement>): void;
  36050. /**
  36051. * Gets the class name of the current intput.
  36052. * @returns the class name
  36053. */
  36054. getClassName(): string;
  36055. /**
  36056. * Get the friendly name associated with the input class.
  36057. * @returns the input friendly name
  36058. */
  36059. getSimpleName(): string;
  36060. }
  36061. }
  36062. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36063. import { Nullable } from "babylonjs/types";
  36064. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36065. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36066. /**
  36067. * Listen to mouse events to control the camera.
  36068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36069. */
  36070. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36071. /**
  36072. * Defines the camera the input is attached to.
  36073. */
  36074. camera: FlyCamera;
  36075. /**
  36076. * Defines if touch is enabled. (Default is true.)
  36077. */
  36078. touchEnabled: boolean;
  36079. /**
  36080. * Defines the buttons associated with the input to handle camera rotation.
  36081. */
  36082. buttons: number[];
  36083. /**
  36084. * Assign buttons for Yaw control.
  36085. */
  36086. buttonsYaw: number[];
  36087. /**
  36088. * Assign buttons for Pitch control.
  36089. */
  36090. buttonsPitch: number[];
  36091. /**
  36092. * Assign buttons for Roll control.
  36093. */
  36094. buttonsRoll: number[];
  36095. /**
  36096. * Detect if any button is being pressed while mouse is moved.
  36097. * -1 = Mouse locked.
  36098. * 0 = Left button.
  36099. * 1 = Middle Button.
  36100. * 2 = Right Button.
  36101. */
  36102. activeButton: number;
  36103. /**
  36104. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36105. * Higher values reduce its sensitivity.
  36106. */
  36107. angularSensibility: number;
  36108. private _mousemoveCallback;
  36109. private _observer;
  36110. private _rollObserver;
  36111. private previousPosition;
  36112. private noPreventDefault;
  36113. private element;
  36114. /**
  36115. * Listen to mouse events to control the camera.
  36116. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36118. */
  36119. constructor(touchEnabled?: boolean);
  36120. /**
  36121. * Attach the mouse control to the HTML DOM element.
  36122. * @param element Defines the element that listens to the input events.
  36123. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36124. */
  36125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36126. /**
  36127. * Detach the current controls from the specified dom element.
  36128. * @param element Defines the element to stop listening the inputs from
  36129. */
  36130. detachControl(element: Nullable<HTMLElement>): void;
  36131. /**
  36132. * Gets the class name of the current input.
  36133. * @returns the class name.
  36134. */
  36135. getClassName(): string;
  36136. /**
  36137. * Get the friendly name associated with the input class.
  36138. * @returns the input's friendly name.
  36139. */
  36140. getSimpleName(): string;
  36141. private _pointerInput;
  36142. private _onMouseMove;
  36143. /**
  36144. * Rotate camera by mouse offset.
  36145. */
  36146. private rotateCamera;
  36147. }
  36148. }
  36149. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36150. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36151. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36152. /**
  36153. * Default Inputs manager for the FlyCamera.
  36154. * It groups all the default supported inputs for ease of use.
  36155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36156. */
  36157. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36158. /**
  36159. * Instantiates a new FlyCameraInputsManager.
  36160. * @param camera Defines the camera the inputs belong to.
  36161. */
  36162. constructor(camera: FlyCamera);
  36163. /**
  36164. * Add keyboard input support to the input manager.
  36165. * @returns the new FlyCameraKeyboardMoveInput().
  36166. */
  36167. addKeyboard(): FlyCameraInputsManager;
  36168. /**
  36169. * Add mouse input support to the input manager.
  36170. * @param touchEnabled Enable touch screen support.
  36171. * @returns the new FlyCameraMouseInput().
  36172. */
  36173. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36174. }
  36175. }
  36176. declare module "babylonjs/Cameras/flyCamera" {
  36177. import { Scene } from "babylonjs/scene";
  36178. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36180. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36181. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36182. /**
  36183. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36184. * such as in a 3D Space Shooter or a Flight Simulator.
  36185. */
  36186. export class FlyCamera extends TargetCamera {
  36187. /**
  36188. * Define the collision ellipsoid of the camera.
  36189. * This is helpful for simulating a camera body, like a player's body.
  36190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36191. */
  36192. ellipsoid: Vector3;
  36193. /**
  36194. * Define an offset for the position of the ellipsoid around the camera.
  36195. * This can be helpful if the camera is attached away from the player's body center,
  36196. * such as at its head.
  36197. */
  36198. ellipsoidOffset: Vector3;
  36199. /**
  36200. * Enable or disable collisions of the camera with the rest of the scene objects.
  36201. */
  36202. checkCollisions: boolean;
  36203. /**
  36204. * Enable or disable gravity on the camera.
  36205. */
  36206. applyGravity: boolean;
  36207. /**
  36208. * Define the current direction the camera is moving to.
  36209. */
  36210. cameraDirection: Vector3;
  36211. /**
  36212. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36213. * This overrides and empties cameraRotation.
  36214. */
  36215. rotationQuaternion: Quaternion;
  36216. /**
  36217. * Track Roll to maintain the wanted Rolling when looking around.
  36218. */
  36219. _trackRoll: number;
  36220. /**
  36221. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36222. */
  36223. rollCorrect: number;
  36224. /**
  36225. * Mimic a banked turn, Rolling the camera when Yawing.
  36226. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36227. */
  36228. bankedTurn: boolean;
  36229. /**
  36230. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36231. */
  36232. bankedTurnLimit: number;
  36233. /**
  36234. * Value of 0 disables the banked Roll.
  36235. * Value of 1 is equal to the Yaw angle in radians.
  36236. */
  36237. bankedTurnMultiplier: number;
  36238. /**
  36239. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36240. */
  36241. inputs: FlyCameraInputsManager;
  36242. /**
  36243. * Gets the input sensibility for mouse input.
  36244. * Higher values reduce sensitivity.
  36245. */
  36246. /**
  36247. * Sets the input sensibility for a mouse input.
  36248. * Higher values reduce sensitivity.
  36249. */
  36250. angularSensibility: number;
  36251. /**
  36252. * Get the keys for camera movement forward.
  36253. */
  36254. /**
  36255. * Set the keys for camera movement forward.
  36256. */
  36257. keysForward: number[];
  36258. /**
  36259. * Get the keys for camera movement backward.
  36260. */
  36261. keysBackward: number[];
  36262. /**
  36263. * Get the keys for camera movement up.
  36264. */
  36265. /**
  36266. * Set the keys for camera movement up.
  36267. */
  36268. keysUp: number[];
  36269. /**
  36270. * Get the keys for camera movement down.
  36271. */
  36272. /**
  36273. * Set the keys for camera movement down.
  36274. */
  36275. keysDown: number[];
  36276. /**
  36277. * Get the keys for camera movement left.
  36278. */
  36279. /**
  36280. * Set the keys for camera movement left.
  36281. */
  36282. keysLeft: number[];
  36283. /**
  36284. * Set the keys for camera movement right.
  36285. */
  36286. /**
  36287. * Set the keys for camera movement right.
  36288. */
  36289. keysRight: number[];
  36290. /**
  36291. * Event raised when the camera collides with a mesh in the scene.
  36292. */
  36293. onCollide: (collidedMesh: AbstractMesh) => void;
  36294. private _collider;
  36295. private _needMoveForGravity;
  36296. private _oldPosition;
  36297. private _diffPosition;
  36298. private _newPosition;
  36299. /** @hidden */
  36300. _localDirection: Vector3;
  36301. /** @hidden */
  36302. _transformedDirection: Vector3;
  36303. /**
  36304. * Instantiates a FlyCamera.
  36305. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36306. * such as in a 3D Space Shooter or a Flight Simulator.
  36307. * @param name Define the name of the camera in the scene.
  36308. * @param position Define the starting position of the camera in the scene.
  36309. * @param scene Define the scene the camera belongs to.
  36310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36311. */
  36312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36313. /**
  36314. * Attach a control to the HTML DOM element.
  36315. * @param element Defines the element that listens to the input events.
  36316. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36317. */
  36318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36319. /**
  36320. * Detach a control from the HTML DOM element.
  36321. * The camera will stop reacting to that input.
  36322. * @param element Defines the element that listens to the input events.
  36323. */
  36324. detachControl(element: HTMLElement): void;
  36325. private _collisionMask;
  36326. /**
  36327. * Get the mask that the camera ignores in collision events.
  36328. */
  36329. /**
  36330. * Set the mask that the camera ignores in collision events.
  36331. */
  36332. collisionMask: number;
  36333. /** @hidden */
  36334. _collideWithWorld(displacement: Vector3): void;
  36335. /** @hidden */
  36336. private _onCollisionPositionChange;
  36337. /** @hidden */
  36338. _checkInputs(): void;
  36339. /** @hidden */
  36340. _decideIfNeedsToMove(): boolean;
  36341. /** @hidden */
  36342. _updatePosition(): void;
  36343. /**
  36344. * Restore the Roll to its target value at the rate specified.
  36345. * @param rate - Higher means slower restoring.
  36346. * @hidden
  36347. */
  36348. restoreRoll(rate: number): void;
  36349. /**
  36350. * Destroy the camera and release the current resources held by it.
  36351. */
  36352. dispose(): void;
  36353. /**
  36354. * Get the current object class name.
  36355. * @returns the class name.
  36356. */
  36357. getClassName(): string;
  36358. }
  36359. }
  36360. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36361. import { Nullable } from "babylonjs/types";
  36362. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36363. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36364. /**
  36365. * Listen to keyboard events to control the camera.
  36366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36367. */
  36368. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36369. /**
  36370. * Defines the camera the input is attached to.
  36371. */
  36372. camera: FlyCamera;
  36373. /**
  36374. * The list of keyboard keys used to control the forward move of the camera.
  36375. */
  36376. keysForward: number[];
  36377. /**
  36378. * The list of keyboard keys used to control the backward move of the camera.
  36379. */
  36380. keysBackward: number[];
  36381. /**
  36382. * The list of keyboard keys used to control the forward move of the camera.
  36383. */
  36384. keysUp: number[];
  36385. /**
  36386. * The list of keyboard keys used to control the backward move of the camera.
  36387. */
  36388. keysDown: number[];
  36389. /**
  36390. * The list of keyboard keys used to control the right strafe move of the camera.
  36391. */
  36392. keysRight: number[];
  36393. /**
  36394. * The list of keyboard keys used to control the left strafe move of the camera.
  36395. */
  36396. keysLeft: number[];
  36397. private _keys;
  36398. private _onCanvasBlurObserver;
  36399. private _onKeyboardObserver;
  36400. private _engine;
  36401. private _scene;
  36402. /**
  36403. * Attach the input controls to a specific dom element to get the input from.
  36404. * @param element Defines the element the controls should be listened from
  36405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36406. */
  36407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36408. /**
  36409. * Detach the current controls from the specified dom element.
  36410. * @param element Defines the element to stop listening the inputs from
  36411. */
  36412. detachControl(element: Nullable<HTMLElement>): void;
  36413. /**
  36414. * Gets the class name of the current intput.
  36415. * @returns the class name
  36416. */
  36417. getClassName(): string;
  36418. /** @hidden */
  36419. _onLostFocus(e: FocusEvent): void;
  36420. /**
  36421. * Get the friendly name associated with the input class.
  36422. * @returns the input friendly name
  36423. */
  36424. getSimpleName(): string;
  36425. /**
  36426. * Update the current camera state depending on the inputs that have been used this frame.
  36427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36428. */
  36429. checkInputs(): void;
  36430. }
  36431. }
  36432. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36433. import { Nullable } from "babylonjs/types";
  36434. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36435. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36436. module "babylonjs/Cameras/freeCameraInputsManager" {
  36437. interface FreeCameraInputsManager {
  36438. /**
  36439. * Add orientation input support to the input manager.
  36440. * @returns the current input manager
  36441. */
  36442. addDeviceOrientation(): FreeCameraInputsManager;
  36443. }
  36444. }
  36445. /**
  36446. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36447. * Screen rotation is taken into account.
  36448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36449. */
  36450. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36451. private _camera;
  36452. private _screenOrientationAngle;
  36453. private _constantTranform;
  36454. private _screenQuaternion;
  36455. private _alpha;
  36456. private _beta;
  36457. private _gamma;
  36458. /**
  36459. * Instantiates a new input
  36460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36461. */
  36462. constructor();
  36463. /**
  36464. * Define the camera controlled by the input.
  36465. */
  36466. camera: FreeCamera;
  36467. /**
  36468. * Attach the input controls to a specific dom element to get the input from.
  36469. * @param element Defines the element the controls should be listened from
  36470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36471. */
  36472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36473. private _orientationChanged;
  36474. private _deviceOrientation;
  36475. /**
  36476. * Detach the current controls from the specified dom element.
  36477. * @param element Defines the element to stop listening the inputs from
  36478. */
  36479. detachControl(element: Nullable<HTMLElement>): void;
  36480. /**
  36481. * Update the current camera state depending on the inputs that have been used this frame.
  36482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36483. */
  36484. checkInputs(): void;
  36485. /**
  36486. * Gets the class name of the current intput.
  36487. * @returns the class name
  36488. */
  36489. getClassName(): string;
  36490. /**
  36491. * Get the friendly name associated with the input class.
  36492. * @returns the input friendly name
  36493. */
  36494. getSimpleName(): string;
  36495. }
  36496. }
  36497. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36498. import { Nullable } from "babylonjs/types";
  36499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36500. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36501. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36502. /**
  36503. * Manage the gamepad inputs to control a free camera.
  36504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36505. */
  36506. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36507. /**
  36508. * Define the camera the input is attached to.
  36509. */
  36510. camera: FreeCamera;
  36511. /**
  36512. * Define the Gamepad controlling the input
  36513. */
  36514. gamepad: Nullable<Gamepad>;
  36515. /**
  36516. * Defines the gamepad rotation sensiblity.
  36517. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36518. */
  36519. gamepadAngularSensibility: number;
  36520. /**
  36521. * Defines the gamepad move sensiblity.
  36522. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36523. */
  36524. gamepadMoveSensibility: number;
  36525. private _onGamepadConnectedObserver;
  36526. private _onGamepadDisconnectedObserver;
  36527. private _cameraTransform;
  36528. private _deltaTransform;
  36529. private _vector3;
  36530. private _vector2;
  36531. /**
  36532. * Attach the input controls to a specific dom element to get the input from.
  36533. * @param element Defines the element the controls should be listened from
  36534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36535. */
  36536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36537. /**
  36538. * Detach the current controls from the specified dom element.
  36539. * @param element Defines the element to stop listening the inputs from
  36540. */
  36541. detachControl(element: Nullable<HTMLElement>): void;
  36542. /**
  36543. * Update the current camera state depending on the inputs that have been used this frame.
  36544. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36545. */
  36546. checkInputs(): void;
  36547. /**
  36548. * Gets the class name of the current intput.
  36549. * @returns the class name
  36550. */
  36551. getClassName(): string;
  36552. /**
  36553. * Get the friendly name associated with the input class.
  36554. * @returns the input friendly name
  36555. */
  36556. getSimpleName(): string;
  36557. }
  36558. }
  36559. declare module "babylonjs/Misc/virtualJoystick" {
  36560. import { Nullable } from "babylonjs/types";
  36561. import { Vector3 } from "babylonjs/Maths/math";
  36562. /**
  36563. * Defines the potential axis of a Joystick
  36564. */
  36565. export enum JoystickAxis {
  36566. /** X axis */
  36567. X = 0,
  36568. /** Y axis */
  36569. Y = 1,
  36570. /** Z axis */
  36571. Z = 2
  36572. }
  36573. /**
  36574. * Class used to define virtual joystick (used in touch mode)
  36575. */
  36576. export class VirtualJoystick {
  36577. /**
  36578. * Gets or sets a boolean indicating that left and right values must be inverted
  36579. */
  36580. reverseLeftRight: boolean;
  36581. /**
  36582. * Gets or sets a boolean indicating that up and down values must be inverted
  36583. */
  36584. reverseUpDown: boolean;
  36585. /**
  36586. * Gets the offset value for the position (ie. the change of the position value)
  36587. */
  36588. deltaPosition: Vector3;
  36589. /**
  36590. * Gets a boolean indicating if the virtual joystick was pressed
  36591. */
  36592. pressed: boolean;
  36593. /**
  36594. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36595. */
  36596. static Canvas: Nullable<HTMLCanvasElement>;
  36597. private static _globalJoystickIndex;
  36598. private static vjCanvasContext;
  36599. private static vjCanvasWidth;
  36600. private static vjCanvasHeight;
  36601. private static halfWidth;
  36602. private _action;
  36603. private _axisTargetedByLeftAndRight;
  36604. private _axisTargetedByUpAndDown;
  36605. private _joystickSensibility;
  36606. private _inversedSensibility;
  36607. private _joystickPointerID;
  36608. private _joystickColor;
  36609. private _joystickPointerPos;
  36610. private _joystickPreviousPointerPos;
  36611. private _joystickPointerStartPos;
  36612. private _deltaJoystickVector;
  36613. private _leftJoystick;
  36614. private _touches;
  36615. private _onPointerDownHandlerRef;
  36616. private _onPointerMoveHandlerRef;
  36617. private _onPointerUpHandlerRef;
  36618. private _onResize;
  36619. /**
  36620. * Creates a new virtual joystick
  36621. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36622. */
  36623. constructor(leftJoystick?: boolean);
  36624. /**
  36625. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36626. * @param newJoystickSensibility defines the new sensibility
  36627. */
  36628. setJoystickSensibility(newJoystickSensibility: number): void;
  36629. private _onPointerDown;
  36630. private _onPointerMove;
  36631. private _onPointerUp;
  36632. /**
  36633. * Change the color of the virtual joystick
  36634. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36635. */
  36636. setJoystickColor(newColor: string): void;
  36637. /**
  36638. * Defines a callback to call when the joystick is touched
  36639. * @param action defines the callback
  36640. */
  36641. setActionOnTouch(action: () => any): void;
  36642. /**
  36643. * Defines which axis you'd like to control for left & right
  36644. * @param axis defines the axis to use
  36645. */
  36646. setAxisForLeftRight(axis: JoystickAxis): void;
  36647. /**
  36648. * Defines which axis you'd like to control for up & down
  36649. * @param axis defines the axis to use
  36650. */
  36651. setAxisForUpDown(axis: JoystickAxis): void;
  36652. private _drawVirtualJoystick;
  36653. /**
  36654. * Release internal HTML canvas
  36655. */
  36656. releaseCanvas(): void;
  36657. }
  36658. }
  36659. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36660. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36661. import { Nullable } from "babylonjs/types";
  36662. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36663. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36664. module "babylonjs/Cameras/freeCameraInputsManager" {
  36665. interface FreeCameraInputsManager {
  36666. /**
  36667. * Add virtual joystick input support to the input manager.
  36668. * @returns the current input manager
  36669. */
  36670. addVirtualJoystick(): FreeCameraInputsManager;
  36671. }
  36672. }
  36673. /**
  36674. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36676. */
  36677. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36678. /**
  36679. * Defines the camera the input is attached to.
  36680. */
  36681. camera: FreeCamera;
  36682. private _leftjoystick;
  36683. private _rightjoystick;
  36684. /**
  36685. * Gets the left stick of the virtual joystick.
  36686. * @returns The virtual Joystick
  36687. */
  36688. getLeftJoystick(): VirtualJoystick;
  36689. /**
  36690. * Gets the right stick of the virtual joystick.
  36691. * @returns The virtual Joystick
  36692. */
  36693. getRightJoystick(): VirtualJoystick;
  36694. /**
  36695. * Update the current camera state depending on the inputs that have been used this frame.
  36696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36697. */
  36698. checkInputs(): void;
  36699. /**
  36700. * Attach the input controls to a specific dom element to get the input from.
  36701. * @param element Defines the element the controls should be listened from
  36702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36703. */
  36704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36705. /**
  36706. * Detach the current controls from the specified dom element.
  36707. * @param element Defines the element to stop listening the inputs from
  36708. */
  36709. detachControl(element: Nullable<HTMLElement>): void;
  36710. /**
  36711. * Gets the class name of the current intput.
  36712. * @returns the class name
  36713. */
  36714. getClassName(): string;
  36715. /**
  36716. * Get the friendly name associated with the input class.
  36717. * @returns the input friendly name
  36718. */
  36719. getSimpleName(): string;
  36720. }
  36721. }
  36722. declare module "babylonjs/Cameras/Inputs/index" {
  36723. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36724. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36725. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36726. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36727. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36728. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36729. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36730. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36731. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36732. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36733. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36734. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36735. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36736. }
  36737. declare module "babylonjs/Cameras/touchCamera" {
  36738. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36739. import { Scene } from "babylonjs/scene";
  36740. import { Vector3 } from "babylonjs/Maths/math";
  36741. /**
  36742. * This represents a FPS type of camera controlled by touch.
  36743. * This is like a universal camera minus the Gamepad controls.
  36744. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36745. */
  36746. export class TouchCamera extends FreeCamera {
  36747. /**
  36748. * Defines the touch sensibility for rotation.
  36749. * The higher the faster.
  36750. */
  36751. touchAngularSensibility: number;
  36752. /**
  36753. * Defines the touch sensibility for move.
  36754. * The higher the faster.
  36755. */
  36756. touchMoveSensibility: number;
  36757. /**
  36758. * Instantiates a new touch camera.
  36759. * This represents a FPS type of camera controlled by touch.
  36760. * This is like a universal camera minus the Gamepad controls.
  36761. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36762. * @param name Define the name of the camera in the scene
  36763. * @param position Define the start position of the camera in the scene
  36764. * @param scene Define the scene the camera belongs to
  36765. */
  36766. constructor(name: string, position: Vector3, scene: Scene);
  36767. /**
  36768. * Gets the current object class name.
  36769. * @return the class name
  36770. */
  36771. getClassName(): string;
  36772. /** @hidden */
  36773. _setupInputs(): void;
  36774. }
  36775. }
  36776. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36777. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36778. import { Scene } from "babylonjs/scene";
  36779. import { Vector3, Axis } from "babylonjs/Maths/math";
  36780. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36781. /**
  36782. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36783. * being tilted forward or back and left or right.
  36784. */
  36785. export class DeviceOrientationCamera extends FreeCamera {
  36786. private _initialQuaternion;
  36787. private _quaternionCache;
  36788. /**
  36789. * Creates a new device orientation camera
  36790. * @param name The name of the camera
  36791. * @param position The start position camera
  36792. * @param scene The scene the camera belongs to
  36793. */
  36794. constructor(name: string, position: Vector3, scene: Scene);
  36795. /**
  36796. * Gets the current instance class name ("DeviceOrientationCamera").
  36797. * This helps avoiding instanceof at run time.
  36798. * @returns the class name
  36799. */
  36800. getClassName(): string;
  36801. /**
  36802. * @hidden
  36803. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36804. */
  36805. _checkInputs(): void;
  36806. /**
  36807. * Reset the camera to its default orientation on the specified axis only.
  36808. * @param axis The axis to reset
  36809. */
  36810. resetToCurrentRotation(axis?: Axis): void;
  36811. }
  36812. }
  36813. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36814. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36815. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36816. import { Nullable } from "babylonjs/types";
  36817. /**
  36818. * Manage the keyboard inputs to control the movement of a follow camera.
  36819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36820. */
  36821. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36822. /**
  36823. * Defines the camera the input is attached to.
  36824. */
  36825. camera: FollowCamera;
  36826. /**
  36827. * Defines the list of key codes associated with the up action (increase heightOffset)
  36828. */
  36829. keysHeightOffsetIncr: number[];
  36830. /**
  36831. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36832. */
  36833. keysHeightOffsetDecr: number[];
  36834. /**
  36835. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36836. */
  36837. keysHeightOffsetModifierAlt: boolean;
  36838. /**
  36839. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36840. */
  36841. keysHeightOffsetModifierCtrl: boolean;
  36842. /**
  36843. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36844. */
  36845. keysHeightOffsetModifierShift: boolean;
  36846. /**
  36847. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36848. */
  36849. keysRotationOffsetIncr: number[];
  36850. /**
  36851. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36852. */
  36853. keysRotationOffsetDecr: number[];
  36854. /**
  36855. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36856. */
  36857. keysRotationOffsetModifierAlt: boolean;
  36858. /**
  36859. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36860. */
  36861. keysRotationOffsetModifierCtrl: boolean;
  36862. /**
  36863. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36864. */
  36865. keysRotationOffsetModifierShift: boolean;
  36866. /**
  36867. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36868. */
  36869. keysRadiusIncr: number[];
  36870. /**
  36871. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36872. */
  36873. keysRadiusDecr: number[];
  36874. /**
  36875. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36876. */
  36877. keysRadiusModifierAlt: boolean;
  36878. /**
  36879. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36880. */
  36881. keysRadiusModifierCtrl: boolean;
  36882. /**
  36883. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36884. */
  36885. keysRadiusModifierShift: boolean;
  36886. /**
  36887. * Defines the rate of change of heightOffset.
  36888. */
  36889. heightSensibility: number;
  36890. /**
  36891. * Defines the rate of change of rotationOffset.
  36892. */
  36893. rotationSensibility: number;
  36894. /**
  36895. * Defines the rate of change of radius.
  36896. */
  36897. radiusSensibility: number;
  36898. private _keys;
  36899. private _ctrlPressed;
  36900. private _altPressed;
  36901. private _shiftPressed;
  36902. private _onCanvasBlurObserver;
  36903. private _onKeyboardObserver;
  36904. private _engine;
  36905. private _scene;
  36906. /**
  36907. * Attach the input controls to a specific dom element to get the input from.
  36908. * @param element Defines the element the controls should be listened from
  36909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36910. */
  36911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36912. /**
  36913. * Detach the current controls from the specified dom element.
  36914. * @param element Defines the element to stop listening the inputs from
  36915. */
  36916. detachControl(element: Nullable<HTMLElement>): void;
  36917. /**
  36918. * Update the current camera state depending on the inputs that have been used this frame.
  36919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36920. */
  36921. checkInputs(): void;
  36922. /**
  36923. * Gets the class name of the current input.
  36924. * @returns the class name
  36925. */
  36926. getClassName(): string;
  36927. /**
  36928. * Get the friendly name associated with the input class.
  36929. * @returns the input friendly name
  36930. */
  36931. getSimpleName(): string;
  36932. /**
  36933. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36934. * allow modification of the heightOffset value.
  36935. */
  36936. private _modifierHeightOffset;
  36937. /**
  36938. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36939. * allow modification of the rotationOffset value.
  36940. */
  36941. private _modifierRotationOffset;
  36942. /**
  36943. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36944. * allow modification of the radius value.
  36945. */
  36946. private _modifierRadius;
  36947. }
  36948. }
  36949. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36950. import { Nullable } from "babylonjs/types";
  36951. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36952. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36953. /**
  36954. * Manage the mouse wheel inputs to control a follow camera.
  36955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36956. */
  36957. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36958. /**
  36959. * Defines the camera the input is attached to.
  36960. */
  36961. camera: FollowCamera;
  36962. /**
  36963. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36964. */
  36965. axisControlRadius: boolean;
  36966. /**
  36967. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36968. */
  36969. axisControlHeight: boolean;
  36970. /**
  36971. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36972. */
  36973. axisControlRotation: boolean;
  36974. /**
  36975. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36976. * relation to mouseWheel events.
  36977. */
  36978. wheelPrecision: number;
  36979. /**
  36980. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36981. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36982. */
  36983. wheelDeltaPercentage: number;
  36984. private _wheel;
  36985. private _observer;
  36986. /**
  36987. * Attach the input controls to a specific dom element to get the input from.
  36988. * @param element Defines the element the controls should be listened from
  36989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36990. */
  36991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36992. /**
  36993. * Detach the current controls from the specified dom element.
  36994. * @param element Defines the element to stop listening the inputs from
  36995. */
  36996. detachControl(element: Nullable<HTMLElement>): void;
  36997. /**
  36998. * Gets the class name of the current intput.
  36999. * @returns the class name
  37000. */
  37001. getClassName(): string;
  37002. /**
  37003. * Get the friendly name associated with the input class.
  37004. * @returns the input friendly name
  37005. */
  37006. getSimpleName(): string;
  37007. }
  37008. }
  37009. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37010. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37011. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37012. /**
  37013. * Default Inputs manager for the FollowCamera.
  37014. * It groups all the default supported inputs for ease of use.
  37015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37016. */
  37017. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37018. /**
  37019. * Instantiates a new FollowCameraInputsManager.
  37020. * @param camera Defines the camera the inputs belong to
  37021. */
  37022. constructor(camera: FollowCamera);
  37023. /**
  37024. * Add keyboard input support to the input manager.
  37025. * @returns the current input manager
  37026. */
  37027. addKeyboard(): FollowCameraInputsManager;
  37028. /**
  37029. * Add mouse wheel input support to the input manager.
  37030. * @returns the current input manager
  37031. */
  37032. addMouseWheel(): FollowCameraInputsManager;
  37033. /**
  37034. * Add pointers input support to the input manager.
  37035. * @returns the current input manager
  37036. */
  37037. addPointers(): FollowCameraInputsManager;
  37038. /**
  37039. * Add orientation input support to the input manager.
  37040. * @returns the current input manager
  37041. */
  37042. addVRDeviceOrientation(): FollowCameraInputsManager;
  37043. }
  37044. }
  37045. declare module "babylonjs/Cameras/followCamera" {
  37046. import { Nullable } from "babylonjs/types";
  37047. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37048. import { Scene } from "babylonjs/scene";
  37049. import { Vector3 } from "babylonjs/Maths/math";
  37050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37051. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37052. /**
  37053. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37054. * an arc rotate version arcFollowCamera are available.
  37055. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37056. */
  37057. export class FollowCamera extends TargetCamera {
  37058. /**
  37059. * Distance the follow camera should follow an object at
  37060. */
  37061. radius: number;
  37062. /**
  37063. * Minimum allowed distance of the camera to the axis of rotation
  37064. * (The camera can not get closer).
  37065. * This can help limiting how the Camera is able to move in the scene.
  37066. */
  37067. lowerRadiusLimit: Nullable<number>;
  37068. /**
  37069. * Maximum allowed distance of the camera to the axis of rotation
  37070. * (The camera can not get further).
  37071. * This can help limiting how the Camera is able to move in the scene.
  37072. */
  37073. upperRadiusLimit: Nullable<number>;
  37074. /**
  37075. * Define a rotation offset between the camera and the object it follows
  37076. */
  37077. rotationOffset: number;
  37078. /**
  37079. * Minimum allowed angle to camera position relative to target object.
  37080. * This can help limiting how the Camera is able to move in the scene.
  37081. */
  37082. lowerRotationOffsetLimit: Nullable<number>;
  37083. /**
  37084. * Maximum allowed angle to camera position relative to target object.
  37085. * This can help limiting how the Camera is able to move in the scene.
  37086. */
  37087. upperRotationOffsetLimit: Nullable<number>;
  37088. /**
  37089. * Define a height offset between the camera and the object it follows.
  37090. * It can help following an object from the top (like a car chaing a plane)
  37091. */
  37092. heightOffset: number;
  37093. /**
  37094. * Minimum allowed height of camera position relative to target object.
  37095. * This can help limiting how the Camera is able to move in the scene.
  37096. */
  37097. lowerHeightOffsetLimit: Nullable<number>;
  37098. /**
  37099. * Maximum allowed height of camera position relative to target object.
  37100. * This can help limiting how the Camera is able to move in the scene.
  37101. */
  37102. upperHeightOffsetLimit: Nullable<number>;
  37103. /**
  37104. * Define how fast the camera can accelerate to follow it s target.
  37105. */
  37106. cameraAcceleration: number;
  37107. /**
  37108. * Define the speed limit of the camera following an object.
  37109. */
  37110. maxCameraSpeed: number;
  37111. /**
  37112. * Define the target of the camera.
  37113. */
  37114. lockedTarget: Nullable<AbstractMesh>;
  37115. /**
  37116. * Defines the input associated with the camera.
  37117. */
  37118. inputs: FollowCameraInputsManager;
  37119. /**
  37120. * Instantiates the follow camera.
  37121. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37122. * @param name Define the name of the camera in the scene
  37123. * @param position Define the position of the camera
  37124. * @param scene Define the scene the camera belong to
  37125. * @param lockedTarget Define the target of the camera
  37126. */
  37127. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37128. private _follow;
  37129. /**
  37130. * Attached controls to the current camera.
  37131. * @param element Defines the element the controls should be listened from
  37132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37133. */
  37134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37135. /**
  37136. * Detach the current controls from the camera.
  37137. * The camera will stop reacting to inputs.
  37138. * @param element Defines the element to stop listening the inputs from
  37139. */
  37140. detachControl(element: HTMLElement): void;
  37141. /** @hidden */
  37142. _checkInputs(): void;
  37143. private _checkLimits;
  37144. /**
  37145. * Gets the camera class name.
  37146. * @returns the class name
  37147. */
  37148. getClassName(): string;
  37149. }
  37150. /**
  37151. * Arc Rotate version of the follow camera.
  37152. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37153. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37154. */
  37155. export class ArcFollowCamera extends TargetCamera {
  37156. /** The longitudinal angle of the camera */
  37157. alpha: number;
  37158. /** The latitudinal angle of the camera */
  37159. beta: number;
  37160. /** The radius of the camera from its target */
  37161. radius: number;
  37162. /** Define the camera target (the messh it should follow) */
  37163. target: Nullable<AbstractMesh>;
  37164. private _cartesianCoordinates;
  37165. /**
  37166. * Instantiates a new ArcFollowCamera
  37167. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37168. * @param name Define the name of the camera
  37169. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37170. * @param beta Define the rotation angle of the camera around the elevation axis
  37171. * @param radius Define the radius of the camera from its target point
  37172. * @param target Define the target of the camera
  37173. * @param scene Define the scene the camera belongs to
  37174. */
  37175. constructor(name: string,
  37176. /** The longitudinal angle of the camera */
  37177. alpha: number,
  37178. /** The latitudinal angle of the camera */
  37179. beta: number,
  37180. /** The radius of the camera from its target */
  37181. radius: number,
  37182. /** Define the camera target (the messh it should follow) */
  37183. target: Nullable<AbstractMesh>, scene: Scene);
  37184. private _follow;
  37185. /** @hidden */
  37186. _checkInputs(): void;
  37187. /**
  37188. * Returns the class name of the object.
  37189. * It is mostly used internally for serialization purposes.
  37190. */
  37191. getClassName(): string;
  37192. }
  37193. }
  37194. declare module "babylonjs/Cameras/universalCamera" {
  37195. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37196. import { Scene } from "babylonjs/scene";
  37197. import { Vector3 } from "babylonjs/Maths/math";
  37198. /**
  37199. * 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,
  37200. * which still works and will still be found in many Playgrounds.
  37201. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37202. */
  37203. export class UniversalCamera extends TouchCamera {
  37204. /**
  37205. * Defines the gamepad rotation sensiblity.
  37206. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37207. */
  37208. gamepadAngularSensibility: number;
  37209. /**
  37210. * Defines the gamepad move sensiblity.
  37211. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37212. */
  37213. gamepadMoveSensibility: number;
  37214. /**
  37215. * 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,
  37216. * which still works and will still be found in many Playgrounds.
  37217. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37218. * @param name Define the name of the camera in the scene
  37219. * @param position Define the start position of the camera in the scene
  37220. * @param scene Define the scene the camera belongs to
  37221. */
  37222. constructor(name: string, position: Vector3, scene: Scene);
  37223. /**
  37224. * Gets the current object class name.
  37225. * @return the class name
  37226. */
  37227. getClassName(): string;
  37228. }
  37229. }
  37230. declare module "babylonjs/Cameras/gamepadCamera" {
  37231. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37232. import { Scene } from "babylonjs/scene";
  37233. import { Vector3 } from "babylonjs/Maths/math";
  37234. /**
  37235. * This represents a FPS type of camera. This is only here for back compat purpose.
  37236. * Please use the UniversalCamera instead as both are identical.
  37237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37238. */
  37239. export class GamepadCamera extends UniversalCamera {
  37240. /**
  37241. * Instantiates a new Gamepad Camera
  37242. * This represents a FPS type of camera. This is only here for back compat purpose.
  37243. * Please use the UniversalCamera instead as both are identical.
  37244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37245. * @param name Define the name of the camera in the scene
  37246. * @param position Define the start position of the camera in the scene
  37247. * @param scene Define the scene the camera belongs to
  37248. */
  37249. constructor(name: string, position: Vector3, scene: Scene);
  37250. /**
  37251. * Gets the current object class name.
  37252. * @return the class name
  37253. */
  37254. getClassName(): string;
  37255. }
  37256. }
  37257. declare module "babylonjs/Shaders/pass.fragment" {
  37258. /** @hidden */
  37259. export var passPixelShader: {
  37260. name: string;
  37261. shader: string;
  37262. };
  37263. }
  37264. declare module "babylonjs/Shaders/passCube.fragment" {
  37265. /** @hidden */
  37266. export var passCubePixelShader: {
  37267. name: string;
  37268. shader: string;
  37269. };
  37270. }
  37271. declare module "babylonjs/PostProcesses/passPostProcess" {
  37272. import { Nullable } from "babylonjs/types";
  37273. import { Camera } from "babylonjs/Cameras/camera";
  37274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37275. import { Engine } from "babylonjs/Engines/engine";
  37276. import "babylonjs/Shaders/pass.fragment";
  37277. import "babylonjs/Shaders/passCube.fragment";
  37278. /**
  37279. * PassPostProcess which produces an output the same as it's input
  37280. */
  37281. export class PassPostProcess extends PostProcess {
  37282. /**
  37283. * Creates the PassPostProcess
  37284. * @param name The name of the effect.
  37285. * @param options The required width/height ratio to downsize to before computing the render pass.
  37286. * @param camera The camera to apply the render pass to.
  37287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37288. * @param engine The engine which the post process will be applied. (default: current engine)
  37289. * @param reusable If the post process can be reused on the same frame. (default: false)
  37290. * @param textureType The type of texture to be used when performing the post processing.
  37291. * @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)
  37292. */
  37293. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37294. }
  37295. /**
  37296. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37297. */
  37298. export class PassCubePostProcess extends PostProcess {
  37299. private _face;
  37300. /**
  37301. * Gets or sets the cube face to display.
  37302. * * 0 is +X
  37303. * * 1 is -X
  37304. * * 2 is +Y
  37305. * * 3 is -Y
  37306. * * 4 is +Z
  37307. * * 5 is -Z
  37308. */
  37309. face: number;
  37310. /**
  37311. * Creates the PassCubePostProcess
  37312. * @param name The name of the effect.
  37313. * @param options The required width/height ratio to downsize to before computing the render pass.
  37314. * @param camera The camera to apply the render pass to.
  37315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37316. * @param engine The engine which the post process will be applied. (default: current engine)
  37317. * @param reusable If the post process can be reused on the same frame. (default: false)
  37318. * @param textureType The type of texture to be used when performing the post processing.
  37319. * @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)
  37320. */
  37321. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37322. }
  37323. }
  37324. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37325. /** @hidden */
  37326. export var anaglyphPixelShader: {
  37327. name: string;
  37328. shader: string;
  37329. };
  37330. }
  37331. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37332. import { Engine } from "babylonjs/Engines/engine";
  37333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37334. import { Camera } from "babylonjs/Cameras/camera";
  37335. import "babylonjs/Shaders/anaglyph.fragment";
  37336. /**
  37337. * Postprocess used to generate anaglyphic rendering
  37338. */
  37339. export class AnaglyphPostProcess extends PostProcess {
  37340. private _passedProcess;
  37341. /**
  37342. * Creates a new AnaglyphPostProcess
  37343. * @param name defines postprocess name
  37344. * @param options defines creation options or target ratio scale
  37345. * @param rigCameras defines cameras using this postprocess
  37346. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37347. * @param engine defines hosting engine
  37348. * @param reusable defines if the postprocess will be reused multiple times per frame
  37349. */
  37350. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37351. }
  37352. }
  37353. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37354. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37355. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37356. import { Scene } from "babylonjs/scene";
  37357. import { Vector3 } from "babylonjs/Maths/math";
  37358. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37359. /**
  37360. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37361. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37362. */
  37363. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37364. /**
  37365. * Creates a new AnaglyphArcRotateCamera
  37366. * @param name defines camera name
  37367. * @param alpha defines alpha angle (in radians)
  37368. * @param beta defines beta angle (in radians)
  37369. * @param radius defines radius
  37370. * @param target defines camera target
  37371. * @param interaxialDistance defines distance between each color axis
  37372. * @param scene defines the hosting scene
  37373. */
  37374. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37375. /**
  37376. * Gets camera class name
  37377. * @returns AnaglyphArcRotateCamera
  37378. */
  37379. getClassName(): string;
  37380. }
  37381. }
  37382. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37383. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37384. import { Scene } from "babylonjs/scene";
  37385. import { Vector3 } from "babylonjs/Maths/math";
  37386. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37387. /**
  37388. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37390. */
  37391. export class AnaglyphFreeCamera extends FreeCamera {
  37392. /**
  37393. * Creates a new AnaglyphFreeCamera
  37394. * @param name defines camera name
  37395. * @param position defines initial position
  37396. * @param interaxialDistance defines distance between each color axis
  37397. * @param scene defines the hosting scene
  37398. */
  37399. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37400. /**
  37401. * Gets camera class name
  37402. * @returns AnaglyphFreeCamera
  37403. */
  37404. getClassName(): string;
  37405. }
  37406. }
  37407. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37408. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37409. import { Scene } from "babylonjs/scene";
  37410. import { Vector3 } from "babylonjs/Maths/math";
  37411. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37412. /**
  37413. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37414. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37415. */
  37416. export class AnaglyphGamepadCamera extends GamepadCamera {
  37417. /**
  37418. * Creates a new AnaglyphGamepadCamera
  37419. * @param name defines camera name
  37420. * @param position defines initial position
  37421. * @param interaxialDistance defines distance between each color axis
  37422. * @param scene defines the hosting scene
  37423. */
  37424. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37425. /**
  37426. * Gets camera class name
  37427. * @returns AnaglyphGamepadCamera
  37428. */
  37429. getClassName(): string;
  37430. }
  37431. }
  37432. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37433. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37434. import { Scene } from "babylonjs/scene";
  37435. import { Vector3 } from "babylonjs/Maths/math";
  37436. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37437. /**
  37438. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37440. */
  37441. export class AnaglyphUniversalCamera extends UniversalCamera {
  37442. /**
  37443. * Creates a new AnaglyphUniversalCamera
  37444. * @param name defines camera name
  37445. * @param position defines initial position
  37446. * @param interaxialDistance defines distance between each color axis
  37447. * @param scene defines the hosting scene
  37448. */
  37449. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37450. /**
  37451. * Gets camera class name
  37452. * @returns AnaglyphUniversalCamera
  37453. */
  37454. getClassName(): string;
  37455. }
  37456. }
  37457. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37458. /** @hidden */
  37459. export var stereoscopicInterlacePixelShader: {
  37460. name: string;
  37461. shader: string;
  37462. };
  37463. }
  37464. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37465. import { Camera } from "babylonjs/Cameras/camera";
  37466. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37467. import { Engine } from "babylonjs/Engines/engine";
  37468. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37469. /**
  37470. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37471. */
  37472. export class StereoscopicInterlacePostProcess extends PostProcess {
  37473. private _stepSize;
  37474. private _passedProcess;
  37475. /**
  37476. * Initializes a StereoscopicInterlacePostProcess
  37477. * @param name The name of the effect.
  37478. * @param rigCameras The rig cameras to be appled to the post process
  37479. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37481. * @param engine The engine which the post process will be applied. (default: current engine)
  37482. * @param reusable If the post process can be reused on the same frame. (default: false)
  37483. */
  37484. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37485. }
  37486. }
  37487. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37488. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37489. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37490. import { Scene } from "babylonjs/scene";
  37491. import { Vector3 } from "babylonjs/Maths/math";
  37492. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37493. /**
  37494. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37495. * @see http://doc.babylonjs.com/features/cameras
  37496. */
  37497. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37498. /**
  37499. * Creates a new StereoscopicArcRotateCamera
  37500. * @param name defines camera name
  37501. * @param alpha defines alpha angle (in radians)
  37502. * @param beta defines beta angle (in radians)
  37503. * @param radius defines radius
  37504. * @param target defines camera target
  37505. * @param interaxialDistance defines distance between each color axis
  37506. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37507. * @param scene defines the hosting scene
  37508. */
  37509. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37510. /**
  37511. * Gets camera class name
  37512. * @returns StereoscopicArcRotateCamera
  37513. */
  37514. getClassName(): string;
  37515. }
  37516. }
  37517. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37518. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37519. import { Scene } from "babylonjs/scene";
  37520. import { Vector3 } from "babylonjs/Maths/math";
  37521. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37522. /**
  37523. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37524. * @see http://doc.babylonjs.com/features/cameras
  37525. */
  37526. export class StereoscopicFreeCamera extends FreeCamera {
  37527. /**
  37528. * Creates a new StereoscopicFreeCamera
  37529. * @param name defines camera name
  37530. * @param position defines initial position
  37531. * @param interaxialDistance defines distance between each color axis
  37532. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37533. * @param scene defines the hosting scene
  37534. */
  37535. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37536. /**
  37537. * Gets camera class name
  37538. * @returns StereoscopicFreeCamera
  37539. */
  37540. getClassName(): string;
  37541. }
  37542. }
  37543. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37544. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37545. import { Scene } from "babylonjs/scene";
  37546. import { Vector3 } from "babylonjs/Maths/math";
  37547. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37548. /**
  37549. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37550. * @see http://doc.babylonjs.com/features/cameras
  37551. */
  37552. export class StereoscopicGamepadCamera extends GamepadCamera {
  37553. /**
  37554. * Creates a new StereoscopicGamepadCamera
  37555. * @param name defines camera name
  37556. * @param position defines initial position
  37557. * @param interaxialDistance defines distance between each color axis
  37558. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37559. * @param scene defines the hosting scene
  37560. */
  37561. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37562. /**
  37563. * Gets camera class name
  37564. * @returns StereoscopicGamepadCamera
  37565. */
  37566. getClassName(): string;
  37567. }
  37568. }
  37569. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37570. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37571. import { Scene } from "babylonjs/scene";
  37572. import { Vector3 } from "babylonjs/Maths/math";
  37573. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37574. /**
  37575. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37576. * @see http://doc.babylonjs.com/features/cameras
  37577. */
  37578. export class StereoscopicUniversalCamera extends UniversalCamera {
  37579. /**
  37580. * Creates a new StereoscopicUniversalCamera
  37581. * @param name defines camera name
  37582. * @param position defines initial position
  37583. * @param interaxialDistance defines distance between each color axis
  37584. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37585. * @param scene defines the hosting scene
  37586. */
  37587. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37588. /**
  37589. * Gets camera class name
  37590. * @returns StereoscopicUniversalCamera
  37591. */
  37592. getClassName(): string;
  37593. }
  37594. }
  37595. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37596. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37597. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37598. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37599. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37600. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37601. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37602. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37603. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37604. }
  37605. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37606. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37607. import { Scene } from "babylonjs/scene";
  37608. import { Vector3 } from "babylonjs/Maths/math";
  37609. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37610. /**
  37611. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37612. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37613. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37614. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37615. */
  37616. export class VirtualJoysticksCamera extends FreeCamera {
  37617. /**
  37618. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37619. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37620. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37621. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37622. * @param name Define the name of the camera in the scene
  37623. * @param position Define the start position of the camera in the scene
  37624. * @param scene Define the scene the camera belongs to
  37625. */
  37626. constructor(name: string, position: Vector3, scene: Scene);
  37627. /**
  37628. * Gets the current object class name.
  37629. * @return the class name
  37630. */
  37631. getClassName(): string;
  37632. }
  37633. }
  37634. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37635. import { Matrix } from "babylonjs/Maths/math";
  37636. /**
  37637. * This represents all the required metrics to create a VR camera.
  37638. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37639. */
  37640. export class VRCameraMetrics {
  37641. /**
  37642. * Define the horizontal resolution off the screen.
  37643. */
  37644. hResolution: number;
  37645. /**
  37646. * Define the vertical resolution off the screen.
  37647. */
  37648. vResolution: number;
  37649. /**
  37650. * Define the horizontal screen size.
  37651. */
  37652. hScreenSize: number;
  37653. /**
  37654. * Define the vertical screen size.
  37655. */
  37656. vScreenSize: number;
  37657. /**
  37658. * Define the vertical screen center position.
  37659. */
  37660. vScreenCenter: number;
  37661. /**
  37662. * Define the distance of the eyes to the screen.
  37663. */
  37664. eyeToScreenDistance: number;
  37665. /**
  37666. * Define the distance between both lenses
  37667. */
  37668. lensSeparationDistance: number;
  37669. /**
  37670. * Define the distance between both viewer's eyes.
  37671. */
  37672. interpupillaryDistance: number;
  37673. /**
  37674. * Define the distortion factor of the VR postprocess.
  37675. * Please, touch with care.
  37676. */
  37677. distortionK: number[];
  37678. /**
  37679. * Define the chromatic aberration correction factors for the VR post process.
  37680. */
  37681. chromaAbCorrection: number[];
  37682. /**
  37683. * Define the scale factor of the post process.
  37684. * The smaller the better but the slower.
  37685. */
  37686. postProcessScaleFactor: number;
  37687. /**
  37688. * Define an offset for the lens center.
  37689. */
  37690. lensCenterOffset: number;
  37691. /**
  37692. * Define if the current vr camera should compensate the distortion of the lense or not.
  37693. */
  37694. compensateDistortion: boolean;
  37695. /**
  37696. * Gets the rendering aspect ratio based on the provided resolutions.
  37697. */
  37698. readonly aspectRatio: number;
  37699. /**
  37700. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37701. */
  37702. readonly aspectRatioFov: number;
  37703. /**
  37704. * @hidden
  37705. */
  37706. readonly leftHMatrix: Matrix;
  37707. /**
  37708. * @hidden
  37709. */
  37710. readonly rightHMatrix: Matrix;
  37711. /**
  37712. * @hidden
  37713. */
  37714. readonly leftPreViewMatrix: Matrix;
  37715. /**
  37716. * @hidden
  37717. */
  37718. readonly rightPreViewMatrix: Matrix;
  37719. /**
  37720. * Get the default VRMetrics based on the most generic setup.
  37721. * @returns the default vr metrics
  37722. */
  37723. static GetDefault(): VRCameraMetrics;
  37724. }
  37725. }
  37726. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37727. /** @hidden */
  37728. export var vrDistortionCorrectionPixelShader: {
  37729. name: string;
  37730. shader: string;
  37731. };
  37732. }
  37733. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37734. import { Camera } from "babylonjs/Cameras/camera";
  37735. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37736. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37737. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37738. /**
  37739. * VRDistortionCorrectionPostProcess used for mobile VR
  37740. */
  37741. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37742. private _isRightEye;
  37743. private _distortionFactors;
  37744. private _postProcessScaleFactor;
  37745. private _lensCenterOffset;
  37746. private _scaleIn;
  37747. private _scaleFactor;
  37748. private _lensCenter;
  37749. /**
  37750. * Initializes the VRDistortionCorrectionPostProcess
  37751. * @param name The name of the effect.
  37752. * @param camera The camera to apply the render pass to.
  37753. * @param isRightEye If this is for the right eye distortion
  37754. * @param vrMetrics All the required metrics for the VR camera
  37755. */
  37756. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37757. }
  37758. }
  37759. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37760. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37761. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37762. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37763. import { Scene } from "babylonjs/scene";
  37764. import { Vector3 } from "babylonjs/Maths/math";
  37765. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37766. import "babylonjs/Cameras/RigModes/vrRigMode";
  37767. /**
  37768. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37769. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37770. */
  37771. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37772. /**
  37773. * Creates a new VRDeviceOrientationArcRotateCamera
  37774. * @param name defines camera name
  37775. * @param alpha defines the camera rotation along the logitudinal axis
  37776. * @param beta defines the camera rotation along the latitudinal axis
  37777. * @param radius defines the camera distance from its target
  37778. * @param target defines the camera target
  37779. * @param scene defines the scene the camera belongs to
  37780. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37781. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37782. */
  37783. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37784. /**
  37785. * Gets camera class name
  37786. * @returns VRDeviceOrientationArcRotateCamera
  37787. */
  37788. getClassName(): string;
  37789. }
  37790. }
  37791. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37792. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37793. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37794. import { Scene } from "babylonjs/scene";
  37795. import { Vector3 } from "babylonjs/Maths/math";
  37796. import "babylonjs/Cameras/RigModes/vrRigMode";
  37797. /**
  37798. * Camera used to simulate VR rendering (based on FreeCamera)
  37799. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37800. */
  37801. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37802. /**
  37803. * Creates a new VRDeviceOrientationFreeCamera
  37804. * @param name defines camera name
  37805. * @param position defines the start position of the camera
  37806. * @param scene defines the scene the camera belongs to
  37807. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37808. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37809. */
  37810. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37811. /**
  37812. * Gets camera class name
  37813. * @returns VRDeviceOrientationFreeCamera
  37814. */
  37815. getClassName(): string;
  37816. }
  37817. }
  37818. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37819. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37820. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37821. import { Scene } from "babylonjs/scene";
  37822. import { Vector3 } from "babylonjs/Maths/math";
  37823. /**
  37824. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37825. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37826. */
  37827. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37828. /**
  37829. * Creates a new VRDeviceOrientationGamepadCamera
  37830. * @param name defines camera name
  37831. * @param position defines the start position of the camera
  37832. * @param scene defines the scene the camera belongs to
  37833. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37834. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37835. */
  37836. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37837. /**
  37838. * Gets camera class name
  37839. * @returns VRDeviceOrientationGamepadCamera
  37840. */
  37841. getClassName(): string;
  37842. }
  37843. }
  37844. declare module "babylonjs/Gamepads/xboxGamepad" {
  37845. import { Observable } from "babylonjs/Misc/observable";
  37846. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37847. /**
  37848. * Defines supported buttons for XBox360 compatible gamepads
  37849. */
  37850. export enum Xbox360Button {
  37851. /** A */
  37852. A = 0,
  37853. /** B */
  37854. B = 1,
  37855. /** X */
  37856. X = 2,
  37857. /** Y */
  37858. Y = 3,
  37859. /** Start */
  37860. Start = 4,
  37861. /** Back */
  37862. Back = 5,
  37863. /** Left button */
  37864. LB = 6,
  37865. /** Right button */
  37866. RB = 7,
  37867. /** Left stick */
  37868. LeftStick = 8,
  37869. /** Right stick */
  37870. RightStick = 9
  37871. }
  37872. /** Defines values for XBox360 DPad */
  37873. export enum Xbox360Dpad {
  37874. /** Up */
  37875. Up = 0,
  37876. /** Down */
  37877. Down = 1,
  37878. /** Left */
  37879. Left = 2,
  37880. /** Right */
  37881. Right = 3
  37882. }
  37883. /**
  37884. * Defines a XBox360 gamepad
  37885. */
  37886. export class Xbox360Pad extends Gamepad {
  37887. private _leftTrigger;
  37888. private _rightTrigger;
  37889. private _onlefttriggerchanged;
  37890. private _onrighttriggerchanged;
  37891. private _onbuttondown;
  37892. private _onbuttonup;
  37893. private _ondpaddown;
  37894. private _ondpadup;
  37895. /** Observable raised when a button is pressed */
  37896. onButtonDownObservable: Observable<Xbox360Button>;
  37897. /** Observable raised when a button is released */
  37898. onButtonUpObservable: Observable<Xbox360Button>;
  37899. /** Observable raised when a pad is pressed */
  37900. onPadDownObservable: Observable<Xbox360Dpad>;
  37901. /** Observable raised when a pad is released */
  37902. onPadUpObservable: Observable<Xbox360Dpad>;
  37903. private _buttonA;
  37904. private _buttonB;
  37905. private _buttonX;
  37906. private _buttonY;
  37907. private _buttonBack;
  37908. private _buttonStart;
  37909. private _buttonLB;
  37910. private _buttonRB;
  37911. private _buttonLeftStick;
  37912. private _buttonRightStick;
  37913. private _dPadUp;
  37914. private _dPadDown;
  37915. private _dPadLeft;
  37916. private _dPadRight;
  37917. private _isXboxOnePad;
  37918. /**
  37919. * Creates a new XBox360 gamepad object
  37920. * @param id defines the id of this gamepad
  37921. * @param index defines its index
  37922. * @param gamepad defines the internal HTML gamepad object
  37923. * @param xboxOne defines if it is a XBox One gamepad
  37924. */
  37925. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37926. /**
  37927. * Defines the callback to call when left trigger is pressed
  37928. * @param callback defines the callback to use
  37929. */
  37930. onlefttriggerchanged(callback: (value: number) => void): void;
  37931. /**
  37932. * Defines the callback to call when right trigger is pressed
  37933. * @param callback defines the callback to use
  37934. */
  37935. onrighttriggerchanged(callback: (value: number) => void): void;
  37936. /**
  37937. * Gets the left trigger value
  37938. */
  37939. /**
  37940. * Sets the left trigger value
  37941. */
  37942. leftTrigger: number;
  37943. /**
  37944. * Gets the right trigger value
  37945. */
  37946. /**
  37947. * Sets the right trigger value
  37948. */
  37949. rightTrigger: number;
  37950. /**
  37951. * Defines the callback to call when a button is pressed
  37952. * @param callback defines the callback to use
  37953. */
  37954. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37955. /**
  37956. * Defines the callback to call when a button is released
  37957. * @param callback defines the callback to use
  37958. */
  37959. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37960. /**
  37961. * Defines the callback to call when a pad is pressed
  37962. * @param callback defines the callback to use
  37963. */
  37964. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37965. /**
  37966. * Defines the callback to call when a pad is released
  37967. * @param callback defines the callback to use
  37968. */
  37969. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37970. private _setButtonValue;
  37971. private _setDPadValue;
  37972. /**
  37973. * Gets the value of the `A` button
  37974. */
  37975. /**
  37976. * Sets the value of the `A` button
  37977. */
  37978. buttonA: number;
  37979. /**
  37980. * Gets the value of the `B` button
  37981. */
  37982. /**
  37983. * Sets the value of the `B` button
  37984. */
  37985. buttonB: number;
  37986. /**
  37987. * Gets the value of the `X` button
  37988. */
  37989. /**
  37990. * Sets the value of the `X` button
  37991. */
  37992. buttonX: number;
  37993. /**
  37994. * Gets the value of the `Y` button
  37995. */
  37996. /**
  37997. * Sets the value of the `Y` button
  37998. */
  37999. buttonY: number;
  38000. /**
  38001. * Gets the value of the `Start` button
  38002. */
  38003. /**
  38004. * Sets the value of the `Start` button
  38005. */
  38006. buttonStart: number;
  38007. /**
  38008. * Gets the value of the `Back` button
  38009. */
  38010. /**
  38011. * Sets the value of the `Back` button
  38012. */
  38013. buttonBack: number;
  38014. /**
  38015. * Gets the value of the `Left` button
  38016. */
  38017. /**
  38018. * Sets the value of the `Left` button
  38019. */
  38020. buttonLB: number;
  38021. /**
  38022. * Gets the value of the `Right` button
  38023. */
  38024. /**
  38025. * Sets the value of the `Right` button
  38026. */
  38027. buttonRB: number;
  38028. /**
  38029. * Gets the value of the Left joystick
  38030. */
  38031. /**
  38032. * Sets the value of the Left joystick
  38033. */
  38034. buttonLeftStick: number;
  38035. /**
  38036. * Gets the value of the Right joystick
  38037. */
  38038. /**
  38039. * Sets the value of the Right joystick
  38040. */
  38041. buttonRightStick: number;
  38042. /**
  38043. * Gets the value of D-pad up
  38044. */
  38045. /**
  38046. * Sets the value of D-pad up
  38047. */
  38048. dPadUp: number;
  38049. /**
  38050. * Gets the value of D-pad down
  38051. */
  38052. /**
  38053. * Sets the value of D-pad down
  38054. */
  38055. dPadDown: number;
  38056. /**
  38057. * Gets the value of D-pad left
  38058. */
  38059. /**
  38060. * Sets the value of D-pad left
  38061. */
  38062. dPadLeft: number;
  38063. /**
  38064. * Gets the value of D-pad right
  38065. */
  38066. /**
  38067. * Sets the value of D-pad right
  38068. */
  38069. dPadRight: number;
  38070. /**
  38071. * Force the gamepad to synchronize with device values
  38072. */
  38073. update(): void;
  38074. /**
  38075. * Disposes the gamepad
  38076. */
  38077. dispose(): void;
  38078. }
  38079. }
  38080. declare module "babylonjs/Materials/pushMaterial" {
  38081. import { Nullable } from "babylonjs/types";
  38082. import { Scene } from "babylonjs/scene";
  38083. import { Matrix } from "babylonjs/Maths/math";
  38084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38085. import { Mesh } from "babylonjs/Meshes/mesh";
  38086. import { Material } from "babylonjs/Materials/material";
  38087. import { Effect } from "babylonjs/Materials/effect";
  38088. /**
  38089. * Base class of materials working in push mode in babylon JS
  38090. * @hidden
  38091. */
  38092. export class PushMaterial extends Material {
  38093. protected _activeEffect: Effect;
  38094. protected _normalMatrix: Matrix;
  38095. /**
  38096. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38097. * This means that the material can keep using a previous shader while a new one is being compiled.
  38098. * This is mostly used when shader parallel compilation is supported (true by default)
  38099. */
  38100. allowShaderHotSwapping: boolean;
  38101. constructor(name: string, scene: Scene);
  38102. getEffect(): Effect;
  38103. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38104. /**
  38105. * Binds the given world matrix to the active effect
  38106. *
  38107. * @param world the matrix to bind
  38108. */
  38109. bindOnlyWorldMatrix(world: Matrix): void;
  38110. /**
  38111. * Binds the given normal matrix to the active effect
  38112. *
  38113. * @param normalMatrix the matrix to bind
  38114. */
  38115. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38116. bind(world: Matrix, mesh?: Mesh): void;
  38117. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38118. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38119. }
  38120. }
  38121. declare module "babylonjs/Materials/materialFlags" {
  38122. /**
  38123. * This groups all the flags used to control the materials channel.
  38124. */
  38125. export class MaterialFlags {
  38126. private static _DiffuseTextureEnabled;
  38127. /**
  38128. * Are diffuse textures enabled in the application.
  38129. */
  38130. static DiffuseTextureEnabled: boolean;
  38131. private static _AmbientTextureEnabled;
  38132. /**
  38133. * Are ambient textures enabled in the application.
  38134. */
  38135. static AmbientTextureEnabled: boolean;
  38136. private static _OpacityTextureEnabled;
  38137. /**
  38138. * Are opacity textures enabled in the application.
  38139. */
  38140. static OpacityTextureEnabled: boolean;
  38141. private static _ReflectionTextureEnabled;
  38142. /**
  38143. * Are reflection textures enabled in the application.
  38144. */
  38145. static ReflectionTextureEnabled: boolean;
  38146. private static _EmissiveTextureEnabled;
  38147. /**
  38148. * Are emissive textures enabled in the application.
  38149. */
  38150. static EmissiveTextureEnabled: boolean;
  38151. private static _SpecularTextureEnabled;
  38152. /**
  38153. * Are specular textures enabled in the application.
  38154. */
  38155. static SpecularTextureEnabled: boolean;
  38156. private static _BumpTextureEnabled;
  38157. /**
  38158. * Are bump textures enabled in the application.
  38159. */
  38160. static BumpTextureEnabled: boolean;
  38161. private static _LightmapTextureEnabled;
  38162. /**
  38163. * Are lightmap textures enabled in the application.
  38164. */
  38165. static LightmapTextureEnabled: boolean;
  38166. private static _RefractionTextureEnabled;
  38167. /**
  38168. * Are refraction textures enabled in the application.
  38169. */
  38170. static RefractionTextureEnabled: boolean;
  38171. private static _ColorGradingTextureEnabled;
  38172. /**
  38173. * Are color grading textures enabled in the application.
  38174. */
  38175. static ColorGradingTextureEnabled: boolean;
  38176. private static _FresnelEnabled;
  38177. /**
  38178. * Are fresnels enabled in the application.
  38179. */
  38180. static FresnelEnabled: boolean;
  38181. }
  38182. }
  38183. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38184. /** @hidden */
  38185. export var defaultFragmentDeclaration: {
  38186. name: string;
  38187. shader: string;
  38188. };
  38189. }
  38190. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38191. /** @hidden */
  38192. export var defaultUboDeclaration: {
  38193. name: string;
  38194. shader: string;
  38195. };
  38196. }
  38197. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38198. /** @hidden */
  38199. export var lightFragmentDeclaration: {
  38200. name: string;
  38201. shader: string;
  38202. };
  38203. }
  38204. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38205. /** @hidden */
  38206. export var lightUboDeclaration: {
  38207. name: string;
  38208. shader: string;
  38209. };
  38210. }
  38211. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38212. /** @hidden */
  38213. export var lightsFragmentFunctions: {
  38214. name: string;
  38215. shader: string;
  38216. };
  38217. }
  38218. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38219. /** @hidden */
  38220. export var shadowsFragmentFunctions: {
  38221. name: string;
  38222. shader: string;
  38223. };
  38224. }
  38225. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38226. /** @hidden */
  38227. export var fresnelFunction: {
  38228. name: string;
  38229. shader: string;
  38230. };
  38231. }
  38232. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38233. /** @hidden */
  38234. export var reflectionFunction: {
  38235. name: string;
  38236. shader: string;
  38237. };
  38238. }
  38239. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38240. /** @hidden */
  38241. export var bumpFragmentFunctions: {
  38242. name: string;
  38243. shader: string;
  38244. };
  38245. }
  38246. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38247. /** @hidden */
  38248. export var logDepthDeclaration: {
  38249. name: string;
  38250. shader: string;
  38251. };
  38252. }
  38253. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38254. /** @hidden */
  38255. export var bumpFragment: {
  38256. name: string;
  38257. shader: string;
  38258. };
  38259. }
  38260. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38261. /** @hidden */
  38262. export var depthPrePass: {
  38263. name: string;
  38264. shader: string;
  38265. };
  38266. }
  38267. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38268. /** @hidden */
  38269. export var lightFragment: {
  38270. name: string;
  38271. shader: string;
  38272. };
  38273. }
  38274. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38275. /** @hidden */
  38276. export var logDepthFragment: {
  38277. name: string;
  38278. shader: string;
  38279. };
  38280. }
  38281. declare module "babylonjs/Shaders/default.fragment" {
  38282. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38283. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38285. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38286. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38287. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38288. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38289. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38290. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38291. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38292. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38293. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38294. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38295. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38296. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38297. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38298. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38299. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38300. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38301. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38302. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38303. /** @hidden */
  38304. export var defaultPixelShader: {
  38305. name: string;
  38306. shader: string;
  38307. };
  38308. }
  38309. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38310. /** @hidden */
  38311. export var defaultVertexDeclaration: {
  38312. name: string;
  38313. shader: string;
  38314. };
  38315. }
  38316. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38317. /** @hidden */
  38318. export var bumpVertexDeclaration: {
  38319. name: string;
  38320. shader: string;
  38321. };
  38322. }
  38323. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38324. /** @hidden */
  38325. export var bumpVertex: {
  38326. name: string;
  38327. shader: string;
  38328. };
  38329. }
  38330. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38331. /** @hidden */
  38332. export var fogVertex: {
  38333. name: string;
  38334. shader: string;
  38335. };
  38336. }
  38337. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38338. /** @hidden */
  38339. export var shadowsVertex: {
  38340. name: string;
  38341. shader: string;
  38342. };
  38343. }
  38344. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38345. /** @hidden */
  38346. export var pointCloudVertex: {
  38347. name: string;
  38348. shader: string;
  38349. };
  38350. }
  38351. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38352. /** @hidden */
  38353. export var logDepthVertex: {
  38354. name: string;
  38355. shader: string;
  38356. };
  38357. }
  38358. declare module "babylonjs/Shaders/default.vertex" {
  38359. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38360. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38361. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38362. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38363. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38364. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38365. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38366. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38367. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38368. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38371. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38373. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38374. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38375. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38376. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38377. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38378. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38379. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38380. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38381. /** @hidden */
  38382. export var defaultVertexShader: {
  38383. name: string;
  38384. shader: string;
  38385. };
  38386. }
  38387. declare module "babylonjs/Materials/standardMaterial" {
  38388. import { SmartArray } from "babylonjs/Misc/smartArray";
  38389. import { IAnimatable } from "babylonjs/Misc/tools";
  38390. import { Nullable } from "babylonjs/types";
  38391. import { Scene } from "babylonjs/scene";
  38392. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38393. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38395. import { Mesh } from "babylonjs/Meshes/mesh";
  38396. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38397. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38398. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38399. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38400. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38403. import "babylonjs/Shaders/default.fragment";
  38404. import "babylonjs/Shaders/default.vertex";
  38405. /** @hidden */
  38406. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38407. MAINUV1: boolean;
  38408. MAINUV2: boolean;
  38409. DIFFUSE: boolean;
  38410. DIFFUSEDIRECTUV: number;
  38411. AMBIENT: boolean;
  38412. AMBIENTDIRECTUV: number;
  38413. OPACITY: boolean;
  38414. OPACITYDIRECTUV: number;
  38415. OPACITYRGB: boolean;
  38416. REFLECTION: boolean;
  38417. EMISSIVE: boolean;
  38418. EMISSIVEDIRECTUV: number;
  38419. SPECULAR: boolean;
  38420. SPECULARDIRECTUV: number;
  38421. BUMP: boolean;
  38422. BUMPDIRECTUV: number;
  38423. PARALLAX: boolean;
  38424. PARALLAXOCCLUSION: boolean;
  38425. SPECULAROVERALPHA: boolean;
  38426. CLIPPLANE: boolean;
  38427. CLIPPLANE2: boolean;
  38428. CLIPPLANE3: boolean;
  38429. CLIPPLANE4: boolean;
  38430. ALPHATEST: boolean;
  38431. DEPTHPREPASS: boolean;
  38432. ALPHAFROMDIFFUSE: boolean;
  38433. POINTSIZE: boolean;
  38434. FOG: boolean;
  38435. SPECULARTERM: boolean;
  38436. DIFFUSEFRESNEL: boolean;
  38437. OPACITYFRESNEL: boolean;
  38438. REFLECTIONFRESNEL: boolean;
  38439. REFRACTIONFRESNEL: boolean;
  38440. EMISSIVEFRESNEL: boolean;
  38441. FRESNEL: boolean;
  38442. NORMAL: boolean;
  38443. UV1: boolean;
  38444. UV2: boolean;
  38445. VERTEXCOLOR: boolean;
  38446. VERTEXALPHA: boolean;
  38447. NUM_BONE_INFLUENCERS: number;
  38448. BonesPerMesh: number;
  38449. BONETEXTURE: boolean;
  38450. INSTANCES: boolean;
  38451. GLOSSINESS: boolean;
  38452. ROUGHNESS: boolean;
  38453. EMISSIVEASILLUMINATION: boolean;
  38454. LINKEMISSIVEWITHDIFFUSE: boolean;
  38455. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38456. LIGHTMAP: boolean;
  38457. LIGHTMAPDIRECTUV: number;
  38458. OBJECTSPACE_NORMALMAP: boolean;
  38459. USELIGHTMAPASSHADOWMAP: boolean;
  38460. REFLECTIONMAP_3D: boolean;
  38461. REFLECTIONMAP_SPHERICAL: boolean;
  38462. REFLECTIONMAP_PLANAR: boolean;
  38463. REFLECTIONMAP_CUBIC: boolean;
  38464. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38465. REFLECTIONMAP_PROJECTION: boolean;
  38466. REFLECTIONMAP_SKYBOX: boolean;
  38467. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38468. REFLECTIONMAP_EXPLICIT: boolean;
  38469. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38470. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38471. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38472. INVERTCUBICMAP: boolean;
  38473. LOGARITHMICDEPTH: boolean;
  38474. REFRACTION: boolean;
  38475. REFRACTIONMAP_3D: boolean;
  38476. REFLECTIONOVERALPHA: boolean;
  38477. TWOSIDEDLIGHTING: boolean;
  38478. SHADOWFLOAT: boolean;
  38479. MORPHTARGETS: boolean;
  38480. MORPHTARGETS_NORMAL: boolean;
  38481. MORPHTARGETS_TANGENT: boolean;
  38482. NUM_MORPH_INFLUENCERS: number;
  38483. NONUNIFORMSCALING: boolean;
  38484. PREMULTIPLYALPHA: boolean;
  38485. IMAGEPROCESSING: boolean;
  38486. VIGNETTE: boolean;
  38487. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38488. VIGNETTEBLENDMODEOPAQUE: boolean;
  38489. TONEMAPPING: boolean;
  38490. TONEMAPPING_ACES: boolean;
  38491. CONTRAST: boolean;
  38492. COLORCURVES: boolean;
  38493. COLORGRADING: boolean;
  38494. COLORGRADING3D: boolean;
  38495. SAMPLER3DGREENDEPTH: boolean;
  38496. SAMPLER3DBGRMAP: boolean;
  38497. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38498. /**
  38499. * If the reflection texture on this material is in linear color space
  38500. * @hidden
  38501. */
  38502. IS_REFLECTION_LINEAR: boolean;
  38503. /**
  38504. * If the refraction texture on this material is in linear color space
  38505. * @hidden
  38506. */
  38507. IS_REFRACTION_LINEAR: boolean;
  38508. EXPOSURE: boolean;
  38509. constructor();
  38510. setReflectionMode(modeToEnable: string): void;
  38511. }
  38512. /**
  38513. * This is the default material used in Babylon. It is the best trade off between quality
  38514. * and performances.
  38515. * @see http://doc.babylonjs.com/babylon101/materials
  38516. */
  38517. export class StandardMaterial extends PushMaterial {
  38518. private _diffuseTexture;
  38519. /**
  38520. * The basic texture of the material as viewed under a light.
  38521. */
  38522. diffuseTexture: Nullable<BaseTexture>;
  38523. private _ambientTexture;
  38524. /**
  38525. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38526. */
  38527. ambientTexture: Nullable<BaseTexture>;
  38528. private _opacityTexture;
  38529. /**
  38530. * Define the transparency of the material from a texture.
  38531. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38532. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38533. */
  38534. opacityTexture: Nullable<BaseTexture>;
  38535. private _reflectionTexture;
  38536. /**
  38537. * Define the texture used to display the reflection.
  38538. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38539. */
  38540. reflectionTexture: Nullable<BaseTexture>;
  38541. private _emissiveTexture;
  38542. /**
  38543. * Define texture of the material as if self lit.
  38544. * This will be mixed in the final result even in the absence of light.
  38545. */
  38546. emissiveTexture: Nullable<BaseTexture>;
  38547. private _specularTexture;
  38548. /**
  38549. * Define how the color and intensity of the highlight given by the light in the material.
  38550. */
  38551. specularTexture: Nullable<BaseTexture>;
  38552. private _bumpTexture;
  38553. /**
  38554. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38555. * 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.
  38556. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38557. */
  38558. bumpTexture: Nullable<BaseTexture>;
  38559. private _lightmapTexture;
  38560. /**
  38561. * Complex lighting can be computationally expensive to compute at runtime.
  38562. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38563. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38564. */
  38565. lightmapTexture: Nullable<BaseTexture>;
  38566. private _refractionTexture;
  38567. /**
  38568. * Define the texture used to display the refraction.
  38569. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38570. */
  38571. refractionTexture: Nullable<BaseTexture>;
  38572. /**
  38573. * The color of the material lit by the environmental background lighting.
  38574. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38575. */
  38576. ambientColor: Color3;
  38577. /**
  38578. * The basic color of the material as viewed under a light.
  38579. */
  38580. diffuseColor: Color3;
  38581. /**
  38582. * Define how the color and intensity of the highlight given by the light in the material.
  38583. */
  38584. specularColor: Color3;
  38585. /**
  38586. * Define the color of the material as if self lit.
  38587. * This will be mixed in the final result even in the absence of light.
  38588. */
  38589. emissiveColor: Color3;
  38590. /**
  38591. * Defines how sharp are the highlights in the material.
  38592. * The bigger the value the sharper giving a more glossy feeling to the result.
  38593. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38594. */
  38595. specularPower: number;
  38596. private _useAlphaFromDiffuseTexture;
  38597. /**
  38598. * Does the transparency come from the diffuse texture alpha channel.
  38599. */
  38600. useAlphaFromDiffuseTexture: boolean;
  38601. private _useEmissiveAsIllumination;
  38602. /**
  38603. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38604. */
  38605. useEmissiveAsIllumination: boolean;
  38606. private _linkEmissiveWithDiffuse;
  38607. /**
  38608. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38609. * the emissive level when the final color is close to one.
  38610. */
  38611. linkEmissiveWithDiffuse: boolean;
  38612. private _useSpecularOverAlpha;
  38613. /**
  38614. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38615. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38616. */
  38617. useSpecularOverAlpha: boolean;
  38618. private _useReflectionOverAlpha;
  38619. /**
  38620. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38621. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38622. */
  38623. useReflectionOverAlpha: boolean;
  38624. private _disableLighting;
  38625. /**
  38626. * Does lights from the scene impacts this material.
  38627. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38628. */
  38629. disableLighting: boolean;
  38630. private _useObjectSpaceNormalMap;
  38631. /**
  38632. * Allows using an object space normal map (instead of tangent space).
  38633. */
  38634. useObjectSpaceNormalMap: boolean;
  38635. private _useParallax;
  38636. /**
  38637. * Is parallax enabled or not.
  38638. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38639. */
  38640. useParallax: boolean;
  38641. private _useParallaxOcclusion;
  38642. /**
  38643. * Is parallax occlusion enabled or not.
  38644. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38645. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38646. */
  38647. useParallaxOcclusion: boolean;
  38648. /**
  38649. * 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.
  38650. */
  38651. parallaxScaleBias: number;
  38652. private _roughness;
  38653. /**
  38654. * Helps to define how blurry the reflections should appears in the material.
  38655. */
  38656. roughness: number;
  38657. /**
  38658. * In case of refraction, define the value of the indice of refraction.
  38659. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38660. */
  38661. indexOfRefraction: number;
  38662. /**
  38663. * Invert the refraction texture alongside the y axis.
  38664. * It can be useful with procedural textures or probe for instance.
  38665. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38666. */
  38667. invertRefractionY: boolean;
  38668. /**
  38669. * Defines the alpha limits in alpha test mode.
  38670. */
  38671. alphaCutOff: number;
  38672. private _useLightmapAsShadowmap;
  38673. /**
  38674. * In case of light mapping, define whether the map contains light or shadow informations.
  38675. */
  38676. useLightmapAsShadowmap: boolean;
  38677. private _diffuseFresnelParameters;
  38678. /**
  38679. * Define the diffuse fresnel parameters of the material.
  38680. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38681. */
  38682. diffuseFresnelParameters: FresnelParameters;
  38683. private _opacityFresnelParameters;
  38684. /**
  38685. * Define the opacity fresnel parameters of the material.
  38686. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38687. */
  38688. opacityFresnelParameters: FresnelParameters;
  38689. private _reflectionFresnelParameters;
  38690. /**
  38691. * Define the reflection fresnel parameters of the material.
  38692. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38693. */
  38694. reflectionFresnelParameters: FresnelParameters;
  38695. private _refractionFresnelParameters;
  38696. /**
  38697. * Define the refraction fresnel parameters of the material.
  38698. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38699. */
  38700. refractionFresnelParameters: FresnelParameters;
  38701. private _emissiveFresnelParameters;
  38702. /**
  38703. * Define the emissive fresnel parameters of the material.
  38704. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38705. */
  38706. emissiveFresnelParameters: FresnelParameters;
  38707. private _useReflectionFresnelFromSpecular;
  38708. /**
  38709. * If true automatically deducts the fresnels values from the material specularity.
  38710. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38711. */
  38712. useReflectionFresnelFromSpecular: boolean;
  38713. private _useGlossinessFromSpecularMapAlpha;
  38714. /**
  38715. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38716. */
  38717. useGlossinessFromSpecularMapAlpha: boolean;
  38718. private _maxSimultaneousLights;
  38719. /**
  38720. * Defines the maximum number of lights that can be used in the material
  38721. */
  38722. maxSimultaneousLights: number;
  38723. private _invertNormalMapX;
  38724. /**
  38725. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38726. */
  38727. invertNormalMapX: boolean;
  38728. private _invertNormalMapY;
  38729. /**
  38730. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38731. */
  38732. invertNormalMapY: boolean;
  38733. private _twoSidedLighting;
  38734. /**
  38735. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38736. */
  38737. twoSidedLighting: boolean;
  38738. /**
  38739. * Default configuration related to image processing available in the standard Material.
  38740. */
  38741. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38742. /**
  38743. * Gets the image processing configuration used either in this material.
  38744. */
  38745. /**
  38746. * Sets the Default image processing configuration used either in the this material.
  38747. *
  38748. * If sets to null, the scene one is in use.
  38749. */
  38750. imageProcessingConfiguration: ImageProcessingConfiguration;
  38751. /**
  38752. * Keep track of the image processing observer to allow dispose and replace.
  38753. */
  38754. private _imageProcessingObserver;
  38755. /**
  38756. * Attaches a new image processing configuration to the Standard Material.
  38757. * @param configuration
  38758. */
  38759. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38760. /**
  38761. * Gets wether the color curves effect is enabled.
  38762. */
  38763. /**
  38764. * Sets wether the color curves effect is enabled.
  38765. */
  38766. cameraColorCurvesEnabled: boolean;
  38767. /**
  38768. * Gets wether the color grading effect is enabled.
  38769. */
  38770. /**
  38771. * Gets wether the color grading effect is enabled.
  38772. */
  38773. cameraColorGradingEnabled: boolean;
  38774. /**
  38775. * Gets wether tonemapping is enabled or not.
  38776. */
  38777. /**
  38778. * Sets wether tonemapping is enabled or not
  38779. */
  38780. cameraToneMappingEnabled: boolean;
  38781. /**
  38782. * The camera exposure used on this material.
  38783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38784. * This corresponds to a photographic exposure.
  38785. */
  38786. /**
  38787. * The camera exposure used on this material.
  38788. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38789. * This corresponds to a photographic exposure.
  38790. */
  38791. cameraExposure: number;
  38792. /**
  38793. * Gets The camera contrast used on this material.
  38794. */
  38795. /**
  38796. * Sets The camera contrast used on this material.
  38797. */
  38798. cameraContrast: number;
  38799. /**
  38800. * Gets the Color Grading 2D Lookup Texture.
  38801. */
  38802. /**
  38803. * Sets the Color Grading 2D Lookup Texture.
  38804. */
  38805. cameraColorGradingTexture: Nullable<BaseTexture>;
  38806. /**
  38807. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38808. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38809. * 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;
  38810. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38811. */
  38812. /**
  38813. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38814. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38815. * 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;
  38816. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38817. */
  38818. cameraColorCurves: Nullable<ColorCurves>;
  38819. /**
  38820. * Custom callback helping to override the default shader used in the material.
  38821. */
  38822. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38823. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38824. protected _worldViewProjectionMatrix: Matrix;
  38825. protected _globalAmbientColor: Color3;
  38826. protected _useLogarithmicDepth: boolean;
  38827. /**
  38828. * Instantiates a new standard material.
  38829. * This is the default material used in Babylon. It is the best trade off between quality
  38830. * and performances.
  38831. * @see http://doc.babylonjs.com/babylon101/materials
  38832. * @param name Define the name of the material in the scene
  38833. * @param scene Define the scene the material belong to
  38834. */
  38835. constructor(name: string, scene: Scene);
  38836. /**
  38837. * Gets a boolean indicating that current material needs to register RTT
  38838. */
  38839. readonly hasRenderTargetTextures: boolean;
  38840. /**
  38841. * Gets the current class name of the material e.g. "StandardMaterial"
  38842. * Mainly use in serialization.
  38843. * @returns the class name
  38844. */
  38845. getClassName(): string;
  38846. /**
  38847. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38848. * You can try switching to logarithmic depth.
  38849. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38850. */
  38851. useLogarithmicDepth: boolean;
  38852. /**
  38853. * Specifies if the material will require alpha blending
  38854. * @returns a boolean specifying if alpha blending is needed
  38855. */
  38856. needAlphaBlending(): boolean;
  38857. /**
  38858. * Specifies if this material should be rendered in alpha test mode
  38859. * @returns a boolean specifying if an alpha test is needed.
  38860. */
  38861. needAlphaTesting(): boolean;
  38862. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38863. /**
  38864. * Get the texture used for alpha test purpose.
  38865. * @returns the diffuse texture in case of the standard material.
  38866. */
  38867. getAlphaTestTexture(): Nullable<BaseTexture>;
  38868. /**
  38869. * Get if the submesh is ready to be used and all its information available.
  38870. * Child classes can use it to update shaders
  38871. * @param mesh defines the mesh to check
  38872. * @param subMesh defines which submesh to check
  38873. * @param useInstances specifies that instances should be used
  38874. * @returns a boolean indicating that the submesh is ready or not
  38875. */
  38876. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38877. /**
  38878. * Builds the material UBO layouts.
  38879. * Used internally during the effect preparation.
  38880. */
  38881. buildUniformLayout(): void;
  38882. /**
  38883. * Unbinds the material from the mesh
  38884. */
  38885. unbind(): void;
  38886. /**
  38887. * Binds the submesh to this material by preparing the effect and shader to draw
  38888. * @param world defines the world transformation matrix
  38889. * @param mesh defines the mesh containing the submesh
  38890. * @param subMesh defines the submesh to bind the material to
  38891. */
  38892. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38893. /**
  38894. * Get the list of animatables in the material.
  38895. * @returns the list of animatables object used in the material
  38896. */
  38897. getAnimatables(): IAnimatable[];
  38898. /**
  38899. * Gets the active textures from the material
  38900. * @returns an array of textures
  38901. */
  38902. getActiveTextures(): BaseTexture[];
  38903. /**
  38904. * Specifies if the material uses a texture
  38905. * @param texture defines the texture to check against the material
  38906. * @returns a boolean specifying if the material uses the texture
  38907. */
  38908. hasTexture(texture: BaseTexture): boolean;
  38909. /**
  38910. * Disposes the material
  38911. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38912. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38913. */
  38914. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38915. /**
  38916. * Makes a duplicate of the material, and gives it a new name
  38917. * @param name defines the new name for the duplicated material
  38918. * @returns the cloned material
  38919. */
  38920. clone(name: string): StandardMaterial;
  38921. /**
  38922. * Serializes this material in a JSON representation
  38923. * @returns the serialized material object
  38924. */
  38925. serialize(): any;
  38926. /**
  38927. * Creates a standard material from parsed material data
  38928. * @param source defines the JSON representation of the material
  38929. * @param scene defines the hosting scene
  38930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38931. * @returns a new standard material
  38932. */
  38933. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38934. /**
  38935. * Are diffuse textures enabled in the application.
  38936. */
  38937. static DiffuseTextureEnabled: boolean;
  38938. /**
  38939. * Are ambient textures enabled in the application.
  38940. */
  38941. static AmbientTextureEnabled: boolean;
  38942. /**
  38943. * Are opacity textures enabled in the application.
  38944. */
  38945. static OpacityTextureEnabled: boolean;
  38946. /**
  38947. * Are reflection textures enabled in the application.
  38948. */
  38949. static ReflectionTextureEnabled: boolean;
  38950. /**
  38951. * Are emissive textures enabled in the application.
  38952. */
  38953. static EmissiveTextureEnabled: boolean;
  38954. /**
  38955. * Are specular textures enabled in the application.
  38956. */
  38957. static SpecularTextureEnabled: boolean;
  38958. /**
  38959. * Are bump textures enabled in the application.
  38960. */
  38961. static BumpTextureEnabled: boolean;
  38962. /**
  38963. * Are lightmap textures enabled in the application.
  38964. */
  38965. static LightmapTextureEnabled: boolean;
  38966. /**
  38967. * Are refraction textures enabled in the application.
  38968. */
  38969. static RefractionTextureEnabled: boolean;
  38970. /**
  38971. * Are color grading textures enabled in the application.
  38972. */
  38973. static ColorGradingTextureEnabled: boolean;
  38974. /**
  38975. * Are fresnels enabled in the application.
  38976. */
  38977. static FresnelEnabled: boolean;
  38978. }
  38979. }
  38980. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  38981. import { Scene } from "babylonjs/scene";
  38982. import { Texture } from "babylonjs/Materials/Textures/texture";
  38983. /**
  38984. * A class extending Texture allowing drawing on a texture
  38985. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38986. */
  38987. export class DynamicTexture extends Texture {
  38988. private _generateMipMaps;
  38989. private _canvas;
  38990. private _context;
  38991. private _engine;
  38992. /**
  38993. * Creates a DynamicTexture
  38994. * @param name defines the name of the texture
  38995. * @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
  38996. * @param scene defines the scene where you want the texture
  38997. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38998. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38999. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39000. */
  39001. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39002. /**
  39003. * Get the current class name of the texture useful for serialization or dynamic coding.
  39004. * @returns "DynamicTexture"
  39005. */
  39006. getClassName(): string;
  39007. /**
  39008. * Gets the current state of canRescale
  39009. */
  39010. readonly canRescale: boolean;
  39011. private _recreate;
  39012. /**
  39013. * Scales the texture
  39014. * @param ratio the scale factor to apply to both width and height
  39015. */
  39016. scale(ratio: number): void;
  39017. /**
  39018. * Resizes the texture
  39019. * @param width the new width
  39020. * @param height the new height
  39021. */
  39022. scaleTo(width: number, height: number): void;
  39023. /**
  39024. * Gets the context of the canvas used by the texture
  39025. * @returns the canvas context of the dynamic texture
  39026. */
  39027. getContext(): CanvasRenderingContext2D;
  39028. /**
  39029. * Clears the texture
  39030. */
  39031. clear(): void;
  39032. /**
  39033. * Updates the texture
  39034. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39035. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39036. */
  39037. update(invertY?: boolean, premulAlpha?: boolean): void;
  39038. /**
  39039. * Draws text onto the texture
  39040. * @param text defines the text to be drawn
  39041. * @param x defines the placement of the text from the left
  39042. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39043. * @param font defines the font to be used with font-style, font-size, font-name
  39044. * @param color defines the color used for the text
  39045. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39046. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39047. * @param update defines whether texture is immediately update (default is true)
  39048. */
  39049. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39050. /**
  39051. * Clones the texture
  39052. * @returns the clone of the texture.
  39053. */
  39054. clone(): DynamicTexture;
  39055. /**
  39056. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39057. * @returns a serialized dynamic texture object
  39058. */
  39059. serialize(): any;
  39060. /** @hidden */
  39061. _rebuild(): void;
  39062. }
  39063. }
  39064. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39065. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39066. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39067. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39068. /** @hidden */
  39069. export var imageProcessingPixelShader: {
  39070. name: string;
  39071. shader: string;
  39072. };
  39073. }
  39074. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39075. import { Nullable } from "babylonjs/types";
  39076. import { Color4 } from "babylonjs/Maths/math";
  39077. import { Camera } from "babylonjs/Cameras/camera";
  39078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39079. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39080. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39081. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39082. import { Engine } from "babylonjs/Engines/engine";
  39083. import "babylonjs/Shaders/imageProcessing.fragment";
  39084. import "babylonjs/Shaders/postprocess.vertex";
  39085. /**
  39086. * ImageProcessingPostProcess
  39087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39088. */
  39089. export class ImageProcessingPostProcess extends PostProcess {
  39090. /**
  39091. * Default configuration related to image processing available in the PBR Material.
  39092. */
  39093. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39094. /**
  39095. * Gets the image processing configuration used either in this material.
  39096. */
  39097. /**
  39098. * Sets the Default image processing configuration used either in the this material.
  39099. *
  39100. * If sets to null, the scene one is in use.
  39101. */
  39102. imageProcessingConfiguration: ImageProcessingConfiguration;
  39103. /**
  39104. * Keep track of the image processing observer to allow dispose and replace.
  39105. */
  39106. private _imageProcessingObserver;
  39107. /**
  39108. * Attaches a new image processing configuration to the PBR Material.
  39109. * @param configuration
  39110. */
  39111. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39112. /**
  39113. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39114. */
  39115. /**
  39116. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39117. */
  39118. colorCurves: Nullable<ColorCurves>;
  39119. /**
  39120. * Gets wether the color curves effect is enabled.
  39121. */
  39122. /**
  39123. * Sets wether the color curves effect is enabled.
  39124. */
  39125. colorCurvesEnabled: boolean;
  39126. /**
  39127. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39128. */
  39129. /**
  39130. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39131. */
  39132. colorGradingTexture: Nullable<BaseTexture>;
  39133. /**
  39134. * Gets wether the color grading effect is enabled.
  39135. */
  39136. /**
  39137. * Gets wether the color grading effect is enabled.
  39138. */
  39139. colorGradingEnabled: boolean;
  39140. /**
  39141. * Gets exposure used in the effect.
  39142. */
  39143. /**
  39144. * Sets exposure used in the effect.
  39145. */
  39146. exposure: number;
  39147. /**
  39148. * Gets wether tonemapping is enabled or not.
  39149. */
  39150. /**
  39151. * Sets wether tonemapping is enabled or not
  39152. */
  39153. toneMappingEnabled: boolean;
  39154. /**
  39155. * Gets contrast used in the effect.
  39156. */
  39157. /**
  39158. * Sets contrast used in the effect.
  39159. */
  39160. contrast: number;
  39161. /**
  39162. * Gets Vignette stretch size.
  39163. */
  39164. /**
  39165. * Sets Vignette stretch size.
  39166. */
  39167. vignetteStretch: number;
  39168. /**
  39169. * Gets Vignette centre X Offset.
  39170. */
  39171. /**
  39172. * Sets Vignette centre X Offset.
  39173. */
  39174. vignetteCentreX: number;
  39175. /**
  39176. * Gets Vignette centre Y Offset.
  39177. */
  39178. /**
  39179. * Sets Vignette centre Y Offset.
  39180. */
  39181. vignetteCentreY: number;
  39182. /**
  39183. * Gets Vignette weight or intensity of the vignette effect.
  39184. */
  39185. /**
  39186. * Sets Vignette weight or intensity of the vignette effect.
  39187. */
  39188. vignetteWeight: number;
  39189. /**
  39190. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39191. * if vignetteEnabled is set to true.
  39192. */
  39193. /**
  39194. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39195. * if vignetteEnabled is set to true.
  39196. */
  39197. vignetteColor: Color4;
  39198. /**
  39199. * Gets Camera field of view used by the Vignette effect.
  39200. */
  39201. /**
  39202. * Sets Camera field of view used by the Vignette effect.
  39203. */
  39204. vignetteCameraFov: number;
  39205. /**
  39206. * Gets the vignette blend mode allowing different kind of effect.
  39207. */
  39208. /**
  39209. * Sets the vignette blend mode allowing different kind of effect.
  39210. */
  39211. vignetteBlendMode: number;
  39212. /**
  39213. * Gets wether the vignette effect is enabled.
  39214. */
  39215. /**
  39216. * Sets wether the vignette effect is enabled.
  39217. */
  39218. vignetteEnabled: boolean;
  39219. private _fromLinearSpace;
  39220. /**
  39221. * Gets wether the input of the processing is in Gamma or Linear Space.
  39222. */
  39223. /**
  39224. * Sets wether the input of the processing is in Gamma or Linear Space.
  39225. */
  39226. fromLinearSpace: boolean;
  39227. /**
  39228. * Defines cache preventing GC.
  39229. */
  39230. private _defines;
  39231. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39232. /**
  39233. * "ImageProcessingPostProcess"
  39234. * @returns "ImageProcessingPostProcess"
  39235. */
  39236. getClassName(): string;
  39237. protected _updateParameters(): void;
  39238. dispose(camera?: Camera): void;
  39239. }
  39240. }
  39241. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39242. import { Scene } from "babylonjs/scene";
  39243. import { Color3 } from "babylonjs/Maths/math";
  39244. import { Mesh } from "babylonjs/Meshes/mesh";
  39245. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39246. /**
  39247. * Class containing static functions to help procedurally build meshes
  39248. */
  39249. export class GroundBuilder {
  39250. /**
  39251. * Creates a ground mesh
  39252. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39253. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39255. * @param name defines the name of the mesh
  39256. * @param options defines the options used to create the mesh
  39257. * @param scene defines the hosting scene
  39258. * @returns the ground mesh
  39259. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39260. */
  39261. static CreateGround(name: string, options: {
  39262. width?: number;
  39263. height?: number;
  39264. subdivisions?: number;
  39265. subdivisionsX?: number;
  39266. subdivisionsY?: number;
  39267. updatable?: boolean;
  39268. }, scene: any): Mesh;
  39269. /**
  39270. * Creates a tiled ground mesh
  39271. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39272. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39273. * * 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
  39274. * * 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
  39275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39276. * @param name defines the name of the mesh
  39277. * @param options defines the options used to create the mesh
  39278. * @param scene defines the hosting scene
  39279. * @returns the tiled ground mesh
  39280. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39281. */
  39282. static CreateTiledGround(name: string, options: {
  39283. xmin: number;
  39284. zmin: number;
  39285. xmax: number;
  39286. zmax: number;
  39287. subdivisions?: {
  39288. w: number;
  39289. h: number;
  39290. };
  39291. precision?: {
  39292. w: number;
  39293. h: number;
  39294. };
  39295. updatable?: boolean;
  39296. }, scene: Scene): Mesh;
  39297. /**
  39298. * Creates a ground mesh from a height map
  39299. * * The parameter `url` sets the URL of the height map image resource.
  39300. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39301. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39302. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39303. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39304. * * 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.
  39305. * * 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).
  39306. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39308. * @param name defines the name of the mesh
  39309. * @param url defines the url to the height map
  39310. * @param options defines the options used to create the mesh
  39311. * @param scene defines the hosting scene
  39312. * @returns the ground mesh
  39313. * @see https://doc.babylonjs.com/babylon101/height_map
  39314. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39315. */
  39316. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39317. width?: number;
  39318. height?: number;
  39319. subdivisions?: number;
  39320. minHeight?: number;
  39321. maxHeight?: number;
  39322. colorFilter?: Color3;
  39323. alphaFilter?: number;
  39324. updatable?: boolean;
  39325. onReady?: (mesh: GroundMesh) => void;
  39326. }, scene: Scene): GroundMesh;
  39327. }
  39328. }
  39329. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39330. import { Vector4 } from "babylonjs/Maths/math";
  39331. import { Mesh } from "babylonjs/Meshes/mesh";
  39332. /**
  39333. * Class containing static functions to help procedurally build meshes
  39334. */
  39335. export class TorusBuilder {
  39336. /**
  39337. * Creates a torus mesh
  39338. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39339. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39340. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39344. * @param name defines the name of the mesh
  39345. * @param options defines the options used to create the mesh
  39346. * @param scene defines the hosting scene
  39347. * @returns the torus mesh
  39348. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39349. */
  39350. static CreateTorus(name: string, options: {
  39351. diameter?: number;
  39352. thickness?: number;
  39353. tessellation?: number;
  39354. updatable?: boolean;
  39355. sideOrientation?: number;
  39356. frontUVs?: Vector4;
  39357. backUVs?: Vector4;
  39358. }, scene: any): Mesh;
  39359. }
  39360. }
  39361. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39362. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39363. import { Mesh } from "babylonjs/Meshes/mesh";
  39364. /**
  39365. * Class containing static functions to help procedurally build meshes
  39366. */
  39367. export class CylinderBuilder {
  39368. /**
  39369. * Creates a cylinder or a cone mesh
  39370. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39371. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39372. * * 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.
  39373. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39374. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39375. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39376. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39377. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39378. * * 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).
  39379. * * 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
  39380. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39381. * * 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
  39382. * * 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.
  39383. * * If `enclose` is false, a ring surface is one element.
  39384. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39385. * * 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
  39386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39389. * @param name defines the name of the mesh
  39390. * @param options defines the options used to create the mesh
  39391. * @param scene defines the hosting scene
  39392. * @returns the cylinder mesh
  39393. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39394. */
  39395. static CreateCylinder(name: string, options: {
  39396. height?: number;
  39397. diameterTop?: number;
  39398. diameterBottom?: number;
  39399. diameter?: number;
  39400. tessellation?: number;
  39401. subdivisions?: number;
  39402. arc?: number;
  39403. faceColors?: Color4[];
  39404. faceUV?: Vector4[];
  39405. updatable?: boolean;
  39406. hasRings?: boolean;
  39407. enclose?: boolean;
  39408. sideOrientation?: number;
  39409. frontUVs?: Vector4;
  39410. backUVs?: Vector4;
  39411. }, scene: any): Mesh;
  39412. }
  39413. }
  39414. declare module "babylonjs/Gamepads/gamepadManager" {
  39415. import { Observable } from "babylonjs/Misc/observable";
  39416. import { Nullable } from "babylonjs/types";
  39417. import { Scene } from "babylonjs/scene";
  39418. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39419. /**
  39420. * Manager for handling gamepads
  39421. */
  39422. export class GamepadManager {
  39423. private _scene?;
  39424. private _babylonGamepads;
  39425. private _oneGamepadConnected;
  39426. /** @hidden */
  39427. _isMonitoring: boolean;
  39428. private _gamepadEventSupported;
  39429. private _gamepadSupport;
  39430. /**
  39431. * observable to be triggered when the gamepad controller has been connected
  39432. */
  39433. onGamepadConnectedObservable: Observable<Gamepad>;
  39434. /**
  39435. * observable to be triggered when the gamepad controller has been disconnected
  39436. */
  39437. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39438. private _onGamepadConnectedEvent;
  39439. private _onGamepadDisconnectedEvent;
  39440. /**
  39441. * Initializes the gamepad manager
  39442. * @param _scene BabylonJS scene
  39443. */
  39444. constructor(_scene?: Scene | undefined);
  39445. /**
  39446. * The gamepads in the game pad manager
  39447. */
  39448. readonly gamepads: Gamepad[];
  39449. /**
  39450. * Get the gamepad controllers based on type
  39451. * @param type The type of gamepad controller
  39452. * @returns Nullable gamepad
  39453. */
  39454. getGamepadByType(type?: number): Nullable<Gamepad>;
  39455. /**
  39456. * Disposes the gamepad manager
  39457. */
  39458. dispose(): void;
  39459. private _addNewGamepad;
  39460. private _startMonitoringGamepads;
  39461. private _stopMonitoringGamepads;
  39462. /** @hidden */
  39463. _checkGamepadsStatus(): void;
  39464. private _updateGamepadObjects;
  39465. }
  39466. }
  39467. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39468. import { Nullable } from "babylonjs/types";
  39469. import { Scene } from "babylonjs/scene";
  39470. import { ISceneComponent } from "babylonjs/sceneComponent";
  39471. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39472. module "babylonjs/scene" {
  39473. interface Scene {
  39474. /** @hidden */
  39475. _gamepadManager: Nullable<GamepadManager>;
  39476. /**
  39477. * Gets the gamepad manager associated with the scene
  39478. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39479. */
  39480. gamepadManager: GamepadManager;
  39481. }
  39482. }
  39483. module "babylonjs/Cameras/freeCameraInputsManager" {
  39484. /**
  39485. * Interface representing a free camera inputs manager
  39486. */
  39487. interface FreeCameraInputsManager {
  39488. /**
  39489. * Adds gamepad input support to the FreeCameraInputsManager.
  39490. * @returns the FreeCameraInputsManager
  39491. */
  39492. addGamepad(): FreeCameraInputsManager;
  39493. }
  39494. }
  39495. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39496. /**
  39497. * Interface representing an arc rotate camera inputs manager
  39498. */
  39499. interface ArcRotateCameraInputsManager {
  39500. /**
  39501. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39502. * @returns the camera inputs manager
  39503. */
  39504. addGamepad(): ArcRotateCameraInputsManager;
  39505. }
  39506. }
  39507. /**
  39508. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39509. */
  39510. export class GamepadSystemSceneComponent implements ISceneComponent {
  39511. /**
  39512. * The component name helpfull to identify the component in the list of scene components.
  39513. */
  39514. readonly name: string;
  39515. /**
  39516. * The scene the component belongs to.
  39517. */
  39518. scene: Scene;
  39519. /**
  39520. * Creates a new instance of the component for the given scene
  39521. * @param scene Defines the scene to register the component in
  39522. */
  39523. constructor(scene: Scene);
  39524. /**
  39525. * Registers the component in a given scene
  39526. */
  39527. register(): void;
  39528. /**
  39529. * Rebuilds the elements related to this component in case of
  39530. * context lost for instance.
  39531. */
  39532. rebuild(): void;
  39533. /**
  39534. * Disposes the component and the associated ressources
  39535. */
  39536. dispose(): void;
  39537. private _beforeCameraUpdate;
  39538. }
  39539. }
  39540. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39541. import { Observable } from "babylonjs/Misc/observable";
  39542. import { Nullable } from "babylonjs/types";
  39543. import { Camera } from "babylonjs/Cameras/camera";
  39544. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39545. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39546. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39547. import { Scene } from "babylonjs/scene";
  39548. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39549. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39551. import { Mesh } from "babylonjs/Meshes/mesh";
  39552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39553. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39554. import "babylonjs/Meshes/Builders/groundBuilder";
  39555. import "babylonjs/Meshes/Builders/torusBuilder";
  39556. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39557. import "babylonjs/Gamepads/gamepadSceneComponent";
  39558. import "babylonjs/Animations/animatable";
  39559. /**
  39560. * Options to modify the vr teleportation behavior.
  39561. */
  39562. export interface VRTeleportationOptions {
  39563. /**
  39564. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39565. */
  39566. floorMeshName?: string;
  39567. /**
  39568. * A list of meshes to be used as the teleportation floor. (default: empty)
  39569. */
  39570. floorMeshes?: Mesh[];
  39571. }
  39572. /**
  39573. * Options to modify the vr experience helper's behavior.
  39574. */
  39575. export interface VRExperienceHelperOptions extends WebVROptions {
  39576. /**
  39577. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39578. */
  39579. createDeviceOrientationCamera?: boolean;
  39580. /**
  39581. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39582. */
  39583. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39584. /**
  39585. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39586. */
  39587. laserToggle?: boolean;
  39588. /**
  39589. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39590. */
  39591. floorMeshes?: Mesh[];
  39592. /**
  39593. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39594. */
  39595. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39596. }
  39597. /**
  39598. * Helps to quickly add VR support to an existing scene.
  39599. * See http://doc.babylonjs.com/how_to/webvr_helper
  39600. */
  39601. export class VRExperienceHelper {
  39602. /** Options to modify the vr experience helper's behavior. */
  39603. webVROptions: VRExperienceHelperOptions;
  39604. private _scene;
  39605. private _position;
  39606. private _btnVR;
  39607. private _btnVRDisplayed;
  39608. private _webVRsupported;
  39609. private _webVRready;
  39610. private _webVRrequesting;
  39611. private _webVRpresenting;
  39612. private _hasEnteredVR;
  39613. private _fullscreenVRpresenting;
  39614. private _canvas;
  39615. private _webVRCamera;
  39616. private _vrDeviceOrientationCamera;
  39617. private _deviceOrientationCamera;
  39618. private _existingCamera;
  39619. private _onKeyDown;
  39620. private _onVrDisplayPresentChange;
  39621. private _onVRDisplayChanged;
  39622. private _onVRRequestPresentStart;
  39623. private _onVRRequestPresentComplete;
  39624. /**
  39625. * Observable raised when entering VR.
  39626. */
  39627. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39628. /**
  39629. * Observable raised when exiting VR.
  39630. */
  39631. onExitingVRObservable: Observable<VRExperienceHelper>;
  39632. /**
  39633. * Observable raised when controller mesh is loaded.
  39634. */
  39635. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39636. /** Return this.onEnteringVRObservable
  39637. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39638. */
  39639. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39640. /** Return this.onExitingVRObservable
  39641. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39642. */
  39643. readonly onExitingVR: Observable<VRExperienceHelper>;
  39644. /** Return this.onControllerMeshLoadedObservable
  39645. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39646. */
  39647. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39648. private _rayLength;
  39649. private _useCustomVRButton;
  39650. private _teleportationRequested;
  39651. private _teleportActive;
  39652. private _floorMeshName;
  39653. private _floorMeshesCollection;
  39654. private _rotationAllowed;
  39655. private _teleportBackwardsVector;
  39656. private _teleportationTarget;
  39657. private _isDefaultTeleportationTarget;
  39658. private _postProcessMove;
  39659. private _teleportationFillColor;
  39660. private _teleportationBorderColor;
  39661. private _rotationAngle;
  39662. private _haloCenter;
  39663. private _cameraGazer;
  39664. private _padSensibilityUp;
  39665. private _padSensibilityDown;
  39666. private _leftController;
  39667. private _rightController;
  39668. /**
  39669. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39670. */
  39671. onNewMeshSelected: Observable<AbstractMesh>;
  39672. /**
  39673. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39674. */
  39675. onNewMeshPicked: Observable<PickingInfo>;
  39676. private _circleEase;
  39677. /**
  39678. * Observable raised before camera teleportation
  39679. */
  39680. onBeforeCameraTeleport: Observable<Vector3>;
  39681. /**
  39682. * Observable raised after camera teleportation
  39683. */
  39684. onAfterCameraTeleport: Observable<Vector3>;
  39685. /**
  39686. * Observable raised when current selected mesh gets unselected
  39687. */
  39688. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39689. private _raySelectionPredicate;
  39690. /**
  39691. * To be optionaly changed by user to define custom ray selection
  39692. */
  39693. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39694. /**
  39695. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39696. */
  39697. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39698. /**
  39699. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39700. */
  39701. teleportationEnabled: boolean;
  39702. private _defaultHeight;
  39703. private _teleportationInitialized;
  39704. private _interactionsEnabled;
  39705. private _interactionsRequested;
  39706. private _displayGaze;
  39707. private _displayLaserPointer;
  39708. /**
  39709. * The mesh used to display where the user is going to teleport.
  39710. */
  39711. /**
  39712. * Sets the mesh to be used to display where the user is going to teleport.
  39713. */
  39714. teleportationTarget: Mesh;
  39715. /**
  39716. * 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
  39717. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39718. * See http://doc.babylonjs.com/resources/baking_transformations
  39719. */
  39720. gazeTrackerMesh: Mesh;
  39721. /**
  39722. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39723. */
  39724. updateGazeTrackerScale: boolean;
  39725. /**
  39726. * If the gaze trackers color should be updated when selecting meshes
  39727. */
  39728. updateGazeTrackerColor: boolean;
  39729. /**
  39730. * The gaze tracking mesh corresponding to the left controller
  39731. */
  39732. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39733. /**
  39734. * The gaze tracking mesh corresponding to the right controller
  39735. */
  39736. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39737. /**
  39738. * If the ray of the gaze should be displayed.
  39739. */
  39740. /**
  39741. * Sets if the ray of the gaze should be displayed.
  39742. */
  39743. displayGaze: boolean;
  39744. /**
  39745. * If the ray of the LaserPointer should be displayed.
  39746. */
  39747. /**
  39748. * Sets if the ray of the LaserPointer should be displayed.
  39749. */
  39750. displayLaserPointer: boolean;
  39751. /**
  39752. * The deviceOrientationCamera used as the camera when not in VR.
  39753. */
  39754. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39755. /**
  39756. * Based on the current WebVR support, returns the current VR camera used.
  39757. */
  39758. readonly currentVRCamera: Nullable<Camera>;
  39759. /**
  39760. * The webVRCamera which is used when in VR.
  39761. */
  39762. readonly webVRCamera: WebVRFreeCamera;
  39763. /**
  39764. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39765. */
  39766. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39767. private readonly _teleportationRequestInitiated;
  39768. /**
  39769. * Defines wether or not Pointer lock should be requested when switching to
  39770. * full screen.
  39771. */
  39772. requestPointerLockOnFullScreen: boolean;
  39773. /**
  39774. * Instantiates a VRExperienceHelper.
  39775. * Helps to quickly add VR support to an existing scene.
  39776. * @param scene The scene the VRExperienceHelper belongs to.
  39777. * @param webVROptions Options to modify the vr experience helper's behavior.
  39778. */
  39779. constructor(scene: Scene,
  39780. /** Options to modify the vr experience helper's behavior. */
  39781. webVROptions?: VRExperienceHelperOptions);
  39782. private _onDefaultMeshLoaded;
  39783. private _onResize;
  39784. private _onFullscreenChange;
  39785. /**
  39786. * Gets a value indicating if we are currently in VR mode.
  39787. */
  39788. readonly isInVRMode: boolean;
  39789. private onVrDisplayPresentChange;
  39790. private onVRDisplayChanged;
  39791. private moveButtonToBottomRight;
  39792. private displayVRButton;
  39793. private updateButtonVisibility;
  39794. private _cachedAngularSensibility;
  39795. /**
  39796. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39797. * Otherwise, will use the fullscreen API.
  39798. */
  39799. enterVR(): void;
  39800. /**
  39801. * Attempt to exit VR, or fullscreen.
  39802. */
  39803. exitVR(): void;
  39804. /**
  39805. * The position of the vr experience helper.
  39806. */
  39807. /**
  39808. * Sets the position of the vr experience helper.
  39809. */
  39810. position: Vector3;
  39811. /**
  39812. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39813. */
  39814. enableInteractions(): void;
  39815. private readonly _noControllerIsActive;
  39816. private beforeRender;
  39817. private _isTeleportationFloor;
  39818. /**
  39819. * Adds a floor mesh to be used for teleportation.
  39820. * @param floorMesh the mesh to be used for teleportation.
  39821. */
  39822. addFloorMesh(floorMesh: Mesh): void;
  39823. /**
  39824. * Removes a floor mesh from being used for teleportation.
  39825. * @param floorMesh the mesh to be removed.
  39826. */
  39827. removeFloorMesh(floorMesh: Mesh): void;
  39828. /**
  39829. * Enables interactions and teleportation using the VR controllers and gaze.
  39830. * @param vrTeleportationOptions options to modify teleportation behavior.
  39831. */
  39832. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39833. private _onNewGamepadConnected;
  39834. private _tryEnableInteractionOnController;
  39835. private _onNewGamepadDisconnected;
  39836. private _enableInteractionOnController;
  39837. private _checkTeleportWithRay;
  39838. private _checkRotate;
  39839. private _checkTeleportBackwards;
  39840. private _enableTeleportationOnController;
  39841. private _createTeleportationCircles;
  39842. private _displayTeleportationTarget;
  39843. private _hideTeleportationTarget;
  39844. private _rotateCamera;
  39845. private _moveTeleportationSelectorTo;
  39846. private _workingVector;
  39847. private _workingQuaternion;
  39848. private _workingMatrix;
  39849. /**
  39850. * Teleports the users feet to the desired location
  39851. * @param location The location where the user's feet should be placed
  39852. */
  39853. teleportCamera(location: Vector3): void;
  39854. private _convertNormalToDirectionOfRay;
  39855. private _castRayAndSelectObject;
  39856. private _notifySelectedMeshUnselected;
  39857. /**
  39858. * Sets the color of the laser ray from the vr controllers.
  39859. * @param color new color for the ray.
  39860. */
  39861. changeLaserColor(color: Color3): void;
  39862. /**
  39863. * Sets the color of the ray from the vr headsets gaze.
  39864. * @param color new color for the ray.
  39865. */
  39866. changeGazeColor(color: Color3): void;
  39867. /**
  39868. * Exits VR and disposes of the vr experience helper
  39869. */
  39870. dispose(): void;
  39871. /**
  39872. * Gets the name of the VRExperienceHelper class
  39873. * @returns "VRExperienceHelper"
  39874. */
  39875. getClassName(): string;
  39876. }
  39877. }
  39878. declare module "babylonjs/Cameras/VR/index" {
  39879. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39880. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39881. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39882. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39883. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39884. export * from "babylonjs/Cameras/VR/webVRCamera";
  39885. }
  39886. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39887. import { Observable } from "babylonjs/Misc/observable";
  39888. import { Nullable } from "babylonjs/types";
  39889. import { IDisposable, Scene } from "babylonjs/scene";
  39890. import { Vector3 } from "babylonjs/Maths/math";
  39891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39892. import { Ray } from "babylonjs/Culling/ray";
  39893. /**
  39894. * Manages an XRSession
  39895. * @see https://doc.babylonjs.com/how_to/webxr
  39896. */
  39897. export class WebXRSessionManager implements IDisposable {
  39898. private scene;
  39899. /**
  39900. * Fires every time a new xrFrame arrives which can be used to update the camera
  39901. */
  39902. onXRFrameObservable: Observable<any>;
  39903. /**
  39904. * Fires when the xr session is ended either by the device or manually done
  39905. */
  39906. onXRSessionEnded: Observable<any>;
  39907. /** @hidden */
  39908. _xrSession: XRSession;
  39909. /** @hidden */
  39910. _frameOfReference: XRFrameOfReference;
  39911. /** @hidden */
  39912. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39913. /** @hidden */
  39914. _currentXRFrame: Nullable<XRFrame>;
  39915. private _xrNavigator;
  39916. private _xrDevice;
  39917. private _tmpMatrix;
  39918. /**
  39919. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39920. * @param scene The scene which the session should be created for
  39921. */
  39922. constructor(scene: Scene);
  39923. /**
  39924. * Initializes the manager
  39925. * After initialization enterXR can be called to start an XR session
  39926. * @returns Promise which resolves after it is initialized
  39927. */
  39928. initializeAsync(): Promise<void>;
  39929. /**
  39930. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39931. * @param sessionCreationOptions xr options to create the session with
  39932. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39933. * @returns Promise which resolves after it enters XR
  39934. */
  39935. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39936. /**
  39937. * Stops the xrSession and restores the renderloop
  39938. * @returns Promise which resolves after it exits XR
  39939. */
  39940. exitXRAsync(): Promise<void>;
  39941. /**
  39942. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39943. * @param ray ray to cast into the environment
  39944. * @returns Promise which resolves with a collision point in the environment if it exists
  39945. */
  39946. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39947. /**
  39948. * Checks if a session would be supported for the creation options specified
  39949. * @param options creation options to check if they are supported
  39950. * @returns true if supported
  39951. */
  39952. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39953. /**
  39954. * @hidden
  39955. * Converts the render layer of xrSession to a render target
  39956. * @param session session to create render target for
  39957. * @param scene scene the new render target should be created for
  39958. */
  39959. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39960. /**
  39961. * Disposes of the session manager
  39962. */
  39963. dispose(): void;
  39964. }
  39965. }
  39966. declare module "babylonjs/Cameras/XR/webXRCamera" {
  39967. import { Scene } from "babylonjs/scene";
  39968. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39969. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39970. /**
  39971. * WebXR Camera which holds the views for the xrSession
  39972. * @see https://doc.babylonjs.com/how_to/webxr
  39973. */
  39974. export class WebXRCamera extends FreeCamera {
  39975. private static _TmpMatrix;
  39976. /**
  39977. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39978. * @param name the name of the camera
  39979. * @param scene the scene to add the camera to
  39980. */
  39981. constructor(name: string, scene: Scene);
  39982. private _updateNumberOfRigCameras;
  39983. /** @hidden */
  39984. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39985. /**
  39986. * Updates the cameras position from the current pose information of the XR session
  39987. * @param xrSessionManager the session containing pose information
  39988. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39989. */
  39990. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39991. }
  39992. }
  39993. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  39994. import { Nullable } from "babylonjs/types";
  39995. import { Observable } from "babylonjs/Misc/observable";
  39996. import { IDisposable, Scene } from "babylonjs/scene";
  39997. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  39998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39999. import { Ray } from "babylonjs/Culling/ray";
  40000. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40001. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40002. /**
  40003. * States of the webXR experience
  40004. */
  40005. export enum WebXRState {
  40006. /**
  40007. * Transitioning to being in XR mode
  40008. */
  40009. ENTERING_XR = 0,
  40010. /**
  40011. * Transitioning to non XR mode
  40012. */
  40013. EXITING_XR = 1,
  40014. /**
  40015. * In XR mode and presenting
  40016. */
  40017. IN_XR = 2,
  40018. /**
  40019. * Not entered XR mode
  40020. */
  40021. NOT_IN_XR = 3
  40022. }
  40023. /**
  40024. * Helper class used to enable XR
  40025. * @see https://doc.babylonjs.com/how_to/webxr
  40026. */
  40027. export class WebXRExperienceHelper implements IDisposable {
  40028. private scene;
  40029. /**
  40030. * 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
  40031. */
  40032. container: AbstractMesh;
  40033. /**
  40034. * Camera used to render xr content
  40035. */
  40036. camera: WebXRCamera;
  40037. /**
  40038. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40039. */
  40040. state: WebXRState;
  40041. private _setState;
  40042. private static _TmpVector;
  40043. /**
  40044. * Fires when the state of the experience helper has changed
  40045. */
  40046. onStateChangedObservable: Observable<WebXRState>;
  40047. /** @hidden */
  40048. _sessionManager: WebXRSessionManager;
  40049. private _nonVRCamera;
  40050. private _originalSceneAutoClear;
  40051. private _supported;
  40052. /**
  40053. * Creates the experience helper
  40054. * @param scene the scene to attach the experience helper to
  40055. * @returns a promise for the experience helper
  40056. */
  40057. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40058. /**
  40059. * Creates a WebXRExperienceHelper
  40060. * @param scene The scene the helper should be created in
  40061. */
  40062. private constructor();
  40063. /**
  40064. * Exits XR mode and returns the scene to its original state
  40065. * @returns promise that resolves after xr mode has exited
  40066. */
  40067. exitXRAsync(): Promise<void>;
  40068. /**
  40069. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40070. * @param sessionCreationOptions options for the XR session
  40071. * @param frameOfReference frame of reference of the XR session
  40072. * @returns promise that resolves after xr mode has entered
  40073. */
  40074. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40075. /**
  40076. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40077. * @param ray ray to cast into the environment
  40078. * @returns Promise which resolves with a collision point in the environment if it exists
  40079. */
  40080. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40081. /**
  40082. * Updates the global position of the camera by moving the camera's container
  40083. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40084. * @param position The desired global position of the camera
  40085. */
  40086. setPositionOfCameraUsingContainer(position: Vector3): void;
  40087. /**
  40088. * Rotates the xr camera by rotating the camera's container around the camera's position
  40089. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40090. * @param rotation the desired quaternion rotation to apply to the camera
  40091. */
  40092. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40093. /**
  40094. * Checks if the creation options are supported by the xr session
  40095. * @param options creation options
  40096. * @returns true if supported
  40097. */
  40098. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40099. /**
  40100. * Disposes of the experience helper
  40101. */
  40102. dispose(): void;
  40103. }
  40104. }
  40105. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40106. import { Nullable } from "babylonjs/types";
  40107. import { Observable } from "babylonjs/Misc/observable";
  40108. import { IDisposable, Scene } from "babylonjs/scene";
  40109. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40110. /**
  40111. * Button which can be used to enter a different mode of XR
  40112. */
  40113. export class WebXREnterExitUIButton {
  40114. /** button element */
  40115. element: HTMLElement;
  40116. /** XR initialization options for the button */
  40117. initializationOptions: XRSessionCreationOptions;
  40118. /**
  40119. * Creates a WebXREnterExitUIButton
  40120. * @param element button element
  40121. * @param initializationOptions XR initialization options for the button
  40122. */
  40123. constructor(
  40124. /** button element */
  40125. element: HTMLElement,
  40126. /** XR initialization options for the button */
  40127. initializationOptions: XRSessionCreationOptions);
  40128. /**
  40129. * Overwritable function which can be used to update the button's visuals when the state changes
  40130. * @param activeButton the current active button in the UI
  40131. */
  40132. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40133. }
  40134. /**
  40135. * Options to create the webXR UI
  40136. */
  40137. export class WebXREnterExitUIOptions {
  40138. /**
  40139. * Context to enter xr with
  40140. */
  40141. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40142. /**
  40143. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40144. */
  40145. customButtons?: Array<WebXREnterExitUIButton>;
  40146. }
  40147. /**
  40148. * UI to allow the user to enter/exit XR mode
  40149. */
  40150. export class WebXREnterExitUI implements IDisposable {
  40151. private scene;
  40152. private _overlay;
  40153. private _buttons;
  40154. private _activeButton;
  40155. /**
  40156. * Fired every time the active button is changed.
  40157. *
  40158. * When xr is entered via a button that launches xr that button will be the callback parameter
  40159. *
  40160. * When exiting xr the callback parameter will be null)
  40161. */
  40162. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40163. /**
  40164. * Creates UI to allow the user to enter/exit XR mode
  40165. * @param scene the scene to add the ui to
  40166. * @param helper the xr experience helper to enter/exit xr with
  40167. * @param options options to configure the UI
  40168. * @returns the created ui
  40169. */
  40170. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40171. private constructor();
  40172. private _updateButtons;
  40173. /**
  40174. * Disposes of the object
  40175. */
  40176. dispose(): void;
  40177. }
  40178. }
  40179. declare module "babylonjs/Cameras/XR/webXRInput" {
  40180. import { IDisposable, Scene } from "babylonjs/scene";
  40181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40182. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40183. /**
  40184. * Represents an XR input
  40185. */
  40186. export class WebXRController {
  40187. /**
  40188. * 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
  40189. */
  40190. grip?: AbstractMesh;
  40191. /**
  40192. * Pointer which can be used to select objects or attach a visible laser to
  40193. */
  40194. pointer: AbstractMesh;
  40195. /**
  40196. * Creates the controller
  40197. * @see https://doc.babylonjs.com/how_to/webxr
  40198. * @param scene the scene which the controller should be associated to
  40199. */
  40200. constructor(scene: Scene);
  40201. /**
  40202. * Disposes of the object
  40203. */
  40204. dispose(): void;
  40205. }
  40206. /**
  40207. * XR input used to track XR inputs such as controllers/rays
  40208. */
  40209. export class WebXRInput implements IDisposable {
  40210. private helper;
  40211. /**
  40212. * XR controllers being tracked
  40213. */
  40214. controllers: Array<WebXRController>;
  40215. private _tmpMatrix;
  40216. private _frameObserver;
  40217. /**
  40218. * Initializes the WebXRInput
  40219. * @param helper experience helper which the input should be created for
  40220. */
  40221. constructor(helper: WebXRExperienceHelper);
  40222. /**
  40223. * Disposes of the object
  40224. */
  40225. dispose(): void;
  40226. }
  40227. }
  40228. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40229. import { Nullable } from "babylonjs/types";
  40230. import { IDisposable } from "babylonjs/scene";
  40231. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40232. /**
  40233. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40234. */
  40235. export class WebXRManagedOutputCanvas implements IDisposable {
  40236. private _canvas;
  40237. /**
  40238. * xrpresent context of the canvas which can be used to display/mirror xr content
  40239. */
  40240. canvasContext: Nullable<WebGLRenderingContext>;
  40241. /**
  40242. * Initializes the canvas to be added/removed upon entering/exiting xr
  40243. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40244. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40245. */
  40246. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40247. /**
  40248. * Disposes of the object
  40249. */
  40250. dispose(): void;
  40251. private _setManagedOutputCanvas;
  40252. private _addCanvas;
  40253. private _removeCanvas;
  40254. }
  40255. }
  40256. declare module "babylonjs/Cameras/XR/index" {
  40257. export * from "babylonjs/Cameras/XR/webXRCamera";
  40258. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40259. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40260. export * from "babylonjs/Cameras/XR/webXRInput";
  40261. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40262. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40263. }
  40264. declare module "babylonjs/Cameras/RigModes/index" {
  40265. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40266. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40267. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40268. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40269. }
  40270. declare module "babylonjs/Cameras/index" {
  40271. export * from "babylonjs/Cameras/Inputs/index";
  40272. export * from "babylonjs/Cameras/cameraInputsManager";
  40273. export * from "babylonjs/Cameras/camera";
  40274. export * from "babylonjs/Cameras/targetCamera";
  40275. export * from "babylonjs/Cameras/freeCamera";
  40276. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40277. export * from "babylonjs/Cameras/touchCamera";
  40278. export * from "babylonjs/Cameras/arcRotateCamera";
  40279. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40280. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40281. export * from "babylonjs/Cameras/flyCamera";
  40282. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40283. export * from "babylonjs/Cameras/followCamera";
  40284. export * from "babylonjs/Cameras/gamepadCamera";
  40285. export * from "babylonjs/Cameras/Stereoscopic/index";
  40286. export * from "babylonjs/Cameras/universalCamera";
  40287. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40288. export * from "babylonjs/Cameras/VR/index";
  40289. export * from "babylonjs/Cameras/XR/index";
  40290. export * from "babylonjs/Cameras/RigModes/index";
  40291. }
  40292. declare module "babylonjs/Collisions/index" {
  40293. export * from "babylonjs/Collisions/collider";
  40294. export * from "babylonjs/Collisions/collisionCoordinator";
  40295. export * from "babylonjs/Collisions/pickingInfo";
  40296. export * from "babylonjs/Collisions/intersectionInfo";
  40297. }
  40298. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40299. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40300. import { Vector3, Plane } from "babylonjs/Maths/math";
  40301. import { Ray } from "babylonjs/Culling/ray";
  40302. /**
  40303. * Contains an array of blocks representing the octree
  40304. */
  40305. export interface IOctreeContainer<T> {
  40306. /**
  40307. * Blocks within the octree
  40308. */
  40309. blocks: Array<OctreeBlock<T>>;
  40310. }
  40311. /**
  40312. * Class used to store a cell in an octree
  40313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40314. */
  40315. export class OctreeBlock<T> {
  40316. /**
  40317. * Gets the content of the current block
  40318. */
  40319. entries: T[];
  40320. /**
  40321. * Gets the list of block children
  40322. */
  40323. blocks: Array<OctreeBlock<T>>;
  40324. private _depth;
  40325. private _maxDepth;
  40326. private _capacity;
  40327. private _minPoint;
  40328. private _maxPoint;
  40329. private _boundingVectors;
  40330. private _creationFunc;
  40331. /**
  40332. * Creates a new block
  40333. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40334. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40335. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40336. * @param depth defines the current depth of this block in the octree
  40337. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40338. * @param creationFunc defines a callback to call when an element is added to the block
  40339. */
  40340. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40341. /**
  40342. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40343. */
  40344. readonly capacity: number;
  40345. /**
  40346. * Gets the minimum vector (in world space) of the block's bounding box
  40347. */
  40348. readonly minPoint: Vector3;
  40349. /**
  40350. * Gets the maximum vector (in world space) of the block's bounding box
  40351. */
  40352. readonly maxPoint: Vector3;
  40353. /**
  40354. * Add a new element to this block
  40355. * @param entry defines the element to add
  40356. */
  40357. addEntry(entry: T): void;
  40358. /**
  40359. * Remove an element from this block
  40360. * @param entry defines the element to remove
  40361. */
  40362. removeEntry(entry: T): void;
  40363. /**
  40364. * Add an array of elements to this block
  40365. * @param entries defines the array of elements to add
  40366. */
  40367. addEntries(entries: T[]): void;
  40368. /**
  40369. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40370. * @param frustumPlanes defines the frustum planes to test
  40371. * @param selection defines the array to store current content if selection is positive
  40372. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40373. */
  40374. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40375. /**
  40376. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40377. * @param sphereCenter defines the bounding sphere center
  40378. * @param sphereRadius defines the bounding sphere radius
  40379. * @param selection defines the array to store current content if selection is positive
  40380. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40381. */
  40382. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40383. /**
  40384. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40385. * @param ray defines the ray to test with
  40386. * @param selection defines the array to store current content if selection is positive
  40387. */
  40388. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40389. /**
  40390. * Subdivide the content into child blocks (this block will then be empty)
  40391. */
  40392. createInnerBlocks(): void;
  40393. /**
  40394. * @hidden
  40395. */
  40396. 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;
  40397. }
  40398. }
  40399. declare module "babylonjs/Culling/Octrees/octree" {
  40400. import { SmartArray } from "babylonjs/Misc/smartArray";
  40401. import { Vector3, Plane } from "babylonjs/Maths/math";
  40402. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40404. import { Ray } from "babylonjs/Culling/ray";
  40405. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40406. /**
  40407. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40408. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40409. */
  40410. export class Octree<T> {
  40411. /** 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.) */
  40412. maxDepth: number;
  40413. /**
  40414. * Blocks within the octree containing objects
  40415. */
  40416. blocks: Array<OctreeBlock<T>>;
  40417. /**
  40418. * Content stored in the octree
  40419. */
  40420. dynamicContent: T[];
  40421. private _maxBlockCapacity;
  40422. private _selectionContent;
  40423. private _creationFunc;
  40424. /**
  40425. * Creates a octree
  40426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40427. * @param creationFunc function to be used to instatiate the octree
  40428. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40429. * @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.)
  40430. */
  40431. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40432. /** 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.) */
  40433. maxDepth?: number);
  40434. /**
  40435. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40436. * @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);
  40437. * @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);
  40438. * @param entries meshes to be added to the octree blocks
  40439. */
  40440. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40441. /**
  40442. * Adds a mesh to the octree
  40443. * @param entry Mesh to add to the octree
  40444. */
  40445. addMesh(entry: T): void;
  40446. /**
  40447. * Remove an element from the octree
  40448. * @param entry defines the element to remove
  40449. */
  40450. removeMesh(entry: T): void;
  40451. /**
  40452. * Selects an array of meshes within the frustum
  40453. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40454. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40455. * @returns array of meshes within the frustum
  40456. */
  40457. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40458. /**
  40459. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40460. * @param sphereCenter defines the bounding sphere center
  40461. * @param sphereRadius defines the bounding sphere radius
  40462. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40463. * @returns an array of objects that intersect the sphere
  40464. */
  40465. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40466. /**
  40467. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40468. * @param ray defines the ray to test with
  40469. * @returns array of intersected objects
  40470. */
  40471. intersectsRay(ray: Ray): SmartArray<T>;
  40472. /**
  40473. * Adds a mesh into the octree block if it intersects the block
  40474. */
  40475. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40476. /**
  40477. * Adds a submesh into the octree block if it intersects the block
  40478. */
  40479. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40480. }
  40481. }
  40482. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40483. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40484. import { Scene } from "babylonjs/scene";
  40485. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40487. import { Ray } from "babylonjs/Culling/ray";
  40488. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40489. import { Collider } from "babylonjs/Collisions/collider";
  40490. module "babylonjs/scene" {
  40491. interface Scene {
  40492. /**
  40493. * @hidden
  40494. * Backing Filed
  40495. */
  40496. _selectionOctree: Octree<AbstractMesh>;
  40497. /**
  40498. * Gets the octree used to boost mesh selection (picking)
  40499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40500. */
  40501. selectionOctree: Octree<AbstractMesh>;
  40502. /**
  40503. * Creates or updates the octree used to boost selection (picking)
  40504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40505. * @param maxCapacity defines the maximum capacity per leaf
  40506. * @param maxDepth defines the maximum depth of the octree
  40507. * @returns an octree of AbstractMesh
  40508. */
  40509. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40510. }
  40511. }
  40512. module "babylonjs/Meshes/abstractMesh" {
  40513. interface AbstractMesh {
  40514. /**
  40515. * @hidden
  40516. * Backing Field
  40517. */
  40518. _submeshesOctree: Octree<SubMesh>;
  40519. /**
  40520. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40521. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40522. * @param maxCapacity defines the maximum size of each block (64 by default)
  40523. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40524. * @returns the new octree
  40525. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40527. */
  40528. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40529. }
  40530. }
  40531. /**
  40532. * Defines the octree scene component responsible to manage any octrees
  40533. * in a given scene.
  40534. */
  40535. export class OctreeSceneComponent {
  40536. /**
  40537. * The component name helpfull to identify the component in the list of scene components.
  40538. */
  40539. readonly name: string;
  40540. /**
  40541. * The scene the component belongs to.
  40542. */
  40543. scene: Scene;
  40544. /**
  40545. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40546. */
  40547. readonly checksIsEnabled: boolean;
  40548. /**
  40549. * Creates a new instance of the component for the given scene
  40550. * @param scene Defines the scene to register the component in
  40551. */
  40552. constructor(scene: Scene);
  40553. /**
  40554. * Registers the component in a given scene
  40555. */
  40556. register(): void;
  40557. /**
  40558. * Return the list of active meshes
  40559. * @returns the list of active meshes
  40560. */
  40561. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40562. /**
  40563. * Return the list of active sub meshes
  40564. * @param mesh The mesh to get the candidates sub meshes from
  40565. * @returns the list of active sub meshes
  40566. */
  40567. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40568. private _tempRay;
  40569. /**
  40570. * Return the list of sub meshes intersecting with a given local ray
  40571. * @param mesh defines the mesh to find the submesh for
  40572. * @param localRay defines the ray in local space
  40573. * @returns the list of intersecting sub meshes
  40574. */
  40575. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40576. /**
  40577. * Return the list of sub meshes colliding with a collider
  40578. * @param mesh defines the mesh to find the submesh for
  40579. * @param collider defines the collider to evaluate the collision against
  40580. * @returns the list of colliding sub meshes
  40581. */
  40582. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40583. /**
  40584. * Rebuilds the elements related to this component in case of
  40585. * context lost for instance.
  40586. */
  40587. rebuild(): void;
  40588. /**
  40589. * Disposes the component and the associated ressources.
  40590. */
  40591. dispose(): void;
  40592. }
  40593. }
  40594. declare module "babylonjs/Culling/Octrees/index" {
  40595. export * from "babylonjs/Culling/Octrees/octree";
  40596. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40597. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40598. }
  40599. declare module "babylonjs/Culling/index" {
  40600. export * from "babylonjs/Culling/boundingBox";
  40601. export * from "babylonjs/Culling/boundingInfo";
  40602. export * from "babylonjs/Culling/boundingSphere";
  40603. export * from "babylonjs/Culling/Octrees/index";
  40604. export * from "babylonjs/Culling/ray";
  40605. }
  40606. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40607. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40608. import { Nullable } from "babylonjs/types";
  40609. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40610. import { Scene } from "babylonjs/scene";
  40611. /**
  40612. * Class containing static functions to help procedurally build meshes
  40613. */
  40614. export class LinesBuilder {
  40615. /**
  40616. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40617. * * 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
  40618. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40619. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40620. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40621. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40622. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40623. * * 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
  40624. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40627. * @param name defines the name of the new line system
  40628. * @param options defines the options used to create the line system
  40629. * @param scene defines the hosting scene
  40630. * @returns a new line system mesh
  40631. */
  40632. static CreateLineSystem(name: string, options: {
  40633. lines: Vector3[][];
  40634. updatable?: boolean;
  40635. instance?: Nullable<LinesMesh>;
  40636. colors?: Nullable<Color4[][]>;
  40637. useVertexAlpha?: boolean;
  40638. }, scene: Nullable<Scene>): LinesMesh;
  40639. /**
  40640. * Creates a line mesh
  40641. * 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
  40642. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40643. * * The parameter `points` is an array successive Vector3
  40644. * * 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
  40645. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40646. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40647. * * When updating an instance, remember that only point positions can change, not the number of points
  40648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40650. * @param name defines the name of the new line system
  40651. * @param options defines the options used to create the line system
  40652. * @param scene defines the hosting scene
  40653. * @returns a new line mesh
  40654. */
  40655. static CreateLines(name: string, options: {
  40656. points: Vector3[];
  40657. updatable?: boolean;
  40658. instance?: Nullable<LinesMesh>;
  40659. colors?: Color4[];
  40660. useVertexAlpha?: boolean;
  40661. }, scene?: Nullable<Scene>): LinesMesh;
  40662. /**
  40663. * Creates a dashed line mesh
  40664. * * 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
  40665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40666. * * The parameter `points` is an array successive Vector3
  40667. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40668. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40669. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40670. * * 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
  40671. * * When updating an instance, remember that only point positions can change, not the number of points
  40672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40673. * @param name defines the name of the mesh
  40674. * @param options defines the options used to create the mesh
  40675. * @param scene defines the hosting scene
  40676. * @returns the dashed line mesh
  40677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40678. */
  40679. static CreateDashedLines(name: string, options: {
  40680. points: Vector3[];
  40681. dashSize?: number;
  40682. gapSize?: number;
  40683. dashNb?: number;
  40684. updatable?: boolean;
  40685. instance?: LinesMesh;
  40686. }, scene?: Nullable<Scene>): LinesMesh;
  40687. }
  40688. }
  40689. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40690. import { IDisposable, Scene } from "babylonjs/scene";
  40691. import { Nullable } from "babylonjs/types";
  40692. import { Observable } from "babylonjs/Misc/observable";
  40693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40694. /**
  40695. * Renders a layer on top of an existing scene
  40696. */
  40697. export class UtilityLayerRenderer implements IDisposable {
  40698. /** the original scene that will be rendered on top of */
  40699. originalScene: Scene;
  40700. private _pointerCaptures;
  40701. private _lastPointerEvents;
  40702. private static _DefaultUtilityLayer;
  40703. private static _DefaultKeepDepthUtilityLayer;
  40704. /**
  40705. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40706. */
  40707. pickUtilitySceneFirst: boolean;
  40708. /**
  40709. * 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)
  40710. */
  40711. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40712. /**
  40713. * 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)
  40714. */
  40715. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40716. /**
  40717. * The scene that is rendered on top of the original scene
  40718. */
  40719. utilityLayerScene: Scene;
  40720. /**
  40721. * If the utility layer should automatically be rendered on top of existing scene
  40722. */
  40723. shouldRender: boolean;
  40724. /**
  40725. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40726. */
  40727. onlyCheckPointerDownEvents: boolean;
  40728. /**
  40729. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40730. */
  40731. processAllEvents: boolean;
  40732. /**
  40733. * Observable raised when the pointer move from the utility layer scene to the main scene
  40734. */
  40735. onPointerOutObservable: Observable<number>;
  40736. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40737. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40738. private _afterRenderObserver;
  40739. private _sceneDisposeObserver;
  40740. private _originalPointerObserver;
  40741. /**
  40742. * Instantiates a UtilityLayerRenderer
  40743. * @param originalScene the original scene that will be rendered on top of
  40744. * @param handleEvents boolean indicating if the utility layer should handle events
  40745. */
  40746. constructor(
  40747. /** the original scene that will be rendered on top of */
  40748. originalScene: Scene, handleEvents?: boolean);
  40749. private _notifyObservers;
  40750. /**
  40751. * Renders the utility layers scene on top of the original scene
  40752. */
  40753. render(): void;
  40754. /**
  40755. * Disposes of the renderer
  40756. */
  40757. dispose(): void;
  40758. private _updateCamera;
  40759. }
  40760. }
  40761. declare module "babylonjs/Gizmos/gizmo" {
  40762. import { Nullable } from "babylonjs/types";
  40763. import { IDisposable } from "babylonjs/scene";
  40764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40765. import { Mesh } from "babylonjs/Meshes/mesh";
  40766. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40767. /**
  40768. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40769. */
  40770. export class Gizmo implements IDisposable {
  40771. /** The utility layer the gizmo will be added to */
  40772. gizmoLayer: UtilityLayerRenderer;
  40773. /**
  40774. * The root mesh of the gizmo
  40775. */
  40776. _rootMesh: Mesh;
  40777. private _attachedMesh;
  40778. /**
  40779. * Ratio for the scale of the gizmo (Default: 1)
  40780. */
  40781. scaleRatio: number;
  40782. private _tmpMatrix;
  40783. /**
  40784. * If a custom mesh has been set (Default: false)
  40785. */
  40786. protected _customMeshSet: boolean;
  40787. /**
  40788. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40789. * * When set, interactions will be enabled
  40790. */
  40791. attachedMesh: Nullable<AbstractMesh>;
  40792. /**
  40793. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40794. * @param mesh The mesh to replace the default mesh of the gizmo
  40795. */
  40796. setCustomMesh(mesh: Mesh): void;
  40797. /**
  40798. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40799. */
  40800. updateGizmoRotationToMatchAttachedMesh: boolean;
  40801. /**
  40802. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40803. */
  40804. updateGizmoPositionToMatchAttachedMesh: boolean;
  40805. /**
  40806. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40807. */
  40808. protected _updateScale: boolean;
  40809. protected _interactionsEnabled: boolean;
  40810. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40811. private _beforeRenderObserver;
  40812. /**
  40813. * Creates a gizmo
  40814. * @param gizmoLayer The utility layer the gizmo will be added to
  40815. */
  40816. constructor(
  40817. /** The utility layer the gizmo will be added to */
  40818. gizmoLayer?: UtilityLayerRenderer);
  40819. private _tempVector;
  40820. /**
  40821. * @hidden
  40822. * Updates the gizmo to match the attached mesh's position/rotation
  40823. */
  40824. protected _update(): void;
  40825. /**
  40826. * Disposes of the gizmo
  40827. */
  40828. dispose(): void;
  40829. }
  40830. }
  40831. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40832. import { Observable } from "babylonjs/Misc/observable";
  40833. import { Nullable } from "babylonjs/types";
  40834. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40835. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40837. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40838. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40839. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40840. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40841. import { Scene } from "babylonjs/scene";
  40842. /**
  40843. * Single axis drag gizmo
  40844. */
  40845. export class AxisDragGizmo extends Gizmo {
  40846. /**
  40847. * Drag behavior responsible for the gizmos dragging interactions
  40848. */
  40849. dragBehavior: PointerDragBehavior;
  40850. private _pointerObserver;
  40851. /**
  40852. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40853. */
  40854. snapDistance: number;
  40855. /**
  40856. * Event that fires each time the gizmo snaps to a new location.
  40857. * * snapDistance is the the change in distance
  40858. */
  40859. onSnapObservable: Observable<{
  40860. snapDistance: number;
  40861. }>;
  40862. /** @hidden */
  40863. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40864. /** @hidden */
  40865. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40866. /**
  40867. * Creates an AxisDragGizmo
  40868. * @param gizmoLayer The utility layer the gizmo will be added to
  40869. * @param dragAxis The axis which the gizmo will be able to drag on
  40870. * @param color The color of the gizmo
  40871. */
  40872. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40873. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40874. /**
  40875. * Disposes of the gizmo
  40876. */
  40877. dispose(): void;
  40878. }
  40879. }
  40880. declare module "babylonjs/Debug/axesViewer" {
  40881. import { Vector3 } from "babylonjs/Maths/math";
  40882. import { Nullable } from "babylonjs/types";
  40883. import { Scene } from "babylonjs/scene";
  40884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40885. /**
  40886. * The Axes viewer will show 3 axes in a specific point in space
  40887. */
  40888. export class AxesViewer {
  40889. private _xAxis;
  40890. private _yAxis;
  40891. private _zAxis;
  40892. private _scaleLinesFactor;
  40893. private _instanced;
  40894. /**
  40895. * Gets the hosting scene
  40896. */
  40897. scene: Scene;
  40898. /**
  40899. * Gets or sets a number used to scale line length
  40900. */
  40901. scaleLines: number;
  40902. /** Gets the node hierarchy used to render x-axis */
  40903. readonly xAxis: TransformNode;
  40904. /** Gets the node hierarchy used to render y-axis */
  40905. readonly yAxis: TransformNode;
  40906. /** Gets the node hierarchy used to render z-axis */
  40907. readonly zAxis: TransformNode;
  40908. /**
  40909. * Creates a new AxesViewer
  40910. * @param scene defines the hosting scene
  40911. * @param scaleLines defines a number used to scale line length (1 by default)
  40912. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40913. * @param xAxis defines the node hierarchy used to render the x-axis
  40914. * @param yAxis defines the node hierarchy used to render the y-axis
  40915. * @param zAxis defines the node hierarchy used to render the z-axis
  40916. */
  40917. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40918. /**
  40919. * Force the viewer to update
  40920. * @param position defines the position of the viewer
  40921. * @param xaxis defines the x axis of the viewer
  40922. * @param yaxis defines the y axis of the viewer
  40923. * @param zaxis defines the z axis of the viewer
  40924. */
  40925. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40926. /**
  40927. * Creates an instance of this axes viewer.
  40928. * @returns a new axes viewer with instanced meshes
  40929. */
  40930. createInstance(): AxesViewer;
  40931. /** Releases resources */
  40932. dispose(): void;
  40933. private static _SetRenderingGroupId;
  40934. }
  40935. }
  40936. declare module "babylonjs/Debug/boneAxesViewer" {
  40937. import { Nullable } from "babylonjs/types";
  40938. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40939. import { Vector3 } from "babylonjs/Maths/math";
  40940. import { Mesh } from "babylonjs/Meshes/mesh";
  40941. import { Bone } from "babylonjs/Bones/bone";
  40942. import { Scene } from "babylonjs/scene";
  40943. /**
  40944. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40945. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40946. */
  40947. export class BoneAxesViewer extends AxesViewer {
  40948. /**
  40949. * Gets or sets the target mesh where to display the axes viewer
  40950. */
  40951. mesh: Nullable<Mesh>;
  40952. /**
  40953. * Gets or sets the target bone where to display the axes viewer
  40954. */
  40955. bone: Nullable<Bone>;
  40956. /** Gets current position */
  40957. pos: Vector3;
  40958. /** Gets direction of X axis */
  40959. xaxis: Vector3;
  40960. /** Gets direction of Y axis */
  40961. yaxis: Vector3;
  40962. /** Gets direction of Z axis */
  40963. zaxis: Vector3;
  40964. /**
  40965. * Creates a new BoneAxesViewer
  40966. * @param scene defines the hosting scene
  40967. * @param bone defines the target bone
  40968. * @param mesh defines the target mesh
  40969. * @param scaleLines defines a scaling factor for line length (1 by default)
  40970. */
  40971. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40972. /**
  40973. * Force the viewer to update
  40974. */
  40975. update(): void;
  40976. /** Releases resources */
  40977. dispose(): void;
  40978. }
  40979. }
  40980. declare module "babylonjs/Debug/debugLayer" {
  40981. import { Observable } from "babylonjs/Misc/observable";
  40982. import { Scene } from "babylonjs/scene";
  40983. /**
  40984. * Interface used to define scene explorer extensibility option
  40985. */
  40986. export interface IExplorerExtensibilityOption {
  40987. /**
  40988. * Define the option label
  40989. */
  40990. label: string;
  40991. /**
  40992. * Defines the action to execute on click
  40993. */
  40994. action: (entity: any) => void;
  40995. }
  40996. /**
  40997. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40998. */
  40999. export interface IExplorerExtensibilityGroup {
  41000. /**
  41001. * Defines a predicate to test if a given type mut be extended
  41002. */
  41003. predicate: (entity: any) => boolean;
  41004. /**
  41005. * Gets the list of options added to a type
  41006. */
  41007. entries: IExplorerExtensibilityOption[];
  41008. }
  41009. /**
  41010. * Interface used to define the options to use to create the Inspector
  41011. */
  41012. export interface IInspectorOptions {
  41013. /**
  41014. * Display in overlay mode (default: false)
  41015. */
  41016. overlay?: boolean;
  41017. /**
  41018. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41019. */
  41020. globalRoot?: HTMLElement;
  41021. /**
  41022. * Display the Scene explorer
  41023. */
  41024. showExplorer?: boolean;
  41025. /**
  41026. * Display the property inspector
  41027. */
  41028. showInspector?: boolean;
  41029. /**
  41030. * Display in embed mode (both panes on the right)
  41031. */
  41032. embedMode?: boolean;
  41033. /**
  41034. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41035. */
  41036. handleResize?: boolean;
  41037. /**
  41038. * Allow the panes to popup (default: true)
  41039. */
  41040. enablePopup?: boolean;
  41041. /**
  41042. * Allow the panes to be closed by users (default: true)
  41043. */
  41044. enableClose?: boolean;
  41045. /**
  41046. * Optional list of extensibility entries
  41047. */
  41048. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41049. }
  41050. module "babylonjs/scene" {
  41051. interface Scene {
  41052. /**
  41053. * @hidden
  41054. * Backing field
  41055. */
  41056. _debugLayer: DebugLayer;
  41057. /**
  41058. * Gets the debug layer (aka Inspector) associated with the scene
  41059. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41060. */
  41061. debugLayer: DebugLayer;
  41062. }
  41063. }
  41064. /**
  41065. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41066. * what is happening in your scene
  41067. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41068. */
  41069. export class DebugLayer {
  41070. /**
  41071. * Define the url to get the inspector script from.
  41072. * By default it uses the babylonjs CDN.
  41073. * @ignoreNaming
  41074. */
  41075. static InspectorURL: string;
  41076. private _scene;
  41077. private BJSINSPECTOR;
  41078. /**
  41079. * Observable triggered when a property is changed through the inspector.
  41080. */
  41081. onPropertyChangedObservable: Observable<{
  41082. object: any;
  41083. property: string;
  41084. value: any;
  41085. initialValue: any;
  41086. }>;
  41087. /**
  41088. * Instantiates a new debug layer.
  41089. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41090. * what is happening in your scene
  41091. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41092. * @param scene Defines the scene to inspect
  41093. */
  41094. constructor(scene: Scene);
  41095. /** Creates the inspector window. */
  41096. private _createInspector;
  41097. /** Get the inspector from bundle or global */
  41098. private _getGlobalInspector;
  41099. /**
  41100. * Get if the inspector is visible or not.
  41101. * @returns true if visible otherwise, false
  41102. */
  41103. isVisible(): boolean;
  41104. /**
  41105. * Hide the inspector and close its window.
  41106. */
  41107. hide(): void;
  41108. /**
  41109. * Launch the debugLayer.
  41110. * @param config Define the configuration of the inspector
  41111. */
  41112. show(config?: IInspectorOptions): void;
  41113. }
  41114. }
  41115. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41116. import { Nullable } from "babylonjs/types";
  41117. import { Scene } from "babylonjs/scene";
  41118. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41119. import { Mesh } from "babylonjs/Meshes/mesh";
  41120. /**
  41121. * Class containing static functions to help procedurally build meshes
  41122. */
  41123. export class BoxBuilder {
  41124. /**
  41125. * Creates a box mesh
  41126. * * The parameter `size` sets the size (float) of each box side (default 1)
  41127. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41128. * * 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)
  41129. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41133. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41134. * @param name defines the name of the mesh
  41135. * @param options defines the options used to create the mesh
  41136. * @param scene defines the hosting scene
  41137. * @returns the box mesh
  41138. */
  41139. static CreateBox(name: string, options: {
  41140. size?: number;
  41141. width?: number;
  41142. height?: number;
  41143. depth?: number;
  41144. faceUV?: Vector4[];
  41145. faceColors?: Color4[];
  41146. sideOrientation?: number;
  41147. frontUVs?: Vector4;
  41148. backUVs?: Vector4;
  41149. updatable?: boolean;
  41150. }, scene?: Nullable<Scene>): Mesh;
  41151. }
  41152. }
  41153. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41154. import { Vector4 } from "babylonjs/Maths/math";
  41155. import { Mesh } from "babylonjs/Meshes/mesh";
  41156. /**
  41157. * Class containing static functions to help procedurally build meshes
  41158. */
  41159. export class SphereBuilder {
  41160. /**
  41161. * Creates a sphere mesh
  41162. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41163. * * 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`)
  41164. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41165. * * 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
  41166. * * 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)
  41167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41170. * @param name defines the name of the mesh
  41171. * @param options defines the options used to create the mesh
  41172. * @param scene defines the hosting scene
  41173. * @returns the sphere mesh
  41174. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41175. */
  41176. static CreateSphere(name: string, options: {
  41177. segments?: number;
  41178. diameter?: number;
  41179. diameterX?: number;
  41180. diameterY?: number;
  41181. diameterZ?: number;
  41182. arc?: number;
  41183. slice?: number;
  41184. sideOrientation?: number;
  41185. frontUVs?: Vector4;
  41186. backUVs?: Vector4;
  41187. updatable?: boolean;
  41188. }, scene: any): Mesh;
  41189. }
  41190. }
  41191. declare module "babylonjs/Debug/physicsViewer" {
  41192. import { Nullable } from "babylonjs/types";
  41193. import { Scene } from "babylonjs/scene";
  41194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41195. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41196. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41197. /**
  41198. * Used to show the physics impostor around the specific mesh
  41199. */
  41200. export class PhysicsViewer {
  41201. /** @hidden */
  41202. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41203. /** @hidden */
  41204. protected _meshes: Array<Nullable<AbstractMesh>>;
  41205. /** @hidden */
  41206. protected _scene: Nullable<Scene>;
  41207. /** @hidden */
  41208. protected _numMeshes: number;
  41209. /** @hidden */
  41210. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41211. private _renderFunction;
  41212. private _utilityLayer;
  41213. private _debugBoxMesh;
  41214. private _debugSphereMesh;
  41215. private _debugMaterial;
  41216. /**
  41217. * Creates a new PhysicsViewer
  41218. * @param scene defines the hosting scene
  41219. */
  41220. constructor(scene: Scene);
  41221. /** @hidden */
  41222. protected _updateDebugMeshes(): void;
  41223. /**
  41224. * Renders a specified physic impostor
  41225. * @param impostor defines the impostor to render
  41226. * @returns the new debug mesh used to render the impostor
  41227. */
  41228. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41229. /**
  41230. * Hides a specified physic impostor
  41231. * @param impostor defines the impostor to hide
  41232. */
  41233. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41234. private _getDebugMaterial;
  41235. private _getDebugBoxMesh;
  41236. private _getDebugSphereMesh;
  41237. private _getDebugMesh;
  41238. /** Releases all resources */
  41239. dispose(): void;
  41240. }
  41241. }
  41242. declare module "babylonjs/Debug/rayHelper" {
  41243. import { Nullable } from "babylonjs/types";
  41244. import { Ray } from "babylonjs/Culling/ray";
  41245. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41246. import { Scene } from "babylonjs/scene";
  41247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41248. import "babylonjs/Meshes/Builders/linesBuilder";
  41249. /**
  41250. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41251. * in order to better appreciate the issue one might have.
  41252. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41253. */
  41254. export class RayHelper {
  41255. /**
  41256. * Defines the ray we are currently tryin to visualize.
  41257. */
  41258. ray: Nullable<Ray>;
  41259. private _renderPoints;
  41260. private _renderLine;
  41261. private _renderFunction;
  41262. private _scene;
  41263. private _updateToMeshFunction;
  41264. private _attachedToMesh;
  41265. private _meshSpaceDirection;
  41266. private _meshSpaceOrigin;
  41267. /**
  41268. * Helper function to create a colored helper in a scene in one line.
  41269. * @param ray Defines the ray we are currently tryin to visualize
  41270. * @param scene Defines the scene the ray is used in
  41271. * @param color Defines the color we want to see the ray in
  41272. * @returns The newly created ray helper.
  41273. */
  41274. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41275. /**
  41276. * Instantiate a new ray helper.
  41277. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41278. * in order to better appreciate the issue one might have.
  41279. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41280. * @param ray Defines the ray we are currently tryin to visualize
  41281. */
  41282. constructor(ray: Ray);
  41283. /**
  41284. * Shows the ray we are willing to debug.
  41285. * @param scene Defines the scene the ray needs to be rendered in
  41286. * @param color Defines the color the ray needs to be rendered in
  41287. */
  41288. show(scene: Scene, color?: Color3): void;
  41289. /**
  41290. * Hides the ray we are debugging.
  41291. */
  41292. hide(): void;
  41293. private _render;
  41294. /**
  41295. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41296. * @param mesh Defines the mesh we want the helper attached to
  41297. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41298. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41299. * @param length Defines the length of the ray
  41300. */
  41301. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41302. /**
  41303. * Detach the ray helper from the mesh it has previously been attached to.
  41304. */
  41305. detachFromMesh(): void;
  41306. private _updateToMesh;
  41307. /**
  41308. * Dispose the helper and release its associated resources.
  41309. */
  41310. dispose(): void;
  41311. }
  41312. }
  41313. declare module "babylonjs/Debug/skeletonViewer" {
  41314. import { Color3 } from "babylonjs/Maths/math";
  41315. import { Scene } from "babylonjs/scene";
  41316. import { Nullable } from "babylonjs/types";
  41317. import { Skeleton } from "babylonjs/Bones/skeleton";
  41318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41319. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41320. /**
  41321. * Class used to render a debug view of a given skeleton
  41322. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41323. */
  41324. export class SkeletonViewer {
  41325. /** defines the skeleton to render */
  41326. skeleton: Skeleton;
  41327. /** defines the mesh attached to the skeleton */
  41328. mesh: AbstractMesh;
  41329. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41330. autoUpdateBonesMatrices: boolean;
  41331. /** defines the rendering group id to use with the viewer */
  41332. renderingGroupId: number;
  41333. /** Gets or sets the color used to render the skeleton */
  41334. color: Color3;
  41335. private _scene;
  41336. private _debugLines;
  41337. private _debugMesh;
  41338. private _isEnabled;
  41339. private _renderFunction;
  41340. private _utilityLayer;
  41341. /**
  41342. * Returns the mesh used to render the bones
  41343. */
  41344. readonly debugMesh: Nullable<LinesMesh>;
  41345. /**
  41346. * Creates a new SkeletonViewer
  41347. * @param skeleton defines the skeleton to render
  41348. * @param mesh defines the mesh attached to the skeleton
  41349. * @param scene defines the hosting scene
  41350. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41351. * @param renderingGroupId defines the rendering group id to use with the viewer
  41352. */
  41353. constructor(
  41354. /** defines the skeleton to render */
  41355. skeleton: Skeleton,
  41356. /** defines the mesh attached to the skeleton */
  41357. mesh: AbstractMesh, scene: Scene,
  41358. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41359. autoUpdateBonesMatrices?: boolean,
  41360. /** defines the rendering group id to use with the viewer */
  41361. renderingGroupId?: number);
  41362. /** Gets or sets a boolean indicating if the viewer is enabled */
  41363. isEnabled: boolean;
  41364. private _getBonePosition;
  41365. private _getLinesForBonesWithLength;
  41366. private _getLinesForBonesNoLength;
  41367. /** Update the viewer to sync with current skeleton state */
  41368. update(): void;
  41369. /** Release associated resources */
  41370. dispose(): void;
  41371. }
  41372. }
  41373. declare module "babylonjs/Debug/index" {
  41374. export * from "babylonjs/Debug/axesViewer";
  41375. export * from "babylonjs/Debug/boneAxesViewer";
  41376. export * from "babylonjs/Debug/debugLayer";
  41377. export * from "babylonjs/Debug/physicsViewer";
  41378. export * from "babylonjs/Debug/rayHelper";
  41379. export * from "babylonjs/Debug/skeletonViewer";
  41380. }
  41381. declare module "babylonjs/Engines/nullEngine" {
  41382. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41383. import { Scene } from "babylonjs/scene";
  41384. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41385. import { Engine } from "babylonjs/Engines/engine";
  41386. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41389. import { Effect } from "babylonjs/Materials/effect";
  41390. /**
  41391. * Options to create the null engine
  41392. */
  41393. export class NullEngineOptions {
  41394. /**
  41395. * Render width (Default: 512)
  41396. */
  41397. renderWidth: number;
  41398. /**
  41399. * Render height (Default: 256)
  41400. */
  41401. renderHeight: number;
  41402. /**
  41403. * Texture size (Default: 512)
  41404. */
  41405. textureSize: number;
  41406. /**
  41407. * If delta time between frames should be constant
  41408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41409. */
  41410. deterministicLockstep: boolean;
  41411. /**
  41412. * Maximum about of steps between frames (Default: 4)
  41413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41414. */
  41415. lockstepMaxSteps: number;
  41416. }
  41417. /**
  41418. * The null engine class provides support for headless version of babylon.js.
  41419. * This can be used in server side scenario or for testing purposes
  41420. */
  41421. export class NullEngine extends Engine {
  41422. private _options;
  41423. /**
  41424. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41425. */
  41426. isDeterministicLockStep(): boolean;
  41427. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41428. getLockstepMaxSteps(): number;
  41429. /**
  41430. * Sets hardware scaling, used to save performance if needed
  41431. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41432. */
  41433. getHardwareScalingLevel(): number;
  41434. constructor(options?: NullEngineOptions);
  41435. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41436. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41437. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41438. getRenderWidth(useScreen?: boolean): number;
  41439. getRenderHeight(useScreen?: boolean): number;
  41440. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41441. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41442. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41443. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41444. bindSamplers(effect: Effect): void;
  41445. enableEffect(effect: Effect): void;
  41446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41447. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41448. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41449. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41450. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41451. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41452. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41453. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41454. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41455. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41456. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41457. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41458. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41459. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41460. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41461. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41462. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41463. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41464. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41465. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41466. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41467. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41468. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41469. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41470. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41471. bindBuffers(vertexBuffers: {
  41472. [key: string]: VertexBuffer;
  41473. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41474. wipeCaches(bruteForce?: boolean): void;
  41475. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41476. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41477. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41478. /** @hidden */
  41479. _createTexture(): WebGLTexture;
  41480. /** @hidden */
  41481. _releaseTexture(texture: InternalTexture): void;
  41482. 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;
  41483. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41484. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41485. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41486. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41487. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41488. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41489. areAllEffectsReady(): boolean;
  41490. /**
  41491. * @hidden
  41492. * Get the current error code of the webGL context
  41493. * @returns the error code
  41494. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41495. */
  41496. getError(): number;
  41497. /** @hidden */
  41498. _getUnpackAlignement(): number;
  41499. /** @hidden */
  41500. _unpackFlipY(value: boolean): void;
  41501. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41502. /**
  41503. * Updates a dynamic vertex buffer.
  41504. * @param vertexBuffer the vertex buffer to update
  41505. * @param data the data used to update the vertex buffer
  41506. * @param byteOffset the byte offset of the data (optional)
  41507. * @param byteLength the byte length of the data (optional)
  41508. */
  41509. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41510. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41511. /** @hidden */
  41512. _bindTexture(channel: number, texture: InternalTexture): void;
  41513. /** @hidden */
  41514. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41515. releaseEffects(): void;
  41516. displayLoadingUI(): void;
  41517. hideLoadingUI(): void;
  41518. /** @hidden */
  41519. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41520. /** @hidden */
  41521. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41522. /** @hidden */
  41523. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41524. /** @hidden */
  41525. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41526. }
  41527. }
  41528. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41529. import { Nullable, int } from "babylonjs/types";
  41530. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41531. /** @hidden */
  41532. export class _OcclusionDataStorage {
  41533. /** @hidden */
  41534. occlusionInternalRetryCounter: number;
  41535. /** @hidden */
  41536. isOcclusionQueryInProgress: boolean;
  41537. /** @hidden */
  41538. isOccluded: boolean;
  41539. /** @hidden */
  41540. occlusionRetryCount: number;
  41541. /** @hidden */
  41542. occlusionType: number;
  41543. /** @hidden */
  41544. occlusionQueryAlgorithmType: number;
  41545. }
  41546. module "babylonjs/Engines/engine" {
  41547. interface Engine {
  41548. /**
  41549. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41550. * @return the new query
  41551. */
  41552. createQuery(): WebGLQuery;
  41553. /**
  41554. * Delete and release a webGL query
  41555. * @param query defines the query to delete
  41556. * @return the current engine
  41557. */
  41558. deleteQuery(query: WebGLQuery): Engine;
  41559. /**
  41560. * Check if a given query has resolved and got its value
  41561. * @param query defines the query to check
  41562. * @returns true if the query got its value
  41563. */
  41564. isQueryResultAvailable(query: WebGLQuery): boolean;
  41565. /**
  41566. * Gets the value of a given query
  41567. * @param query defines the query to check
  41568. * @returns the value of the query
  41569. */
  41570. getQueryResult(query: WebGLQuery): number;
  41571. /**
  41572. * Initiates an occlusion query
  41573. * @param algorithmType defines the algorithm to use
  41574. * @param query defines the query to use
  41575. * @returns the current engine
  41576. * @see http://doc.babylonjs.com/features/occlusionquery
  41577. */
  41578. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41579. /**
  41580. * Ends an occlusion query
  41581. * @see http://doc.babylonjs.com/features/occlusionquery
  41582. * @param algorithmType defines the algorithm to use
  41583. * @returns the current engine
  41584. */
  41585. endOcclusionQuery(algorithmType: number): Engine;
  41586. /**
  41587. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41588. * Please note that only one query can be issued at a time
  41589. * @returns a time token used to track the time span
  41590. */
  41591. startTimeQuery(): Nullable<_TimeToken>;
  41592. /**
  41593. * Ends a time query
  41594. * @param token defines the token used to measure the time span
  41595. * @returns the time spent (in ns)
  41596. */
  41597. endTimeQuery(token: _TimeToken): int;
  41598. /** @hidden */
  41599. _currentNonTimestampToken: Nullable<_TimeToken>;
  41600. /** @hidden */
  41601. _createTimeQuery(): WebGLQuery;
  41602. /** @hidden */
  41603. _deleteTimeQuery(query: WebGLQuery): void;
  41604. /** @hidden */
  41605. _getGlAlgorithmType(algorithmType: number): number;
  41606. /** @hidden */
  41607. _getTimeQueryResult(query: WebGLQuery): any;
  41608. /** @hidden */
  41609. _getTimeQueryAvailability(query: WebGLQuery): any;
  41610. }
  41611. }
  41612. module "babylonjs/Meshes/abstractMesh" {
  41613. interface AbstractMesh {
  41614. /**
  41615. * Backing filed
  41616. * @hidden
  41617. */
  41618. __occlusionDataStorage: _OcclusionDataStorage;
  41619. /**
  41620. * Access property
  41621. * @hidden
  41622. */
  41623. _occlusionDataStorage: _OcclusionDataStorage;
  41624. /**
  41625. * 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.
  41626. * The default value is -1 which means don't break the query and wait till the result
  41627. * @see http://doc.babylonjs.com/features/occlusionquery
  41628. */
  41629. occlusionRetryCount: number;
  41630. /**
  41631. * 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:
  41632. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41633. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41634. * * 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.
  41635. * @see http://doc.babylonjs.com/features/occlusionquery
  41636. */
  41637. occlusionType: number;
  41638. /**
  41639. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41640. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41641. * * 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.
  41642. * @see http://doc.babylonjs.com/features/occlusionquery
  41643. */
  41644. occlusionQueryAlgorithmType: number;
  41645. /**
  41646. * 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
  41647. * @see http://doc.babylonjs.com/features/occlusionquery
  41648. */
  41649. isOccluded: boolean;
  41650. /**
  41651. * Flag to check the progress status of the query
  41652. * @see http://doc.babylonjs.com/features/occlusionquery
  41653. */
  41654. isOcclusionQueryInProgress: boolean;
  41655. }
  41656. }
  41657. }
  41658. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41659. import { Nullable } from "babylonjs/types";
  41660. /** @hidden */
  41661. export var _forceTransformFeedbackToBundle: boolean;
  41662. module "babylonjs/Engines/engine" {
  41663. interface Engine {
  41664. /**
  41665. * Creates a webGL transform feedback object
  41666. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41667. * @returns the webGL transform feedback object
  41668. */
  41669. createTransformFeedback(): WebGLTransformFeedback;
  41670. /**
  41671. * Delete a webGL transform feedback object
  41672. * @param value defines the webGL transform feedback object to delete
  41673. */
  41674. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41675. /**
  41676. * Bind a webGL transform feedback object to the webgl context
  41677. * @param value defines the webGL transform feedback object to bind
  41678. */
  41679. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41680. /**
  41681. * Begins a transform feedback operation
  41682. * @param usePoints defines if points or triangles must be used
  41683. */
  41684. beginTransformFeedback(usePoints: boolean): void;
  41685. /**
  41686. * Ends a transform feedback operation
  41687. */
  41688. endTransformFeedback(): void;
  41689. /**
  41690. * Specify the varyings to use with transform feedback
  41691. * @param program defines the associated webGL program
  41692. * @param value defines the list of strings representing the varying names
  41693. */
  41694. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41695. /**
  41696. * Bind a webGL buffer for a transform feedback operation
  41697. * @param value defines the webGL buffer to bind
  41698. */
  41699. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41700. }
  41701. }
  41702. }
  41703. declare module "babylonjs/Engines/Extensions/index" {
  41704. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41705. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41706. }
  41707. declare module "babylonjs/Engines/index" {
  41708. export * from "babylonjs/Engines/constants";
  41709. export * from "babylonjs/Engines/engine";
  41710. export * from "babylonjs/Engines/engineStore";
  41711. export * from "babylonjs/Engines/nullEngine";
  41712. export * from "babylonjs/Engines/Extensions/index";
  41713. }
  41714. declare module "babylonjs/Events/clipboardEvents" {
  41715. /**
  41716. * Gather the list of clipboard event types as constants.
  41717. */
  41718. export class ClipboardEventTypes {
  41719. /**
  41720. * The clipboard event is fired when a copy command is active (pressed).
  41721. */
  41722. static readonly COPY: number;
  41723. /**
  41724. * The clipboard event is fired when a cut command is active (pressed).
  41725. */
  41726. static readonly CUT: number;
  41727. /**
  41728. * The clipboard event is fired when a paste command is active (pressed).
  41729. */
  41730. static readonly PASTE: number;
  41731. }
  41732. /**
  41733. * This class is used to store clipboard related info for the onClipboardObservable event.
  41734. */
  41735. export class ClipboardInfo {
  41736. /**
  41737. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41738. */
  41739. type: number;
  41740. /**
  41741. * Defines the related dom event
  41742. */
  41743. event: ClipboardEvent;
  41744. /**
  41745. *Creates an instance of ClipboardInfo.
  41746. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41747. * @param event Defines the related dom event
  41748. */
  41749. constructor(
  41750. /**
  41751. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41752. */
  41753. type: number,
  41754. /**
  41755. * Defines the related dom event
  41756. */
  41757. event: ClipboardEvent);
  41758. /**
  41759. * Get the clipboard event's type from the keycode.
  41760. * @param keyCode Defines the keyCode for the current keyboard event.
  41761. * @return {number}
  41762. */
  41763. static GetTypeFromCharacter(keyCode: number): number;
  41764. }
  41765. }
  41766. declare module "babylonjs/Events/index" {
  41767. export * from "babylonjs/Events/keyboardEvents";
  41768. export * from "babylonjs/Events/pointerEvents";
  41769. export * from "babylonjs/Events/clipboardEvents";
  41770. }
  41771. declare module "babylonjs/Loading/sceneLoader" {
  41772. import { Observable } from "babylonjs/Misc/observable";
  41773. import { Nullable } from "babylonjs/types";
  41774. import { Scene } from "babylonjs/scene";
  41775. import { Engine } from "babylonjs/Engines/engine";
  41776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41777. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41778. import { AssetContainer } from "babylonjs/assetContainer";
  41779. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41780. import { Skeleton } from "babylonjs/Bones/skeleton";
  41781. /**
  41782. * Class used to represent data loading progression
  41783. */
  41784. export class SceneLoaderProgressEvent {
  41785. /** defines if data length to load can be evaluated */
  41786. readonly lengthComputable: boolean;
  41787. /** defines the loaded data length */
  41788. readonly loaded: number;
  41789. /** defines the data length to load */
  41790. readonly total: number;
  41791. /**
  41792. * Create a new progress event
  41793. * @param lengthComputable defines if data length to load can be evaluated
  41794. * @param loaded defines the loaded data length
  41795. * @param total defines the data length to load
  41796. */
  41797. constructor(
  41798. /** defines if data length to load can be evaluated */
  41799. lengthComputable: boolean,
  41800. /** defines the loaded data length */
  41801. loaded: number,
  41802. /** defines the data length to load */
  41803. total: number);
  41804. /**
  41805. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41806. * @param event defines the source event
  41807. * @returns a new SceneLoaderProgressEvent
  41808. */
  41809. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41810. }
  41811. /**
  41812. * Interface used by SceneLoader plugins to define supported file extensions
  41813. */
  41814. export interface ISceneLoaderPluginExtensions {
  41815. /**
  41816. * Defines the list of supported extensions
  41817. */
  41818. [extension: string]: {
  41819. isBinary: boolean;
  41820. };
  41821. }
  41822. /**
  41823. * Interface used by SceneLoader plugin factory
  41824. */
  41825. export interface ISceneLoaderPluginFactory {
  41826. /**
  41827. * Defines the name of the factory
  41828. */
  41829. name: string;
  41830. /**
  41831. * Function called to create a new plugin
  41832. * @return the new plugin
  41833. */
  41834. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41835. /**
  41836. * Boolean indicating if the plugin can direct load specific data
  41837. */
  41838. canDirectLoad?: (data: string) => boolean;
  41839. }
  41840. /**
  41841. * Interface used to define a SceneLoader plugin
  41842. */
  41843. export interface ISceneLoaderPlugin {
  41844. /**
  41845. * The friendly name of this plugin.
  41846. */
  41847. name: string;
  41848. /**
  41849. * The file extensions supported by this plugin.
  41850. */
  41851. extensions: string | ISceneLoaderPluginExtensions;
  41852. /**
  41853. * Import meshes into a scene.
  41854. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41855. * @param scene The scene to import into
  41856. * @param data The data to import
  41857. * @param rootUrl The root url for scene and resources
  41858. * @param meshes The meshes array to import into
  41859. * @param particleSystems The particle systems array to import into
  41860. * @param skeletons The skeletons array to import into
  41861. * @param onError The callback when import fails
  41862. * @returns True if successful or false otherwise
  41863. */
  41864. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41865. /**
  41866. * Load into a scene.
  41867. * @param scene The scene to load into
  41868. * @param data The data to import
  41869. * @param rootUrl The root url for scene and resources
  41870. * @param onError The callback when import fails
  41871. * @returns true if successful or false otherwise
  41872. */
  41873. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41874. /**
  41875. * The callback that returns true if the data can be directly loaded.
  41876. */
  41877. canDirectLoad?: (data: string) => boolean;
  41878. /**
  41879. * The callback that allows custom handling of the root url based on the response url.
  41880. */
  41881. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41882. /**
  41883. * Load into an asset container.
  41884. * @param scene The scene to load into
  41885. * @param data The data to import
  41886. * @param rootUrl The root url for scene and resources
  41887. * @param onError The callback when import fails
  41888. * @returns The loaded asset container
  41889. */
  41890. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41891. }
  41892. /**
  41893. * Interface used to define an async SceneLoader plugin
  41894. */
  41895. export interface ISceneLoaderPluginAsync {
  41896. /**
  41897. * The friendly name of this plugin.
  41898. */
  41899. name: string;
  41900. /**
  41901. * The file extensions supported by this plugin.
  41902. */
  41903. extensions: string | ISceneLoaderPluginExtensions;
  41904. /**
  41905. * Import meshes into a scene.
  41906. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41907. * @param scene The scene to import into
  41908. * @param data The data to import
  41909. * @param rootUrl The root url for scene and resources
  41910. * @param onProgress The callback when the load progresses
  41911. * @param fileName Defines the name of the file to load
  41912. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41913. */
  41914. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41915. meshes: AbstractMesh[];
  41916. particleSystems: IParticleSystem[];
  41917. skeletons: Skeleton[];
  41918. animationGroups: AnimationGroup[];
  41919. }>;
  41920. /**
  41921. * Load into a scene.
  41922. * @param scene The scene to load into
  41923. * @param data The data to import
  41924. * @param rootUrl The root url for scene and resources
  41925. * @param onProgress The callback when the load progresses
  41926. * @param fileName Defines the name of the file to load
  41927. * @returns Nothing
  41928. */
  41929. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41930. /**
  41931. * The callback that returns true if the data can be directly loaded.
  41932. */
  41933. canDirectLoad?: (data: string) => boolean;
  41934. /**
  41935. * The callback that allows custom handling of the root url based on the response url.
  41936. */
  41937. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41938. /**
  41939. * Load into an asset container.
  41940. * @param scene The scene to load into
  41941. * @param data The data to import
  41942. * @param rootUrl The root url for scene and resources
  41943. * @param onProgress The callback when the load progresses
  41944. * @param fileName Defines the name of the file to load
  41945. * @returns The loaded asset container
  41946. */
  41947. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41948. }
  41949. /**
  41950. * Class used to load scene from various file formats using registered plugins
  41951. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41952. */
  41953. export class SceneLoader {
  41954. /**
  41955. * No logging while loading
  41956. */
  41957. static readonly NO_LOGGING: number;
  41958. /**
  41959. * Minimal logging while loading
  41960. */
  41961. static readonly MINIMAL_LOGGING: number;
  41962. /**
  41963. * Summary logging while loading
  41964. */
  41965. static readonly SUMMARY_LOGGING: number;
  41966. /**
  41967. * Detailled logging while loading
  41968. */
  41969. static readonly DETAILED_LOGGING: number;
  41970. /**
  41971. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41972. */
  41973. static ForceFullSceneLoadingForIncremental: boolean;
  41974. /**
  41975. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41976. */
  41977. static ShowLoadingScreen: boolean;
  41978. /**
  41979. * Defines the current logging level (while loading the scene)
  41980. * @ignorenaming
  41981. */
  41982. static loggingLevel: number;
  41983. /**
  41984. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41985. */
  41986. static CleanBoneMatrixWeights: boolean;
  41987. /**
  41988. * Event raised when a plugin is used to load a scene
  41989. */
  41990. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41991. private static _registeredPlugins;
  41992. private static _getDefaultPlugin;
  41993. private static _getPluginForExtension;
  41994. private static _getPluginForDirectLoad;
  41995. private static _getPluginForFilename;
  41996. private static _getDirectLoad;
  41997. private static _loadData;
  41998. private static _getFileInfo;
  41999. /**
  42000. * Gets a plugin that can load the given extension
  42001. * @param extension defines the extension to load
  42002. * @returns a plugin or null if none works
  42003. */
  42004. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42005. /**
  42006. * Gets a boolean indicating that the given extension can be loaded
  42007. * @param extension defines the extension to load
  42008. * @returns true if the extension is supported
  42009. */
  42010. static IsPluginForExtensionAvailable(extension: string): boolean;
  42011. /**
  42012. * Adds a new plugin to the list of registered plugins
  42013. * @param plugin defines the plugin to add
  42014. */
  42015. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42016. /**
  42017. * Import meshes into a scene
  42018. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42019. * @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)
  42020. * @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)
  42021. * @param scene the instance of BABYLON.Scene to append to
  42022. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42023. * @param onProgress a callback with a progress event for each file being loaded
  42024. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42025. * @param pluginExtension the extension used to determine the plugin
  42026. * @returns The loaded plugin
  42027. */
  42028. 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>;
  42029. /**
  42030. * Import meshes into a scene
  42031. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42032. * @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)
  42033. * @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)
  42034. * @param scene the instance of BABYLON.Scene to append to
  42035. * @param onProgress a callback with a progress event for each file being loaded
  42036. * @param pluginExtension the extension used to determine the plugin
  42037. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42038. */
  42039. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42040. meshes: AbstractMesh[];
  42041. particleSystems: IParticleSystem[];
  42042. skeletons: Skeleton[];
  42043. animationGroups: AnimationGroup[];
  42044. }>;
  42045. /**
  42046. * Load a scene
  42047. * @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)
  42048. * @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)
  42049. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42050. * @param onSuccess a callback with the scene when import succeeds
  42051. * @param onProgress a callback with a progress event for each file being loaded
  42052. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42053. * @param pluginExtension the extension used to determine the plugin
  42054. * @returns The loaded plugin
  42055. */
  42056. 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>;
  42057. /**
  42058. * Load a scene
  42059. * @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)
  42060. * @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)
  42061. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42062. * @param onProgress a callback with a progress event for each file being loaded
  42063. * @param pluginExtension the extension used to determine the plugin
  42064. * @returns The loaded scene
  42065. */
  42066. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42067. /**
  42068. * Append a scene
  42069. * @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)
  42070. * @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)
  42071. * @param scene is the instance of BABYLON.Scene to append to
  42072. * @param onSuccess a callback with the scene when import succeeds
  42073. * @param onProgress a callback with a progress event for each file being loaded
  42074. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42075. * @param pluginExtension the extension used to determine the plugin
  42076. * @returns The loaded plugin
  42077. */
  42078. 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>;
  42079. /**
  42080. * Append a scene
  42081. * @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)
  42082. * @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)
  42083. * @param scene is the instance of BABYLON.Scene to append to
  42084. * @param onProgress a callback with a progress event for each file being loaded
  42085. * @param pluginExtension the extension used to determine the plugin
  42086. * @returns The given scene
  42087. */
  42088. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42089. /**
  42090. * Load a scene into an asset container
  42091. * @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)
  42092. * @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)
  42093. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42094. * @param onSuccess a callback with the scene when import succeeds
  42095. * @param onProgress a callback with a progress event for each file being loaded
  42096. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42097. * @param pluginExtension the extension used to determine the plugin
  42098. * @returns The loaded plugin
  42099. */
  42100. 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>;
  42101. /**
  42102. * Load a scene into an asset container
  42103. * @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)
  42104. * @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)
  42105. * @param scene is the instance of Scene to append to
  42106. * @param onProgress a callback with a progress event for each file being loaded
  42107. * @param pluginExtension the extension used to determine the plugin
  42108. * @returns The loaded asset container
  42109. */
  42110. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42111. }
  42112. }
  42113. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42114. import { Scene } from "babylonjs/scene";
  42115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42116. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42117. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42118. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42119. /**
  42120. * Google Daydream controller
  42121. */
  42122. export class DaydreamController extends WebVRController {
  42123. /**
  42124. * Base Url for the controller model.
  42125. */
  42126. static MODEL_BASE_URL: string;
  42127. /**
  42128. * File name for the controller model.
  42129. */
  42130. static MODEL_FILENAME: string;
  42131. /**
  42132. * Gamepad Id prefix used to identify Daydream Controller.
  42133. */
  42134. static readonly GAMEPAD_ID_PREFIX: string;
  42135. /**
  42136. * Creates a new DaydreamController from a gamepad
  42137. * @param vrGamepad the gamepad that the controller should be created from
  42138. */
  42139. constructor(vrGamepad: any);
  42140. /**
  42141. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42142. * @param scene scene in which to add meshes
  42143. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42144. */
  42145. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42146. /**
  42147. * Called once for each button that changed state since the last frame
  42148. * @param buttonIdx Which button index changed
  42149. * @param state New state of the button
  42150. * @param changes Which properties on the state changed since last frame
  42151. */
  42152. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42153. }
  42154. }
  42155. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42156. import { Scene } from "babylonjs/scene";
  42157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42158. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42159. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42160. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42161. /**
  42162. * Gear VR Controller
  42163. */
  42164. export class GearVRController extends WebVRController {
  42165. /**
  42166. * Base Url for the controller model.
  42167. */
  42168. static MODEL_BASE_URL: string;
  42169. /**
  42170. * File name for the controller model.
  42171. */
  42172. static MODEL_FILENAME: string;
  42173. /**
  42174. * Gamepad Id prefix used to identify this controller.
  42175. */
  42176. static readonly GAMEPAD_ID_PREFIX: string;
  42177. private readonly _buttonIndexToObservableNameMap;
  42178. /**
  42179. * Creates a new GearVRController from a gamepad
  42180. * @param vrGamepad the gamepad that the controller should be created from
  42181. */
  42182. constructor(vrGamepad: any);
  42183. /**
  42184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42185. * @param scene scene in which to add meshes
  42186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42187. */
  42188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42189. /**
  42190. * Called once for each button that changed state since the last frame
  42191. * @param buttonIdx Which button index changed
  42192. * @param state New state of the button
  42193. * @param changes Which properties on the state changed since last frame
  42194. */
  42195. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42196. }
  42197. }
  42198. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42199. import { Scene } from "babylonjs/scene";
  42200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42201. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42202. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42203. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42204. /**
  42205. * Generic Controller
  42206. */
  42207. export class GenericController extends WebVRController {
  42208. /**
  42209. * Base Url for the controller model.
  42210. */
  42211. static readonly MODEL_BASE_URL: string;
  42212. /**
  42213. * File name for the controller model.
  42214. */
  42215. static readonly MODEL_FILENAME: string;
  42216. /**
  42217. * Creates a new GenericController from a gamepad
  42218. * @param vrGamepad the gamepad that the controller should be created from
  42219. */
  42220. constructor(vrGamepad: any);
  42221. /**
  42222. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42223. * @param scene scene in which to add meshes
  42224. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42225. */
  42226. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42227. /**
  42228. * Called once for each button that changed state since the last frame
  42229. * @param buttonIdx Which button index changed
  42230. * @param state New state of the button
  42231. * @param changes Which properties on the state changed since last frame
  42232. */
  42233. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42234. }
  42235. }
  42236. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42237. import { Observable } from "babylonjs/Misc/observable";
  42238. import { Scene } from "babylonjs/scene";
  42239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42240. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42241. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42242. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42243. /**
  42244. * Oculus Touch Controller
  42245. */
  42246. export class OculusTouchController extends WebVRController {
  42247. /**
  42248. * Base Url for the controller model.
  42249. */
  42250. static MODEL_BASE_URL: string;
  42251. /**
  42252. * File name for the left controller model.
  42253. */
  42254. static MODEL_LEFT_FILENAME: string;
  42255. /**
  42256. * File name for the right controller model.
  42257. */
  42258. static MODEL_RIGHT_FILENAME: string;
  42259. /**
  42260. * Fired when the secondary trigger on this controller is modified
  42261. */
  42262. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42263. /**
  42264. * Fired when the thumb rest on this controller is modified
  42265. */
  42266. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42267. /**
  42268. * Creates a new OculusTouchController from a gamepad
  42269. * @param vrGamepad the gamepad that the controller should be created from
  42270. */
  42271. constructor(vrGamepad: any);
  42272. /**
  42273. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42274. * @param scene scene in which to add meshes
  42275. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42276. */
  42277. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42278. /**
  42279. * Fired when the A button on this controller is modified
  42280. */
  42281. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42282. /**
  42283. * Fired when the B button on this controller is modified
  42284. */
  42285. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42286. /**
  42287. * Fired when the X button on this controller is modified
  42288. */
  42289. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42290. /**
  42291. * Fired when the Y button on this controller is modified
  42292. */
  42293. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42294. /**
  42295. * Called once for each button that changed state since the last frame
  42296. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42297. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42298. * 2) secondary trigger (same)
  42299. * 3) A (right) X (left), touch, pressed = value
  42300. * 4) B / Y
  42301. * 5) thumb rest
  42302. * @param buttonIdx Which button index changed
  42303. * @param state New state of the button
  42304. * @param changes Which properties on the state changed since last frame
  42305. */
  42306. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42307. }
  42308. }
  42309. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42310. import { Scene } from "babylonjs/scene";
  42311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42312. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42313. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42314. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42315. import { Observable } from "babylonjs/Misc/observable";
  42316. /**
  42317. * Vive Controller
  42318. */
  42319. export class ViveController extends WebVRController {
  42320. /**
  42321. * Base Url for the controller model.
  42322. */
  42323. static MODEL_BASE_URL: string;
  42324. /**
  42325. * File name for the controller model.
  42326. */
  42327. static MODEL_FILENAME: string;
  42328. /**
  42329. * Creates a new ViveController from a gamepad
  42330. * @param vrGamepad the gamepad that the controller should be created from
  42331. */
  42332. constructor(vrGamepad: any);
  42333. /**
  42334. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42335. * @param scene scene in which to add meshes
  42336. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42337. */
  42338. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42339. /**
  42340. * Fired when the left button on this controller is modified
  42341. */
  42342. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42343. /**
  42344. * Fired when the right button on this controller is modified
  42345. */
  42346. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42347. /**
  42348. * Fired when the menu button on this controller is modified
  42349. */
  42350. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42351. /**
  42352. * Called once for each button that changed state since the last frame
  42353. * Vive mapping:
  42354. * 0: touchpad
  42355. * 1: trigger
  42356. * 2: left AND right buttons
  42357. * 3: menu button
  42358. * @param buttonIdx Which button index changed
  42359. * @param state New state of the button
  42360. * @param changes Which properties on the state changed since last frame
  42361. */
  42362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42363. }
  42364. }
  42365. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42366. import { Observable } from "babylonjs/Misc/observable";
  42367. import { Scene } from "babylonjs/scene";
  42368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42369. import { Ray } from "babylonjs/Culling/ray";
  42370. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42371. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42372. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42373. /**
  42374. * Defines the WindowsMotionController object that the state of the windows motion controller
  42375. */
  42376. export class WindowsMotionController extends WebVRController {
  42377. /**
  42378. * The base url used to load the left and right controller models
  42379. */
  42380. static MODEL_BASE_URL: string;
  42381. /**
  42382. * The name of the left controller model file
  42383. */
  42384. static MODEL_LEFT_FILENAME: string;
  42385. /**
  42386. * The name of the right controller model file
  42387. */
  42388. static MODEL_RIGHT_FILENAME: string;
  42389. /**
  42390. * The controller name prefix for this controller type
  42391. */
  42392. static readonly GAMEPAD_ID_PREFIX: string;
  42393. /**
  42394. * The controller id pattern for this controller type
  42395. */
  42396. private static readonly GAMEPAD_ID_PATTERN;
  42397. private _loadedMeshInfo;
  42398. private readonly _mapping;
  42399. /**
  42400. * Fired when the trackpad on this controller is clicked
  42401. */
  42402. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42403. /**
  42404. * Fired when the trackpad on this controller is modified
  42405. */
  42406. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42407. /**
  42408. * The current x and y values of this controller's trackpad
  42409. */
  42410. trackpad: StickValues;
  42411. /**
  42412. * Creates a new WindowsMotionController from a gamepad
  42413. * @param vrGamepad the gamepad that the controller should be created from
  42414. */
  42415. constructor(vrGamepad: any);
  42416. /**
  42417. * Fired when the trigger on this controller is modified
  42418. */
  42419. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42420. /**
  42421. * Fired when the menu button on this controller is modified
  42422. */
  42423. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42424. /**
  42425. * Fired when the grip button on this controller is modified
  42426. */
  42427. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42428. /**
  42429. * Fired when the thumbstick button on this controller is modified
  42430. */
  42431. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42432. /**
  42433. * Fired when the touchpad button on this controller is modified
  42434. */
  42435. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42436. /**
  42437. * Fired when the touchpad values on this controller are modified
  42438. */
  42439. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42440. private _updateTrackpad;
  42441. /**
  42442. * Called once per frame by the engine.
  42443. */
  42444. update(): void;
  42445. /**
  42446. * Called once for each button that changed state since the last frame
  42447. * @param buttonIdx Which button index changed
  42448. * @param state New state of the button
  42449. * @param changes Which properties on the state changed since last frame
  42450. */
  42451. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42452. /**
  42453. * Moves the buttons on the controller mesh based on their current state
  42454. * @param buttonName the name of the button to move
  42455. * @param buttonValue the value of the button which determines the buttons new position
  42456. */
  42457. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42458. /**
  42459. * Moves the axis on the controller mesh based on its current state
  42460. * @param axis the index of the axis
  42461. * @param axisValue the value of the axis which determines the meshes new position
  42462. * @hidden
  42463. */
  42464. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42465. /**
  42466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42467. * @param scene scene in which to add meshes
  42468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42469. */
  42470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42471. /**
  42472. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42473. * can be transformed by button presses and axes values, based on this._mapping.
  42474. *
  42475. * @param scene scene in which the meshes exist
  42476. * @param meshes list of meshes that make up the controller model to process
  42477. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42478. */
  42479. private processModel;
  42480. private createMeshInfo;
  42481. /**
  42482. * Gets the ray of the controller in the direction the controller is pointing
  42483. * @param length the length the resulting ray should be
  42484. * @returns a ray in the direction the controller is pointing
  42485. */
  42486. getForwardRay(length?: number): Ray;
  42487. /**
  42488. * Disposes of the controller
  42489. */
  42490. dispose(): void;
  42491. }
  42492. }
  42493. declare module "babylonjs/Gamepads/Controllers/index" {
  42494. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42495. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42496. export * from "babylonjs/Gamepads/Controllers/genericController";
  42497. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42498. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42499. export * from "babylonjs/Gamepads/Controllers/viveController";
  42500. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42501. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42502. }
  42503. declare module "babylonjs/Gamepads/index" {
  42504. export * from "babylonjs/Gamepads/Controllers/index";
  42505. export * from "babylonjs/Gamepads/gamepad";
  42506. export * from "babylonjs/Gamepads/gamepadManager";
  42507. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42508. export * from "babylonjs/Gamepads/xboxGamepad";
  42509. }
  42510. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42511. import { Observable } from "babylonjs/Misc/observable";
  42512. import { Nullable } from "babylonjs/types";
  42513. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42515. import { Mesh } from "babylonjs/Meshes/mesh";
  42516. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42517. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42518. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42519. /**
  42520. * Single axis scale gizmo
  42521. */
  42522. export class AxisScaleGizmo extends Gizmo {
  42523. private _coloredMaterial;
  42524. /**
  42525. * Drag behavior responsible for the gizmos dragging interactions
  42526. */
  42527. dragBehavior: PointerDragBehavior;
  42528. private _pointerObserver;
  42529. /**
  42530. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42531. */
  42532. snapDistance: number;
  42533. /**
  42534. * Event that fires each time the gizmo snaps to a new location.
  42535. * * snapDistance is the the change in distance
  42536. */
  42537. onSnapObservable: Observable<{
  42538. snapDistance: number;
  42539. }>;
  42540. /**
  42541. * If the scaling operation should be done on all axis (default: false)
  42542. */
  42543. uniformScaling: boolean;
  42544. /**
  42545. * Creates an AxisScaleGizmo
  42546. * @param gizmoLayer The utility layer the gizmo will be added to
  42547. * @param dragAxis The axis which the gizmo will be able to scale on
  42548. * @param color The color of the gizmo
  42549. */
  42550. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42551. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42552. /**
  42553. * Disposes of the gizmo
  42554. */
  42555. dispose(): void;
  42556. /**
  42557. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42558. * @param mesh The mesh to replace the default mesh of the gizmo
  42559. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42560. */
  42561. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42562. }
  42563. }
  42564. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42565. import { Observable } from "babylonjs/Misc/observable";
  42566. import { Nullable } from "babylonjs/types";
  42567. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42569. import { Mesh } from "babylonjs/Meshes/mesh";
  42570. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42571. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42572. import "babylonjs/Meshes/Builders/boxBuilder";
  42573. /**
  42574. * Bounding box gizmo
  42575. */
  42576. export class BoundingBoxGizmo extends Gizmo {
  42577. private _lineBoundingBox;
  42578. private _rotateSpheresParent;
  42579. private _scaleBoxesParent;
  42580. private _boundingDimensions;
  42581. private _renderObserver;
  42582. private _pointerObserver;
  42583. private _scaleDragSpeed;
  42584. private _tmpQuaternion;
  42585. private _tmpVector;
  42586. private _tmpRotationMatrix;
  42587. /**
  42588. * 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)
  42589. */
  42590. ignoreChildren: boolean;
  42591. /**
  42592. * 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)
  42593. */
  42594. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42595. /**
  42596. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42597. */
  42598. rotationSphereSize: number;
  42599. /**
  42600. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42601. */
  42602. scaleBoxSize: number;
  42603. /**
  42604. * 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)
  42605. */
  42606. fixedDragMeshScreenSize: boolean;
  42607. /**
  42608. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42609. */
  42610. fixedDragMeshScreenSizeDistanceFactor: number;
  42611. /**
  42612. * Fired when a rotation sphere or scale box is dragged
  42613. */
  42614. onDragStartObservable: Observable<{}>;
  42615. /**
  42616. * Fired when a scale box is dragged
  42617. */
  42618. onScaleBoxDragObservable: Observable<{}>;
  42619. /**
  42620. * Fired when a scale box drag is ended
  42621. */
  42622. onScaleBoxDragEndObservable: Observable<{}>;
  42623. /**
  42624. * Fired when a rotation sphere is dragged
  42625. */
  42626. onRotationSphereDragObservable: Observable<{}>;
  42627. /**
  42628. * Fired when a rotation sphere drag is ended
  42629. */
  42630. onRotationSphereDragEndObservable: Observable<{}>;
  42631. /**
  42632. * 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)
  42633. */
  42634. scalePivot: Nullable<Vector3>;
  42635. private _anchorMesh;
  42636. private _existingMeshScale;
  42637. private _dragMesh;
  42638. private pointerDragBehavior;
  42639. /**
  42640. * Creates an BoundingBoxGizmo
  42641. * @param gizmoLayer The utility layer the gizmo will be added to
  42642. * @param color The color of the gizmo
  42643. */
  42644. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42645. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42646. private _selectNode;
  42647. /**
  42648. * Updates the bounding box information for the Gizmo
  42649. */
  42650. updateBoundingBox(): void;
  42651. private _updateRotationSpheres;
  42652. private _updateScaleBoxes;
  42653. /**
  42654. * Enables rotation on the specified axis and disables rotation on the others
  42655. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42656. */
  42657. setEnabledRotationAxis(axis: string): void;
  42658. /**
  42659. * Enables/disables scaling
  42660. * @param enable if scaling should be enabled
  42661. */
  42662. setEnabledScaling(enable: boolean): void;
  42663. private _updateDummy;
  42664. /**
  42665. * Enables a pointer drag behavior on the bounding box of the gizmo
  42666. */
  42667. enableDragBehavior(): void;
  42668. /**
  42669. * Disposes of the gizmo
  42670. */
  42671. dispose(): void;
  42672. /**
  42673. * 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)
  42674. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42675. * @returns the bounding box mesh with the passed in mesh as a child
  42676. */
  42677. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42678. /**
  42679. * CustomMeshes are not supported by this gizmo
  42680. * @param mesh The mesh to replace the default mesh of the gizmo
  42681. */
  42682. setCustomMesh(mesh: Mesh): void;
  42683. }
  42684. }
  42685. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42686. import { Observable } from "babylonjs/Misc/observable";
  42687. import { Nullable } from "babylonjs/types";
  42688. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42690. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42691. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42692. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42693. import "babylonjs/Meshes/Builders/linesBuilder";
  42694. /**
  42695. * Single plane rotation gizmo
  42696. */
  42697. export class PlaneRotationGizmo extends Gizmo {
  42698. /**
  42699. * Drag behavior responsible for the gizmos dragging interactions
  42700. */
  42701. dragBehavior: PointerDragBehavior;
  42702. private _pointerObserver;
  42703. /**
  42704. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42705. */
  42706. snapDistance: number;
  42707. /**
  42708. * Event that fires each time the gizmo snaps to a new location.
  42709. * * snapDistance is the the change in distance
  42710. */
  42711. onSnapObservable: Observable<{
  42712. snapDistance: number;
  42713. }>;
  42714. /**
  42715. * Creates a PlaneRotationGizmo
  42716. * @param gizmoLayer The utility layer the gizmo will be added to
  42717. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42718. * @param color The color of the gizmo
  42719. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42720. */
  42721. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42722. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42723. /**
  42724. * Disposes of the gizmo
  42725. */
  42726. dispose(): void;
  42727. }
  42728. }
  42729. declare module "babylonjs/Gizmos/rotationGizmo" {
  42730. import { Observable } from "babylonjs/Misc/observable";
  42731. import { Nullable } from "babylonjs/types";
  42732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42733. import { Mesh } from "babylonjs/Meshes/mesh";
  42734. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42735. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42736. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42737. /**
  42738. * Gizmo that enables rotating a mesh along 3 axis
  42739. */
  42740. export class RotationGizmo extends Gizmo {
  42741. /**
  42742. * Internal gizmo used for interactions on the x axis
  42743. */
  42744. xGizmo: PlaneRotationGizmo;
  42745. /**
  42746. * Internal gizmo used for interactions on the y axis
  42747. */
  42748. yGizmo: PlaneRotationGizmo;
  42749. /**
  42750. * Internal gizmo used for interactions on the z axis
  42751. */
  42752. zGizmo: PlaneRotationGizmo;
  42753. /** Fires an event when any of it's sub gizmos are dragged */
  42754. onDragStartObservable: Observable<{}>;
  42755. /** Fires an event when any of it's sub gizmos are released from dragging */
  42756. onDragEndObservable: Observable<{}>;
  42757. attachedMesh: Nullable<AbstractMesh>;
  42758. /**
  42759. * Creates a RotationGizmo
  42760. * @param gizmoLayer The utility layer the gizmo will be added to
  42761. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42762. */
  42763. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42764. updateGizmoRotationToMatchAttachedMesh: boolean;
  42765. /**
  42766. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42767. */
  42768. snapDistance: number;
  42769. /**
  42770. * Ratio for the scale of the gizmo (Default: 1)
  42771. */
  42772. scaleRatio: number;
  42773. /**
  42774. * Disposes of the gizmo
  42775. */
  42776. dispose(): void;
  42777. /**
  42778. * CustomMeshes are not supported by this gizmo
  42779. * @param mesh The mesh to replace the default mesh of the gizmo
  42780. */
  42781. setCustomMesh(mesh: Mesh): void;
  42782. }
  42783. }
  42784. declare module "babylonjs/Gizmos/positionGizmo" {
  42785. import { Observable } from "babylonjs/Misc/observable";
  42786. import { Nullable } from "babylonjs/types";
  42787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42788. import { Mesh } from "babylonjs/Meshes/mesh";
  42789. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42790. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42791. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42792. /**
  42793. * Gizmo that enables dragging a mesh along 3 axis
  42794. */
  42795. export class PositionGizmo extends Gizmo {
  42796. /**
  42797. * Internal gizmo used for interactions on the x axis
  42798. */
  42799. xGizmo: AxisDragGizmo;
  42800. /**
  42801. * Internal gizmo used for interactions on the y axis
  42802. */
  42803. yGizmo: AxisDragGizmo;
  42804. /**
  42805. * Internal gizmo used for interactions on the z axis
  42806. */
  42807. zGizmo: AxisDragGizmo;
  42808. /** Fires an event when any of it's sub gizmos are dragged */
  42809. onDragStartObservable: Observable<{}>;
  42810. /** Fires an event when any of it's sub gizmos are released from dragging */
  42811. onDragEndObservable: Observable<{}>;
  42812. attachedMesh: Nullable<AbstractMesh>;
  42813. /**
  42814. * Creates a PositionGizmo
  42815. * @param gizmoLayer The utility layer the gizmo will be added to
  42816. */
  42817. constructor(gizmoLayer?: UtilityLayerRenderer);
  42818. updateGizmoRotationToMatchAttachedMesh: boolean;
  42819. /**
  42820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42821. */
  42822. snapDistance: number;
  42823. /**
  42824. * Ratio for the scale of the gizmo (Default: 1)
  42825. */
  42826. scaleRatio: number;
  42827. /**
  42828. * Disposes of the gizmo
  42829. */
  42830. dispose(): void;
  42831. /**
  42832. * CustomMeshes are not supported by this gizmo
  42833. * @param mesh The mesh to replace the default mesh of the gizmo
  42834. */
  42835. setCustomMesh(mesh: Mesh): void;
  42836. }
  42837. }
  42838. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42839. import { Scene } from "babylonjs/scene";
  42840. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42841. import { Mesh } from "babylonjs/Meshes/mesh";
  42842. /**
  42843. * Class containing static functions to help procedurally build meshes
  42844. */
  42845. export class PolyhedronBuilder {
  42846. /**
  42847. * Creates a polyhedron mesh
  42848. * * 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
  42849. * * The parameter `size` (positive float, default 1) sets the polygon size
  42850. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42851. * * 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`
  42852. * * 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
  42853. * * 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)`)
  42854. * * 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
  42855. * * 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
  42856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42859. * @param name defines the name of the mesh
  42860. * @param options defines the options used to create the mesh
  42861. * @param scene defines the hosting scene
  42862. * @returns the polyhedron mesh
  42863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42864. */
  42865. static CreatePolyhedron(name: string, options: {
  42866. type?: number;
  42867. size?: number;
  42868. sizeX?: number;
  42869. sizeY?: number;
  42870. sizeZ?: number;
  42871. custom?: any;
  42872. faceUV?: Vector4[];
  42873. faceColors?: Color4[];
  42874. flat?: boolean;
  42875. updatable?: boolean;
  42876. sideOrientation?: number;
  42877. frontUVs?: Vector4;
  42878. backUVs?: Vector4;
  42879. }, scene: Scene): Mesh;
  42880. }
  42881. }
  42882. declare module "babylonjs/Gizmos/scaleGizmo" {
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { Nullable } from "babylonjs/types";
  42885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42886. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42887. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42888. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42889. /**
  42890. * Gizmo that enables scaling a mesh along 3 axis
  42891. */
  42892. export class ScaleGizmo extends Gizmo {
  42893. /**
  42894. * Internal gizmo used for interactions on the x axis
  42895. */
  42896. xGizmo: AxisScaleGizmo;
  42897. /**
  42898. * Internal gizmo used for interactions on the y axis
  42899. */
  42900. yGizmo: AxisScaleGizmo;
  42901. /**
  42902. * Internal gizmo used for interactions on the z axis
  42903. */
  42904. zGizmo: AxisScaleGizmo;
  42905. /**
  42906. * Internal gizmo used to scale all axis equally
  42907. */
  42908. uniformScaleGizmo: AxisScaleGizmo;
  42909. /** Fires an event when any of it's sub gizmos are dragged */
  42910. onDragStartObservable: Observable<{}>;
  42911. /** Fires an event when any of it's sub gizmos are released from dragging */
  42912. onDragEndObservable: Observable<{}>;
  42913. attachedMesh: Nullable<AbstractMesh>;
  42914. /**
  42915. * Creates a ScaleGizmo
  42916. * @param gizmoLayer The utility layer the gizmo will be added to
  42917. */
  42918. constructor(gizmoLayer?: UtilityLayerRenderer);
  42919. updateGizmoRotationToMatchAttachedMesh: boolean;
  42920. /**
  42921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42922. */
  42923. snapDistance: number;
  42924. /**
  42925. * Ratio for the scale of the gizmo (Default: 1)
  42926. */
  42927. scaleRatio: number;
  42928. /**
  42929. * Disposes of the gizmo
  42930. */
  42931. dispose(): void;
  42932. }
  42933. }
  42934. declare module "babylonjs/Gizmos/gizmoManager" {
  42935. import { Observable } from "babylonjs/Misc/observable";
  42936. import { Nullable } from "babylonjs/types";
  42937. import { Scene, IDisposable } from "babylonjs/scene";
  42938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42939. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42940. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42941. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42942. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  42943. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  42944. /**
  42945. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42946. */
  42947. export class GizmoManager implements IDisposable {
  42948. private scene;
  42949. /**
  42950. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42951. */
  42952. gizmos: {
  42953. positionGizmo: Nullable<PositionGizmo>;
  42954. rotationGizmo: Nullable<RotationGizmo>;
  42955. scaleGizmo: Nullable<ScaleGizmo>;
  42956. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42957. };
  42958. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42959. clearGizmoOnEmptyPointerEvent: boolean;
  42960. /** Fires an event when the manager is attached to a mesh */
  42961. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42962. private _gizmosEnabled;
  42963. private _pointerObserver;
  42964. private _attachedMesh;
  42965. private _boundingBoxColor;
  42966. private _defaultUtilityLayer;
  42967. private _defaultKeepDepthUtilityLayer;
  42968. /**
  42969. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42970. */
  42971. boundingBoxDragBehavior: SixDofDragBehavior;
  42972. /**
  42973. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42974. */
  42975. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42976. /**
  42977. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42978. */
  42979. usePointerToAttachGizmos: boolean;
  42980. /**
  42981. * Instatiates a gizmo manager
  42982. * @param scene the scene to overlay the gizmos on top of
  42983. */
  42984. constructor(scene: Scene);
  42985. /**
  42986. * Attaches a set of gizmos to the specified mesh
  42987. * @param mesh The mesh the gizmo's should be attached to
  42988. */
  42989. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42990. /**
  42991. * If the position gizmo is enabled
  42992. */
  42993. positionGizmoEnabled: boolean;
  42994. /**
  42995. * If the rotation gizmo is enabled
  42996. */
  42997. rotationGizmoEnabled: boolean;
  42998. /**
  42999. * If the scale gizmo is enabled
  43000. */
  43001. scaleGizmoEnabled: boolean;
  43002. /**
  43003. * If the boundingBox gizmo is enabled
  43004. */
  43005. boundingBoxGizmoEnabled: boolean;
  43006. /**
  43007. * Disposes of the gizmo manager
  43008. */
  43009. dispose(): void;
  43010. }
  43011. }
  43012. declare module "babylonjs/Gizmos/lightGizmo" {
  43013. import { Nullable } from "babylonjs/types";
  43014. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43015. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43016. import { Light } from "babylonjs/Lights/light";
  43017. /**
  43018. * Gizmo that enables viewing a light
  43019. */
  43020. export class LightGizmo extends Gizmo {
  43021. private _box;
  43022. /**
  43023. * Creates a LightGizmo
  43024. * @param gizmoLayer The utility layer the gizmo will be added to
  43025. */
  43026. constructor(gizmoLayer?: UtilityLayerRenderer);
  43027. private _light;
  43028. /**
  43029. * The light that the gizmo is attached to
  43030. */
  43031. light: Nullable<Light>;
  43032. /**
  43033. * @hidden
  43034. * Updates the gizmo to match the attached mesh's position/rotation
  43035. */
  43036. protected _update(): void;
  43037. }
  43038. }
  43039. declare module "babylonjs/Gizmos/index" {
  43040. export * from "babylonjs/Gizmos/axisDragGizmo";
  43041. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43042. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43043. export * from "babylonjs/Gizmos/gizmo";
  43044. export * from "babylonjs/Gizmos/gizmoManager";
  43045. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43046. export * from "babylonjs/Gizmos/positionGizmo";
  43047. export * from "babylonjs/Gizmos/rotationGizmo";
  43048. export * from "babylonjs/Gizmos/scaleGizmo";
  43049. export * from "babylonjs/Gizmos/lightGizmo";
  43050. }
  43051. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43052. /** @hidden */
  43053. export var backgroundFragmentDeclaration: {
  43054. name: string;
  43055. shader: string;
  43056. };
  43057. }
  43058. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43059. /** @hidden */
  43060. export var backgroundUboDeclaration: {
  43061. name: string;
  43062. shader: string;
  43063. };
  43064. }
  43065. declare module "babylonjs/Shaders/background.fragment" {
  43066. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43067. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43068. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43069. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43070. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43071. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43072. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43073. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43074. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43075. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43076. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43077. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43078. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43079. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43080. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43081. /** @hidden */
  43082. export var backgroundPixelShader: {
  43083. name: string;
  43084. shader: string;
  43085. };
  43086. }
  43087. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43088. /** @hidden */
  43089. export var backgroundVertexDeclaration: {
  43090. name: string;
  43091. shader: string;
  43092. };
  43093. }
  43094. declare module "babylonjs/Shaders/background.vertex" {
  43095. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43096. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43098. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43100. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43101. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43102. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43103. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43104. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43105. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43106. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43107. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43108. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43109. /** @hidden */
  43110. export var backgroundVertexShader: {
  43111. name: string;
  43112. shader: string;
  43113. };
  43114. }
  43115. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43116. import { Nullable, int, float } from "babylonjs/types";
  43117. import { Scene } from "babylonjs/scene";
  43118. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43119. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43121. import { Mesh } from "babylonjs/Meshes/mesh";
  43122. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43123. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43124. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43126. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43127. import "babylonjs/Shaders/background.fragment";
  43128. import "babylonjs/Shaders/background.vertex";
  43129. /**
  43130. * Background material used to create an efficient environement around your scene.
  43131. */
  43132. export class BackgroundMaterial extends PushMaterial {
  43133. /**
  43134. * Standard reflectance value at parallel view angle.
  43135. */
  43136. static StandardReflectance0: number;
  43137. /**
  43138. * Standard reflectance value at grazing angle.
  43139. */
  43140. static StandardReflectance90: number;
  43141. protected _primaryColor: Color3;
  43142. /**
  43143. * Key light Color (multiply against the environement texture)
  43144. */
  43145. primaryColor: Color3;
  43146. protected __perceptualColor: Nullable<Color3>;
  43147. /**
  43148. * Experimental Internal Use Only.
  43149. *
  43150. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43151. * This acts as a helper to set the primary color to a more "human friendly" value.
  43152. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43153. * output color as close as possible from the chosen value.
  43154. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43155. * part of lighting setup.)
  43156. */
  43157. _perceptualColor: Nullable<Color3>;
  43158. protected _primaryColorShadowLevel: float;
  43159. /**
  43160. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43161. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43162. */
  43163. primaryColorShadowLevel: float;
  43164. protected _primaryColorHighlightLevel: float;
  43165. /**
  43166. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43167. * The primary color is used at the level chosen to define what the white area would look.
  43168. */
  43169. primaryColorHighlightLevel: float;
  43170. protected _reflectionTexture: Nullable<BaseTexture>;
  43171. /**
  43172. * Reflection Texture used in the material.
  43173. * Should be author in a specific way for the best result (refer to the documentation).
  43174. */
  43175. reflectionTexture: Nullable<BaseTexture>;
  43176. protected _reflectionBlur: float;
  43177. /**
  43178. * Reflection Texture level of blur.
  43179. *
  43180. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43181. * texture twice.
  43182. */
  43183. reflectionBlur: float;
  43184. protected _diffuseTexture: Nullable<BaseTexture>;
  43185. /**
  43186. * Diffuse Texture used in the material.
  43187. * Should be author in a specific way for the best result (refer to the documentation).
  43188. */
  43189. diffuseTexture: Nullable<BaseTexture>;
  43190. protected _shadowLights: Nullable<IShadowLight[]>;
  43191. /**
  43192. * Specify the list of lights casting shadow on the material.
  43193. * All scene shadow lights will be included if null.
  43194. */
  43195. shadowLights: Nullable<IShadowLight[]>;
  43196. protected _shadowLevel: float;
  43197. /**
  43198. * Helps adjusting the shadow to a softer level if required.
  43199. * 0 means black shadows and 1 means no shadows.
  43200. */
  43201. shadowLevel: float;
  43202. protected _sceneCenter: Vector3;
  43203. /**
  43204. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43205. * It is usually zero but might be interesting to modify according to your setup.
  43206. */
  43207. sceneCenter: Vector3;
  43208. protected _opacityFresnel: boolean;
  43209. /**
  43210. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43211. * This helps ensuring a nice transition when the camera goes under the ground.
  43212. */
  43213. opacityFresnel: boolean;
  43214. protected _reflectionFresnel: boolean;
  43215. /**
  43216. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43217. * This helps adding a mirror texture on the ground.
  43218. */
  43219. reflectionFresnel: boolean;
  43220. protected _reflectionFalloffDistance: number;
  43221. /**
  43222. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43223. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43224. */
  43225. reflectionFalloffDistance: number;
  43226. protected _reflectionAmount: number;
  43227. /**
  43228. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43229. */
  43230. reflectionAmount: number;
  43231. protected _reflectionReflectance0: number;
  43232. /**
  43233. * This specifies the weight of the reflection at grazing angle.
  43234. */
  43235. reflectionReflectance0: number;
  43236. protected _reflectionReflectance90: number;
  43237. /**
  43238. * This specifies the weight of the reflection at a perpendicular point of view.
  43239. */
  43240. reflectionReflectance90: number;
  43241. /**
  43242. * Sets the reflection reflectance fresnel values according to the default standard
  43243. * empirically know to work well :-)
  43244. */
  43245. reflectionStandardFresnelWeight: number;
  43246. protected _useRGBColor: boolean;
  43247. /**
  43248. * Helps to directly use the maps channels instead of their level.
  43249. */
  43250. useRGBColor: boolean;
  43251. protected _enableNoise: boolean;
  43252. /**
  43253. * This helps reducing the banding effect that could occur on the background.
  43254. */
  43255. enableNoise: boolean;
  43256. /**
  43257. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43258. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43259. * Recommended to be keep at 1.0 except for special cases.
  43260. */
  43261. fovMultiplier: number;
  43262. private _fovMultiplier;
  43263. /**
  43264. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43265. */
  43266. useEquirectangularFOV: boolean;
  43267. private _maxSimultaneousLights;
  43268. /**
  43269. * Number of Simultaneous lights allowed on the material.
  43270. */
  43271. maxSimultaneousLights: int;
  43272. /**
  43273. * Default configuration related to image processing available in the Background Material.
  43274. */
  43275. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43276. /**
  43277. * Keep track of the image processing observer to allow dispose and replace.
  43278. */
  43279. private _imageProcessingObserver;
  43280. /**
  43281. * Attaches a new image processing configuration to the PBR Material.
  43282. * @param configuration (if null the scene configuration will be use)
  43283. */
  43284. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43285. /**
  43286. * Gets the image processing configuration used either in this material.
  43287. */
  43288. /**
  43289. * Sets the Default image processing configuration used either in the this material.
  43290. *
  43291. * If sets to null, the scene one is in use.
  43292. */
  43293. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43294. /**
  43295. * Gets wether the color curves effect is enabled.
  43296. */
  43297. /**
  43298. * Sets wether the color curves effect is enabled.
  43299. */
  43300. cameraColorCurvesEnabled: boolean;
  43301. /**
  43302. * Gets wether the color grading effect is enabled.
  43303. */
  43304. /**
  43305. * Gets wether the color grading effect is enabled.
  43306. */
  43307. cameraColorGradingEnabled: boolean;
  43308. /**
  43309. * Gets wether tonemapping is enabled or not.
  43310. */
  43311. /**
  43312. * Sets wether tonemapping is enabled or not
  43313. */
  43314. cameraToneMappingEnabled: boolean;
  43315. /**
  43316. * The camera exposure used on this material.
  43317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43318. * This corresponds to a photographic exposure.
  43319. */
  43320. /**
  43321. * The camera exposure used on this material.
  43322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43323. * This corresponds to a photographic exposure.
  43324. */
  43325. cameraExposure: float;
  43326. /**
  43327. * Gets The camera contrast used on this material.
  43328. */
  43329. /**
  43330. * Sets The camera contrast used on this material.
  43331. */
  43332. cameraContrast: float;
  43333. /**
  43334. * Gets the Color Grading 2D Lookup Texture.
  43335. */
  43336. /**
  43337. * Sets the Color Grading 2D Lookup Texture.
  43338. */
  43339. cameraColorGradingTexture: Nullable<BaseTexture>;
  43340. /**
  43341. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43342. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43343. * 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;
  43344. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43345. */
  43346. /**
  43347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43349. * 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;
  43350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43351. */
  43352. cameraColorCurves: Nullable<ColorCurves>;
  43353. /**
  43354. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43355. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43356. */
  43357. switchToBGR: boolean;
  43358. private _renderTargets;
  43359. private _reflectionControls;
  43360. private _white;
  43361. private _primaryShadowColor;
  43362. private _primaryHighlightColor;
  43363. /**
  43364. * Instantiates a Background Material in the given scene
  43365. * @param name The friendly name of the material
  43366. * @param scene The scene to add the material to
  43367. */
  43368. constructor(name: string, scene: Scene);
  43369. /**
  43370. * Gets a boolean indicating that current material needs to register RTT
  43371. */
  43372. readonly hasRenderTargetTextures: boolean;
  43373. /**
  43374. * The entire material has been created in order to prevent overdraw.
  43375. * @returns false
  43376. */
  43377. needAlphaTesting(): boolean;
  43378. /**
  43379. * The entire material has been created in order to prevent overdraw.
  43380. * @returns true if blending is enable
  43381. */
  43382. needAlphaBlending(): boolean;
  43383. /**
  43384. * Checks wether the material is ready to be rendered for a given mesh.
  43385. * @param mesh The mesh to render
  43386. * @param subMesh The submesh to check against
  43387. * @param useInstances Specify wether or not the material is used with instances
  43388. * @returns true if all the dependencies are ready (Textures, Effects...)
  43389. */
  43390. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43391. /**
  43392. * Compute the primary color according to the chosen perceptual color.
  43393. */
  43394. private _computePrimaryColorFromPerceptualColor;
  43395. /**
  43396. * Compute the highlights and shadow colors according to their chosen levels.
  43397. */
  43398. private _computePrimaryColors;
  43399. /**
  43400. * Build the uniform buffer used in the material.
  43401. */
  43402. buildUniformLayout(): void;
  43403. /**
  43404. * Unbind the material.
  43405. */
  43406. unbind(): void;
  43407. /**
  43408. * Bind only the world matrix to the material.
  43409. * @param world The world matrix to bind.
  43410. */
  43411. bindOnlyWorldMatrix(world: Matrix): void;
  43412. /**
  43413. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43414. * @param world The world matrix to bind.
  43415. * @param subMesh The submesh to bind for.
  43416. */
  43417. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43418. /**
  43419. * Dispose the material.
  43420. * @param forceDisposeEffect Force disposal of the associated effect.
  43421. * @param forceDisposeTextures Force disposal of the associated textures.
  43422. */
  43423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43424. /**
  43425. * Clones the material.
  43426. * @param name The cloned name.
  43427. * @returns The cloned material.
  43428. */
  43429. clone(name: string): BackgroundMaterial;
  43430. /**
  43431. * Serializes the current material to its JSON representation.
  43432. * @returns The JSON representation.
  43433. */
  43434. serialize(): any;
  43435. /**
  43436. * Gets the class name of the material
  43437. * @returns "BackgroundMaterial"
  43438. */
  43439. getClassName(): string;
  43440. /**
  43441. * Parse a JSON input to create back a background material.
  43442. * @param source The JSON data to parse
  43443. * @param scene The scene to create the parsed material in
  43444. * @param rootUrl The root url of the assets the material depends upon
  43445. * @returns the instantiated BackgroundMaterial.
  43446. */
  43447. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43448. }
  43449. }
  43450. declare module "babylonjs/Helpers/environmentHelper" {
  43451. import { Observable } from "babylonjs/Misc/observable";
  43452. import { Nullable } from "babylonjs/types";
  43453. import { Scene } from "babylonjs/scene";
  43454. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43456. import { Mesh } from "babylonjs/Meshes/mesh";
  43457. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43458. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43459. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43460. import "babylonjs/Meshes/Builders/planeBuilder";
  43461. import "babylonjs/Meshes/Builders/boxBuilder";
  43462. /**
  43463. * Represents the different options available during the creation of
  43464. * a Environment helper.
  43465. *
  43466. * This can control the default ground, skybox and image processing setup of your scene.
  43467. */
  43468. export interface IEnvironmentHelperOptions {
  43469. /**
  43470. * Specifies wether or not to create a ground.
  43471. * True by default.
  43472. */
  43473. createGround: boolean;
  43474. /**
  43475. * Specifies the ground size.
  43476. * 15 by default.
  43477. */
  43478. groundSize: number;
  43479. /**
  43480. * The texture used on the ground for the main color.
  43481. * Comes from the BabylonJS CDN by default.
  43482. *
  43483. * Remarks: Can be either a texture or a url.
  43484. */
  43485. groundTexture: string | BaseTexture;
  43486. /**
  43487. * The color mixed in the ground texture by default.
  43488. * BabylonJS clearColor by default.
  43489. */
  43490. groundColor: Color3;
  43491. /**
  43492. * Specifies the ground opacity.
  43493. * 1 by default.
  43494. */
  43495. groundOpacity: number;
  43496. /**
  43497. * Enables the ground to receive shadows.
  43498. * True by default.
  43499. */
  43500. enableGroundShadow: boolean;
  43501. /**
  43502. * Helps preventing the shadow to be fully black on the ground.
  43503. * 0.5 by default.
  43504. */
  43505. groundShadowLevel: number;
  43506. /**
  43507. * Creates a mirror texture attach to the ground.
  43508. * false by default.
  43509. */
  43510. enableGroundMirror: boolean;
  43511. /**
  43512. * Specifies the ground mirror size ratio.
  43513. * 0.3 by default as the default kernel is 64.
  43514. */
  43515. groundMirrorSizeRatio: number;
  43516. /**
  43517. * Specifies the ground mirror blur kernel size.
  43518. * 64 by default.
  43519. */
  43520. groundMirrorBlurKernel: number;
  43521. /**
  43522. * Specifies the ground mirror visibility amount.
  43523. * 1 by default
  43524. */
  43525. groundMirrorAmount: number;
  43526. /**
  43527. * Specifies the ground mirror reflectance weight.
  43528. * This uses the standard weight of the background material to setup the fresnel effect
  43529. * of the mirror.
  43530. * 1 by default.
  43531. */
  43532. groundMirrorFresnelWeight: number;
  43533. /**
  43534. * Specifies the ground mirror Falloff distance.
  43535. * This can helps reducing the size of the reflection.
  43536. * 0 by Default.
  43537. */
  43538. groundMirrorFallOffDistance: number;
  43539. /**
  43540. * Specifies the ground mirror texture type.
  43541. * Unsigned Int by Default.
  43542. */
  43543. groundMirrorTextureType: number;
  43544. /**
  43545. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43546. * the shown objects.
  43547. */
  43548. groundYBias: number;
  43549. /**
  43550. * Specifies wether or not to create a skybox.
  43551. * True by default.
  43552. */
  43553. createSkybox: boolean;
  43554. /**
  43555. * Specifies the skybox size.
  43556. * 20 by default.
  43557. */
  43558. skyboxSize: number;
  43559. /**
  43560. * The texture used on the skybox for the main color.
  43561. * Comes from the BabylonJS CDN by default.
  43562. *
  43563. * Remarks: Can be either a texture or a url.
  43564. */
  43565. skyboxTexture: string | BaseTexture;
  43566. /**
  43567. * The color mixed in the skybox texture by default.
  43568. * BabylonJS clearColor by default.
  43569. */
  43570. skyboxColor: Color3;
  43571. /**
  43572. * The background rotation around the Y axis of the scene.
  43573. * This helps aligning the key lights of your scene with the background.
  43574. * 0 by default.
  43575. */
  43576. backgroundYRotation: number;
  43577. /**
  43578. * Compute automatically the size of the elements to best fit with the scene.
  43579. */
  43580. sizeAuto: boolean;
  43581. /**
  43582. * Default position of the rootMesh if autoSize is not true.
  43583. */
  43584. rootPosition: Vector3;
  43585. /**
  43586. * Sets up the image processing in the scene.
  43587. * true by default.
  43588. */
  43589. setupImageProcessing: boolean;
  43590. /**
  43591. * The texture used as your environment texture in the scene.
  43592. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43593. *
  43594. * Remarks: Can be either a texture or a url.
  43595. */
  43596. environmentTexture: string | BaseTexture;
  43597. /**
  43598. * The value of the exposure to apply to the scene.
  43599. * 0.6 by default if setupImageProcessing is true.
  43600. */
  43601. cameraExposure: number;
  43602. /**
  43603. * The value of the contrast to apply to the scene.
  43604. * 1.6 by default if setupImageProcessing is true.
  43605. */
  43606. cameraContrast: number;
  43607. /**
  43608. * Specifies wether or not tonemapping should be enabled in the scene.
  43609. * true by default if setupImageProcessing is true.
  43610. */
  43611. toneMappingEnabled: boolean;
  43612. }
  43613. /**
  43614. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43615. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43616. * It also helps with the default setup of your imageProcessing configuration.
  43617. */
  43618. export class EnvironmentHelper {
  43619. /**
  43620. * Default ground texture URL.
  43621. */
  43622. private static _groundTextureCDNUrl;
  43623. /**
  43624. * Default skybox texture URL.
  43625. */
  43626. private static _skyboxTextureCDNUrl;
  43627. /**
  43628. * Default environment texture URL.
  43629. */
  43630. private static _environmentTextureCDNUrl;
  43631. /**
  43632. * Creates the default options for the helper.
  43633. */
  43634. private static _getDefaultOptions;
  43635. private _rootMesh;
  43636. /**
  43637. * Gets the root mesh created by the helper.
  43638. */
  43639. readonly rootMesh: Mesh;
  43640. private _skybox;
  43641. /**
  43642. * Gets the skybox created by the helper.
  43643. */
  43644. readonly skybox: Nullable<Mesh>;
  43645. private _skyboxTexture;
  43646. /**
  43647. * Gets the skybox texture created by the helper.
  43648. */
  43649. readonly skyboxTexture: Nullable<BaseTexture>;
  43650. private _skyboxMaterial;
  43651. /**
  43652. * Gets the skybox material created by the helper.
  43653. */
  43654. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43655. private _ground;
  43656. /**
  43657. * Gets the ground mesh created by the helper.
  43658. */
  43659. readonly ground: Nullable<Mesh>;
  43660. private _groundTexture;
  43661. /**
  43662. * Gets the ground texture created by the helper.
  43663. */
  43664. readonly groundTexture: Nullable<BaseTexture>;
  43665. private _groundMirror;
  43666. /**
  43667. * Gets the ground mirror created by the helper.
  43668. */
  43669. readonly groundMirror: Nullable<MirrorTexture>;
  43670. /**
  43671. * Gets the ground mirror render list to helps pushing the meshes
  43672. * you wish in the ground reflection.
  43673. */
  43674. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43675. private _groundMaterial;
  43676. /**
  43677. * Gets the ground material created by the helper.
  43678. */
  43679. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43680. /**
  43681. * Stores the creation options.
  43682. */
  43683. private readonly _scene;
  43684. private _options;
  43685. /**
  43686. * This observable will be notified with any error during the creation of the environment,
  43687. * mainly texture creation errors.
  43688. */
  43689. onErrorObservable: Observable<{
  43690. message?: string;
  43691. exception?: any;
  43692. }>;
  43693. /**
  43694. * constructor
  43695. * @param options Defines the options we want to customize the helper
  43696. * @param scene The scene to add the material to
  43697. */
  43698. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43699. /**
  43700. * Updates the background according to the new options
  43701. * @param options
  43702. */
  43703. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43704. /**
  43705. * Sets the primary color of all the available elements.
  43706. * @param color the main color to affect to the ground and the background
  43707. */
  43708. setMainColor(color: Color3): void;
  43709. /**
  43710. * Setup the image processing according to the specified options.
  43711. */
  43712. private _setupImageProcessing;
  43713. /**
  43714. * Setup the environment texture according to the specified options.
  43715. */
  43716. private _setupEnvironmentTexture;
  43717. /**
  43718. * Setup the background according to the specified options.
  43719. */
  43720. private _setupBackground;
  43721. /**
  43722. * Get the scene sizes according to the setup.
  43723. */
  43724. private _getSceneSize;
  43725. /**
  43726. * Setup the ground according to the specified options.
  43727. */
  43728. private _setupGround;
  43729. /**
  43730. * Setup the ground material according to the specified options.
  43731. */
  43732. private _setupGroundMaterial;
  43733. /**
  43734. * Setup the ground diffuse texture according to the specified options.
  43735. */
  43736. private _setupGroundDiffuseTexture;
  43737. /**
  43738. * Setup the ground mirror texture according to the specified options.
  43739. */
  43740. private _setupGroundMirrorTexture;
  43741. /**
  43742. * Setup the ground to receive the mirror texture.
  43743. */
  43744. private _setupMirrorInGroundMaterial;
  43745. /**
  43746. * Setup the skybox according to the specified options.
  43747. */
  43748. private _setupSkybox;
  43749. /**
  43750. * Setup the skybox material according to the specified options.
  43751. */
  43752. private _setupSkyboxMaterial;
  43753. /**
  43754. * Setup the skybox reflection texture according to the specified options.
  43755. */
  43756. private _setupSkyboxReflectionTexture;
  43757. private _errorHandler;
  43758. /**
  43759. * Dispose all the elements created by the Helper.
  43760. */
  43761. dispose(): void;
  43762. }
  43763. }
  43764. declare module "babylonjs/Helpers/photoDome" {
  43765. import { Observable } from "babylonjs/Misc/observable";
  43766. import { Nullable } from "babylonjs/types";
  43767. import { Scene } from "babylonjs/scene";
  43768. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43769. import { Mesh } from "babylonjs/Meshes/mesh";
  43770. import { Texture } from "babylonjs/Materials/Textures/texture";
  43771. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43772. import "babylonjs/Meshes/Builders/sphereBuilder";
  43773. /**
  43774. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43775. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43776. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43777. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43778. */
  43779. export class PhotoDome extends TransformNode {
  43780. private _useDirectMapping;
  43781. /**
  43782. * The texture being displayed on the sphere
  43783. */
  43784. protected _photoTexture: Texture;
  43785. /**
  43786. * Gets or sets the texture being displayed on the sphere
  43787. */
  43788. photoTexture: Texture;
  43789. /**
  43790. * Observable raised when an error occured while loading the 360 image
  43791. */
  43792. onLoadErrorObservable: Observable<string>;
  43793. /**
  43794. * The skybox material
  43795. */
  43796. protected _material: BackgroundMaterial;
  43797. /**
  43798. * The surface used for the skybox
  43799. */
  43800. protected _mesh: Mesh;
  43801. /**
  43802. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43803. * Also see the options.resolution property.
  43804. */
  43805. fovMultiplier: number;
  43806. /**
  43807. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43808. * @param name Element's name, child elements will append suffixes for their own names.
  43809. * @param urlsOfPhoto defines the url of the photo to display
  43810. * @param options defines an object containing optional or exposed sub element properties
  43811. * @param onError defines a callback called when an error occured while loading the texture
  43812. */
  43813. constructor(name: string, urlOfPhoto: string, options: {
  43814. resolution?: number;
  43815. size?: number;
  43816. useDirectMapping?: boolean;
  43817. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43818. /**
  43819. * Releases resources associated with this node.
  43820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43822. */
  43823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43824. }
  43825. }
  43826. declare module "babylonjs/Misc/textureTools" {
  43827. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43828. import { Texture } from "babylonjs/Materials/Textures/texture";
  43829. import { Scene } from "babylonjs/scene";
  43830. /**
  43831. * Class used to host texture specific utilities
  43832. */
  43833. export class TextureTools {
  43834. /**
  43835. * Uses the GPU to create a copy texture rescaled at a given size
  43836. * @param texture Texture to copy from
  43837. * @param width defines the desired width
  43838. * @param height defines the desired height
  43839. * @param useBilinearMode defines if bilinear mode has to be used
  43840. * @return the generated texture
  43841. */
  43842. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43843. /**
  43844. * Gets an environment BRDF texture for a given scene
  43845. * @param scene defines the hosting scene
  43846. * @returns the environment BRDF texture
  43847. */
  43848. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43849. private static _environmentBRDFBase64Texture;
  43850. }
  43851. }
  43852. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  43853. /** @hidden */
  43854. export var pbrFragmentDeclaration: {
  43855. name: string;
  43856. shader: string;
  43857. };
  43858. }
  43859. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  43860. /** @hidden */
  43861. export var pbrUboDeclaration: {
  43862. name: string;
  43863. shader: string;
  43864. };
  43865. }
  43866. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  43867. /** @hidden */
  43868. export var pbrFunctions: {
  43869. name: string;
  43870. shader: string;
  43871. };
  43872. }
  43873. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  43874. /** @hidden */
  43875. export var harmonicsFunctions: {
  43876. name: string;
  43877. shader: string;
  43878. };
  43879. }
  43880. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  43881. /** @hidden */
  43882. export var pbrLightFunctions: {
  43883. name: string;
  43884. shader: string;
  43885. };
  43886. }
  43887. declare module "babylonjs/Shaders/pbr.fragment" {
  43888. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  43889. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43890. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43891. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43892. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43893. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43894. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43895. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43896. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43897. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  43898. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43899. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  43900. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  43901. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43902. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43903. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43904. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43905. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  43906. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  43907. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43908. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  43909. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43910. /** @hidden */
  43911. export var pbrPixelShader: {
  43912. name: string;
  43913. shader: string;
  43914. };
  43915. }
  43916. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  43917. /** @hidden */
  43918. export var pbrVertexDeclaration: {
  43919. name: string;
  43920. shader: string;
  43921. };
  43922. }
  43923. declare module "babylonjs/Shaders/pbr.vertex" {
  43924. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  43925. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43926. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43927. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43928. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43929. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43930. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  43931. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43932. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43933. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43934. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43935. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  43936. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  43937. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  43939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43941. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  43942. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43943. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43944. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43945. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  43946. /** @hidden */
  43947. export var pbrVertexShader: {
  43948. name: string;
  43949. shader: string;
  43950. };
  43951. }
  43952. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  43953. import { IAnimatable } from "babylonjs/Misc/tools";
  43954. import { Nullable } from "babylonjs/types";
  43955. import { Scene } from "babylonjs/scene";
  43956. import { Matrix, Color3 } from "babylonjs/Maths/math";
  43957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43959. import { Mesh } from "babylonjs/Meshes/mesh";
  43960. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43961. import { Material } from "babylonjs/Materials/material";
  43962. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43964. import "babylonjs/Shaders/pbr.fragment";
  43965. import "babylonjs/Shaders/pbr.vertex";
  43966. /**
  43967. * The Physically based material base class of BJS.
  43968. *
  43969. * This offers the main features of a standard PBR material.
  43970. * For more information, please refer to the documentation :
  43971. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43972. */
  43973. export abstract class PBRBaseMaterial extends PushMaterial {
  43974. /**
  43975. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43976. */
  43977. static readonly PBRMATERIAL_OPAQUE: number;
  43978. /**
  43979. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43980. */
  43981. static readonly PBRMATERIAL_ALPHATEST: number;
  43982. /**
  43983. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43984. */
  43985. static readonly PBRMATERIAL_ALPHABLEND: number;
  43986. /**
  43987. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43988. * They are also discarded below the alpha cutoff threshold to improve performances.
  43989. */
  43990. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43991. /**
  43992. * Defines the default value of how much AO map is occluding the analytical lights
  43993. * (point spot...).
  43994. */
  43995. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43996. /**
  43997. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43998. */
  43999. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44000. /**
  44001. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44002. * to enhance interoperability with other engines.
  44003. */
  44004. static readonly LIGHTFALLOFF_GLTF: number;
  44005. /**
  44006. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44007. * to enhance interoperability with other materials.
  44008. */
  44009. static readonly LIGHTFALLOFF_STANDARD: number;
  44010. /**
  44011. * Intensity of the direct lights e.g. the four lights available in your scene.
  44012. * This impacts both the direct diffuse and specular highlights.
  44013. */
  44014. protected _directIntensity: number;
  44015. /**
  44016. * Intensity of the emissive part of the material.
  44017. * This helps controlling the emissive effect without modifying the emissive color.
  44018. */
  44019. protected _emissiveIntensity: number;
  44020. /**
  44021. * Intensity of the environment e.g. how much the environment will light the object
  44022. * either through harmonics for rough material or through the refelction for shiny ones.
  44023. */
  44024. protected _environmentIntensity: number;
  44025. /**
  44026. * This is a special control allowing the reduction of the specular highlights coming from the
  44027. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44028. */
  44029. protected _specularIntensity: number;
  44030. /**
  44031. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44032. */
  44033. private _lightingInfos;
  44034. /**
  44035. * Debug Control allowing disabling the bump map on this material.
  44036. */
  44037. protected _disableBumpMap: boolean;
  44038. /**
  44039. * AKA Diffuse Texture in standard nomenclature.
  44040. */
  44041. protected _albedoTexture: BaseTexture;
  44042. /**
  44043. * AKA Occlusion Texture in other nomenclature.
  44044. */
  44045. protected _ambientTexture: BaseTexture;
  44046. /**
  44047. * AKA Occlusion Texture Intensity in other nomenclature.
  44048. */
  44049. protected _ambientTextureStrength: number;
  44050. /**
  44051. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44052. * 1 means it completely occludes it
  44053. * 0 mean it has no impact
  44054. */
  44055. protected _ambientTextureImpactOnAnalyticalLights: number;
  44056. /**
  44057. * Stores the alpha values in a texture.
  44058. */
  44059. protected _opacityTexture: BaseTexture;
  44060. /**
  44061. * Stores the reflection values in a texture.
  44062. */
  44063. protected _reflectionTexture: BaseTexture;
  44064. /**
  44065. * Stores the refraction values in a texture.
  44066. */
  44067. protected _refractionTexture: BaseTexture;
  44068. /**
  44069. * Stores the emissive values in a texture.
  44070. */
  44071. protected _emissiveTexture: BaseTexture;
  44072. /**
  44073. * AKA Specular texture in other nomenclature.
  44074. */
  44075. protected _reflectivityTexture: BaseTexture;
  44076. /**
  44077. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44078. */
  44079. protected _metallicTexture: BaseTexture;
  44080. /**
  44081. * Specifies the metallic scalar of the metallic/roughness workflow.
  44082. * Can also be used to scale the metalness values of the metallic texture.
  44083. */
  44084. protected _metallic: Nullable<number>;
  44085. /**
  44086. * Specifies the roughness scalar of the metallic/roughness workflow.
  44087. * Can also be used to scale the roughness values of the metallic texture.
  44088. */
  44089. protected _roughness: Nullable<number>;
  44090. /**
  44091. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44092. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44093. */
  44094. protected _microSurfaceTexture: BaseTexture;
  44095. /**
  44096. * Stores surface normal data used to displace a mesh in a texture.
  44097. */
  44098. protected _bumpTexture: BaseTexture;
  44099. /**
  44100. * Stores the pre-calculated light information of a mesh in a texture.
  44101. */
  44102. protected _lightmapTexture: BaseTexture;
  44103. /**
  44104. * The color of a material in ambient lighting.
  44105. */
  44106. protected _ambientColor: Color3;
  44107. /**
  44108. * AKA Diffuse Color in other nomenclature.
  44109. */
  44110. protected _albedoColor: Color3;
  44111. /**
  44112. * AKA Specular Color in other nomenclature.
  44113. */
  44114. protected _reflectivityColor: Color3;
  44115. /**
  44116. * The color applied when light is reflected from a material.
  44117. */
  44118. protected _reflectionColor: Color3;
  44119. /**
  44120. * The color applied when light is emitted from a material.
  44121. */
  44122. protected _emissiveColor: Color3;
  44123. /**
  44124. * AKA Glossiness in other nomenclature.
  44125. */
  44126. protected _microSurface: number;
  44127. /**
  44128. * source material index of refraction (IOR)' / 'destination material IOR.
  44129. */
  44130. protected _indexOfRefraction: number;
  44131. /**
  44132. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44133. */
  44134. protected _invertRefractionY: boolean;
  44135. /**
  44136. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44137. * Materials half opaque for instance using refraction could benefit from this control.
  44138. */
  44139. protected _linkRefractionWithTransparency: boolean;
  44140. /**
  44141. * Specifies that the material will use the light map as a show map.
  44142. */
  44143. protected _useLightmapAsShadowmap: boolean;
  44144. /**
  44145. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44146. * makes the reflect vector face the model (under horizon).
  44147. */
  44148. protected _useHorizonOcclusion: boolean;
  44149. /**
  44150. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44151. * too much the area relying on ambient texture to define their ambient occlusion.
  44152. */
  44153. protected _useRadianceOcclusion: boolean;
  44154. /**
  44155. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44156. */
  44157. protected _useAlphaFromAlbedoTexture: boolean;
  44158. /**
  44159. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44160. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44161. */
  44162. protected _useSpecularOverAlpha: boolean;
  44163. /**
  44164. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44165. */
  44166. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44167. /**
  44168. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44169. */
  44170. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44171. /**
  44172. * Specifies if the metallic texture contains the roughness information in its green channel.
  44173. */
  44174. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44175. /**
  44176. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44177. */
  44178. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44179. /**
  44180. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44181. */
  44182. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44183. /**
  44184. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44185. */
  44186. protected _useAmbientInGrayScale: boolean;
  44187. /**
  44188. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44189. * The material will try to infer what glossiness each pixel should be.
  44190. */
  44191. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44192. /**
  44193. * Defines the falloff type used in this material.
  44194. * It by default is Physical.
  44195. */
  44196. protected _lightFalloff: number;
  44197. /**
  44198. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44199. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44200. */
  44201. protected _useRadianceOverAlpha: boolean;
  44202. /**
  44203. * Allows using an object space normal map (instead of tangent space).
  44204. */
  44205. protected _useObjectSpaceNormalMap: boolean;
  44206. /**
  44207. * Allows using the bump map in parallax mode.
  44208. */
  44209. protected _useParallax: boolean;
  44210. /**
  44211. * Allows using the bump map in parallax occlusion mode.
  44212. */
  44213. protected _useParallaxOcclusion: boolean;
  44214. /**
  44215. * Controls the scale bias of the parallax mode.
  44216. */
  44217. protected _parallaxScaleBias: number;
  44218. /**
  44219. * If sets to true, disables all the lights affecting the material.
  44220. */
  44221. protected _disableLighting: boolean;
  44222. /**
  44223. * Number of Simultaneous lights allowed on the material.
  44224. */
  44225. protected _maxSimultaneousLights: number;
  44226. /**
  44227. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44228. */
  44229. protected _invertNormalMapX: boolean;
  44230. /**
  44231. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44232. */
  44233. protected _invertNormalMapY: boolean;
  44234. /**
  44235. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44236. */
  44237. protected _twoSidedLighting: boolean;
  44238. /**
  44239. * Defines the alpha limits in alpha test mode.
  44240. */
  44241. protected _alphaCutOff: number;
  44242. /**
  44243. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44244. */
  44245. protected _forceAlphaTest: boolean;
  44246. /**
  44247. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44248. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44249. */
  44250. protected _useAlphaFresnel: boolean;
  44251. /**
  44252. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44253. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44254. */
  44255. protected _useLinearAlphaFresnel: boolean;
  44256. /**
  44257. * The transparency mode of the material.
  44258. */
  44259. protected _transparencyMode: Nullable<number>;
  44260. /**
  44261. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44262. * from cos thetav and roughness:
  44263. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44264. */
  44265. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44266. /**
  44267. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44268. */
  44269. protected _forceIrradianceInFragment: boolean;
  44270. /**
  44271. * Force normal to face away from face.
  44272. */
  44273. protected _forceNormalForward: boolean;
  44274. /**
  44275. * Enables specular anti aliasing in the PBR shader.
  44276. * It will both interacts on the Geometry for analytical and IBL lighting.
  44277. * It also prefilter the roughness map based on the bump values.
  44278. */
  44279. protected _enableSpecularAntiAliasing: boolean;
  44280. /**
  44281. * Default configuration related to image processing available in the PBR Material.
  44282. */
  44283. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44284. /**
  44285. * Keep track of the image processing observer to allow dispose and replace.
  44286. */
  44287. private _imageProcessingObserver;
  44288. /**
  44289. * Attaches a new image processing configuration to the PBR Material.
  44290. * @param configuration
  44291. */
  44292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44293. /**
  44294. * Stores the available render targets.
  44295. */
  44296. private _renderTargets;
  44297. /**
  44298. * Sets the global ambient color for the material used in lighting calculations.
  44299. */
  44300. private _globalAmbientColor;
  44301. /**
  44302. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44303. */
  44304. private _useLogarithmicDepth;
  44305. /**
  44306. * If set to true, no lighting calculations will be applied.
  44307. */
  44308. private _unlit;
  44309. /**
  44310. * Instantiates a new PBRMaterial instance.
  44311. *
  44312. * @param name The material name
  44313. * @param scene The scene the material will be use in.
  44314. */
  44315. constructor(name: string, scene: Scene);
  44316. /**
  44317. * Gets a boolean indicating that current material needs to register RTT
  44318. */
  44319. readonly hasRenderTargetTextures: boolean;
  44320. /**
  44321. * Gets the name of the material class.
  44322. */
  44323. getClassName(): string;
  44324. /**
  44325. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44326. */
  44327. /**
  44328. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44329. */
  44330. useLogarithmicDepth: boolean;
  44331. /**
  44332. * Gets the current transparency mode.
  44333. */
  44334. /**
  44335. * Sets the transparency mode of the material.
  44336. *
  44337. * | Value | Type | Description |
  44338. * | ----- | ----------------------------------- | ----------- |
  44339. * | 0 | OPAQUE | |
  44340. * | 1 | ALPHATEST | |
  44341. * | 2 | ALPHABLEND | |
  44342. * | 3 | ALPHATESTANDBLEND | |
  44343. *
  44344. */
  44345. transparencyMode: Nullable<number>;
  44346. /**
  44347. * Returns true if alpha blending should be disabled.
  44348. */
  44349. private readonly _disableAlphaBlending;
  44350. /**
  44351. * Specifies whether or not this material should be rendered in alpha blend mode.
  44352. */
  44353. needAlphaBlending(): boolean;
  44354. /**
  44355. * Specifies if the mesh will require alpha blending.
  44356. * @param mesh - BJS mesh.
  44357. */
  44358. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44359. /**
  44360. * Specifies whether or not this material should be rendered in alpha test mode.
  44361. */
  44362. needAlphaTesting(): boolean;
  44363. /**
  44364. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44365. */
  44366. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44367. /**
  44368. * Gets the texture used for the alpha test.
  44369. */
  44370. getAlphaTestTexture(): BaseTexture;
  44371. /**
  44372. * Specifies that the submesh is ready to be used.
  44373. * @param mesh - BJS mesh.
  44374. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44375. * @param useInstances - Specifies that instances should be used.
  44376. * @returns - boolean indicating that the submesh is ready or not.
  44377. */
  44378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44379. /**
  44380. * Specifies if the material uses metallic roughness workflow.
  44381. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44382. */
  44383. isMetallicWorkflow(): boolean;
  44384. private _prepareEffect;
  44385. private _prepareDefines;
  44386. /**
  44387. * Force shader compilation
  44388. */
  44389. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44390. clipPlane: boolean;
  44391. }>): void;
  44392. /**
  44393. * Initializes the uniform buffer layout for the shader.
  44394. */
  44395. buildUniformLayout(): void;
  44396. /**
  44397. * Unbinds the textures.
  44398. */
  44399. unbind(): void;
  44400. /**
  44401. * Binds the submesh data.
  44402. * @param world - The world matrix.
  44403. * @param mesh - The BJS mesh.
  44404. * @param subMesh - A submesh of the BJS mesh.
  44405. */
  44406. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44407. /**
  44408. * Returns the animatable textures.
  44409. * @returns - Array of animatable textures.
  44410. */
  44411. getAnimatables(): IAnimatable[];
  44412. /**
  44413. * Returns the texture used for reflections.
  44414. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44415. */
  44416. private _getReflectionTexture;
  44417. /**
  44418. * Returns the texture used for refraction or null if none is used.
  44419. * @returns - Refection texture if present. If no refraction texture and refraction
  44420. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44421. */
  44422. private _getRefractionTexture;
  44423. /**
  44424. * Disposes the resources of the material.
  44425. * @param forceDisposeEffect - Forces the disposal of effects.
  44426. * @param forceDisposeTextures - Forces the disposal of all textures.
  44427. */
  44428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44429. }
  44430. }
  44431. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44432. import { Nullable } from "babylonjs/types";
  44433. import { Scene } from "babylonjs/scene";
  44434. import { Color3 } from "babylonjs/Maths/math";
  44435. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44436. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44438. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44439. /**
  44440. * The Physically based material of BJS.
  44441. *
  44442. * This offers the main features of a standard PBR material.
  44443. * For more information, please refer to the documentation :
  44444. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44445. */
  44446. export class PBRMaterial extends PBRBaseMaterial {
  44447. /**
  44448. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44449. */
  44450. static readonly PBRMATERIAL_OPAQUE: number;
  44451. /**
  44452. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44453. */
  44454. static readonly PBRMATERIAL_ALPHATEST: number;
  44455. /**
  44456. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44457. */
  44458. static readonly PBRMATERIAL_ALPHABLEND: number;
  44459. /**
  44460. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44461. * They are also discarded below the alpha cutoff threshold to improve performances.
  44462. */
  44463. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44464. /**
  44465. * Defines the default value of how much AO map is occluding the analytical lights
  44466. * (point spot...).
  44467. */
  44468. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44469. /**
  44470. * Intensity of the direct lights e.g. the four lights available in your scene.
  44471. * This impacts both the direct diffuse and specular highlights.
  44472. */
  44473. directIntensity: number;
  44474. /**
  44475. * Intensity of the emissive part of the material.
  44476. * This helps controlling the emissive effect without modifying the emissive color.
  44477. */
  44478. emissiveIntensity: number;
  44479. /**
  44480. * Intensity of the environment e.g. how much the environment will light the object
  44481. * either through harmonics for rough material or through the refelction for shiny ones.
  44482. */
  44483. environmentIntensity: number;
  44484. /**
  44485. * This is a special control allowing the reduction of the specular highlights coming from the
  44486. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44487. */
  44488. specularIntensity: number;
  44489. /**
  44490. * Debug Control allowing disabling the bump map on this material.
  44491. */
  44492. disableBumpMap: boolean;
  44493. /**
  44494. * AKA Diffuse Texture in standard nomenclature.
  44495. */
  44496. albedoTexture: BaseTexture;
  44497. /**
  44498. * AKA Occlusion Texture in other nomenclature.
  44499. */
  44500. ambientTexture: BaseTexture;
  44501. /**
  44502. * AKA Occlusion Texture Intensity in other nomenclature.
  44503. */
  44504. ambientTextureStrength: number;
  44505. /**
  44506. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44507. * 1 means it completely occludes it
  44508. * 0 mean it has no impact
  44509. */
  44510. ambientTextureImpactOnAnalyticalLights: number;
  44511. /**
  44512. * Stores the alpha values in a texture.
  44513. */
  44514. opacityTexture: BaseTexture;
  44515. /**
  44516. * Stores the reflection values in a texture.
  44517. */
  44518. reflectionTexture: Nullable<BaseTexture>;
  44519. /**
  44520. * Stores the emissive values in a texture.
  44521. */
  44522. emissiveTexture: BaseTexture;
  44523. /**
  44524. * AKA Specular texture in other nomenclature.
  44525. */
  44526. reflectivityTexture: BaseTexture;
  44527. /**
  44528. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44529. */
  44530. metallicTexture: BaseTexture;
  44531. /**
  44532. * Specifies the metallic scalar of the metallic/roughness workflow.
  44533. * Can also be used to scale the metalness values of the metallic texture.
  44534. */
  44535. metallic: Nullable<number>;
  44536. /**
  44537. * Specifies the roughness scalar of the metallic/roughness workflow.
  44538. * Can also be used to scale the roughness values of the metallic texture.
  44539. */
  44540. roughness: Nullable<number>;
  44541. /**
  44542. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44543. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44544. */
  44545. microSurfaceTexture: BaseTexture;
  44546. /**
  44547. * Stores surface normal data used to displace a mesh in a texture.
  44548. */
  44549. bumpTexture: BaseTexture;
  44550. /**
  44551. * Stores the pre-calculated light information of a mesh in a texture.
  44552. */
  44553. lightmapTexture: BaseTexture;
  44554. /**
  44555. * Stores the refracted light information in a texture.
  44556. */
  44557. refractionTexture: BaseTexture;
  44558. /**
  44559. * The color of a material in ambient lighting.
  44560. */
  44561. ambientColor: Color3;
  44562. /**
  44563. * AKA Diffuse Color in other nomenclature.
  44564. */
  44565. albedoColor: Color3;
  44566. /**
  44567. * AKA Specular Color in other nomenclature.
  44568. */
  44569. reflectivityColor: Color3;
  44570. /**
  44571. * The color reflected from the material.
  44572. */
  44573. reflectionColor: Color3;
  44574. /**
  44575. * The color emitted from the material.
  44576. */
  44577. emissiveColor: Color3;
  44578. /**
  44579. * AKA Glossiness in other nomenclature.
  44580. */
  44581. microSurface: number;
  44582. /**
  44583. * source material index of refraction (IOR)' / 'destination material IOR.
  44584. */
  44585. indexOfRefraction: number;
  44586. /**
  44587. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44588. */
  44589. invertRefractionY: boolean;
  44590. /**
  44591. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44592. * Materials half opaque for instance using refraction could benefit from this control.
  44593. */
  44594. linkRefractionWithTransparency: boolean;
  44595. /**
  44596. * If true, the light map contains occlusion information instead of lighting info.
  44597. */
  44598. useLightmapAsShadowmap: boolean;
  44599. /**
  44600. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44601. */
  44602. useAlphaFromAlbedoTexture: boolean;
  44603. /**
  44604. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44605. */
  44606. forceAlphaTest: boolean;
  44607. /**
  44608. * Defines the alpha limits in alpha test mode.
  44609. */
  44610. alphaCutOff: number;
  44611. /**
  44612. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44613. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44614. */
  44615. useSpecularOverAlpha: boolean;
  44616. /**
  44617. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44618. */
  44619. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44620. /**
  44621. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44622. */
  44623. useRoughnessFromMetallicTextureAlpha: boolean;
  44624. /**
  44625. * Specifies if the metallic texture contains the roughness information in its green channel.
  44626. */
  44627. useRoughnessFromMetallicTextureGreen: boolean;
  44628. /**
  44629. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44630. */
  44631. useMetallnessFromMetallicTextureBlue: boolean;
  44632. /**
  44633. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44634. */
  44635. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44636. /**
  44637. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44638. */
  44639. useAmbientInGrayScale: boolean;
  44640. /**
  44641. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44642. * The material will try to infer what glossiness each pixel should be.
  44643. */
  44644. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44645. /**
  44646. * BJS is using an harcoded light falloff based on a manually sets up range.
  44647. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44648. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44649. */
  44650. /**
  44651. * BJS is using an harcoded light falloff based on a manually sets up range.
  44652. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44653. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44654. */
  44655. usePhysicalLightFalloff: boolean;
  44656. /**
  44657. * In order to support the falloff compatibility with gltf, a special mode has been added
  44658. * to reproduce the gltf light falloff.
  44659. */
  44660. /**
  44661. * In order to support the falloff compatibility with gltf, a special mode has been added
  44662. * to reproduce the gltf light falloff.
  44663. */
  44664. useGLTFLightFalloff: boolean;
  44665. /**
  44666. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44667. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44668. */
  44669. useRadianceOverAlpha: boolean;
  44670. /**
  44671. * Allows using an object space normal map (instead of tangent space).
  44672. */
  44673. useObjectSpaceNormalMap: boolean;
  44674. /**
  44675. * Allows using the bump map in parallax mode.
  44676. */
  44677. useParallax: boolean;
  44678. /**
  44679. * Allows using the bump map in parallax occlusion mode.
  44680. */
  44681. useParallaxOcclusion: boolean;
  44682. /**
  44683. * Controls the scale bias of the parallax mode.
  44684. */
  44685. parallaxScaleBias: number;
  44686. /**
  44687. * If sets to true, disables all the lights affecting the material.
  44688. */
  44689. disableLighting: boolean;
  44690. /**
  44691. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44692. */
  44693. forceIrradianceInFragment: boolean;
  44694. /**
  44695. * Number of Simultaneous lights allowed on the material.
  44696. */
  44697. maxSimultaneousLights: number;
  44698. /**
  44699. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44700. */
  44701. invertNormalMapX: boolean;
  44702. /**
  44703. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44704. */
  44705. invertNormalMapY: boolean;
  44706. /**
  44707. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44708. */
  44709. twoSidedLighting: boolean;
  44710. /**
  44711. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44712. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44713. */
  44714. useAlphaFresnel: boolean;
  44715. /**
  44716. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44717. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44718. */
  44719. useLinearAlphaFresnel: boolean;
  44720. /**
  44721. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44722. * And/Or occlude the blended part.
  44723. */
  44724. environmentBRDFTexture: Nullable<BaseTexture>;
  44725. /**
  44726. * Force normal to face away from face.
  44727. */
  44728. forceNormalForward: boolean;
  44729. /**
  44730. * Enables specular anti aliasing in the PBR shader.
  44731. * It will both interacts on the Geometry for analytical and IBL lighting.
  44732. * It also prefilter the roughness map based on the bump values.
  44733. */
  44734. enableSpecularAntiAliasing: boolean;
  44735. /**
  44736. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44737. * makes the reflect vector face the model (under horizon).
  44738. */
  44739. useHorizonOcclusion: boolean;
  44740. /**
  44741. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44742. * too much the area relying on ambient texture to define their ambient occlusion.
  44743. */
  44744. useRadianceOcclusion: boolean;
  44745. /**
  44746. * If set to true, no lighting calculations will be applied.
  44747. */
  44748. unlit: boolean;
  44749. /**
  44750. * Gets the image processing configuration used either in this material.
  44751. */
  44752. /**
  44753. * Sets the Default image processing configuration used either in the this material.
  44754. *
  44755. * If sets to null, the scene one is in use.
  44756. */
  44757. imageProcessingConfiguration: ImageProcessingConfiguration;
  44758. /**
  44759. * Gets wether the color curves effect is enabled.
  44760. */
  44761. /**
  44762. * Sets wether the color curves effect is enabled.
  44763. */
  44764. cameraColorCurvesEnabled: boolean;
  44765. /**
  44766. * Gets wether the color grading effect is enabled.
  44767. */
  44768. /**
  44769. * Gets wether the color grading effect is enabled.
  44770. */
  44771. cameraColorGradingEnabled: boolean;
  44772. /**
  44773. * Gets wether tonemapping is enabled or not.
  44774. */
  44775. /**
  44776. * Sets wether tonemapping is enabled or not
  44777. */
  44778. cameraToneMappingEnabled: boolean;
  44779. /**
  44780. * The camera exposure used on this material.
  44781. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44782. * This corresponds to a photographic exposure.
  44783. */
  44784. /**
  44785. * The camera exposure used on this material.
  44786. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44787. * This corresponds to a photographic exposure.
  44788. */
  44789. cameraExposure: number;
  44790. /**
  44791. * Gets The camera contrast used on this material.
  44792. */
  44793. /**
  44794. * Sets The camera contrast used on this material.
  44795. */
  44796. cameraContrast: number;
  44797. /**
  44798. * Gets the Color Grading 2D Lookup Texture.
  44799. */
  44800. /**
  44801. * Sets the Color Grading 2D Lookup Texture.
  44802. */
  44803. cameraColorGradingTexture: Nullable<BaseTexture>;
  44804. /**
  44805. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44806. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44807. * 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;
  44808. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44809. */
  44810. /**
  44811. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44812. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44813. * 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;
  44814. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44815. */
  44816. cameraColorCurves: Nullable<ColorCurves>;
  44817. /**
  44818. * Instantiates a new PBRMaterial instance.
  44819. *
  44820. * @param name The material name
  44821. * @param scene The scene the material will be use in.
  44822. */
  44823. constructor(name: string, scene: Scene);
  44824. /**
  44825. * Returns the name of this material class.
  44826. */
  44827. getClassName(): string;
  44828. /**
  44829. * Returns an array of the actively used textures.
  44830. * @returns - Array of BaseTextures
  44831. */
  44832. getActiveTextures(): BaseTexture[];
  44833. /**
  44834. * Checks to see if a texture is used in the material.
  44835. * @param texture - Base texture to use.
  44836. * @returns - Boolean specifying if a texture is used in the material.
  44837. */
  44838. hasTexture(texture: BaseTexture): boolean;
  44839. /**
  44840. * Makes a duplicate of the current material.
  44841. * @param name - name to use for the new material.
  44842. */
  44843. clone(name: string): PBRMaterial;
  44844. /**
  44845. * Serializes this PBR Material.
  44846. * @returns - An object with the serialized material.
  44847. */
  44848. serialize(): any;
  44849. /**
  44850. * Parses a PBR Material from a serialized object.
  44851. * @param source - Serialized object.
  44852. * @param scene - BJS scene instance.
  44853. * @param rootUrl - url for the scene object
  44854. * @returns - PBRMaterial
  44855. */
  44856. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44857. }
  44858. }
  44859. declare module "babylonjs/Helpers/sceneHelpers" {
  44860. import { Nullable } from "babylonjs/types";
  44861. import { Mesh } from "babylonjs/Meshes/mesh";
  44862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44863. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  44864. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44865. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  44866. import "babylonjs/Meshes/Builders/boxBuilder";
  44867. /** @hidden */
  44868. export var _forceSceneHelpersToBundle: boolean;
  44869. module "babylonjs/scene" {
  44870. interface Scene {
  44871. /**
  44872. * Creates a default light for the scene.
  44873. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  44874. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  44875. */
  44876. createDefaultLight(replace?: boolean): void;
  44877. /**
  44878. * Creates a default camera for the scene.
  44879. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  44880. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44881. * @param replace has default false, when true replaces the active camera in the scene
  44882. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  44883. */
  44884. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44885. /**
  44886. * Creates a default camera and a default light.
  44887. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  44888. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44889. * @param replace has the default false, when true replaces the active camera/light in the scene
  44890. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  44891. */
  44892. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44893. /**
  44894. * Creates a new sky box
  44895. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  44896. * @param environmentTexture defines the texture to use as environment texture
  44897. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  44898. * @param scale defines the overall scale of the skybox
  44899. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  44900. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  44901. * @returns a new mesh holding the sky box
  44902. */
  44903. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  44904. /**
  44905. * Creates a new environment
  44906. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  44907. * @param options defines the options you can use to configure the environment
  44908. * @returns the new EnvironmentHelper
  44909. */
  44910. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  44911. /**
  44912. * Creates a new VREXperienceHelper
  44913. * @see http://doc.babylonjs.com/how_to/webvr_helper
  44914. * @param webVROptions defines the options used to create the new VREXperienceHelper
  44915. * @returns a new VREXperienceHelper
  44916. */
  44917. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  44918. /**
  44919. * Creates a new XREXperienceHelper
  44920. * @see http://doc.babylonjs.com/how_to/webxr
  44921. * @returns a promise for a new XREXperienceHelper
  44922. */
  44923. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  44924. }
  44925. }
  44926. }
  44927. declare module "babylonjs/Helpers/videoDome" {
  44928. import { Scene } from "babylonjs/scene";
  44929. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44930. import { Mesh } from "babylonjs/Meshes/mesh";
  44931. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  44932. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44933. import "babylonjs/Meshes/Builders/sphereBuilder";
  44934. /**
  44935. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  44936. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  44937. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  44938. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44939. */
  44940. export class VideoDome extends TransformNode {
  44941. private _useDirectMapping;
  44942. /**
  44943. * The video texture being displayed on the sphere
  44944. */
  44945. protected _videoTexture: VideoTexture;
  44946. /**
  44947. * Gets the video texture being displayed on the sphere
  44948. */
  44949. readonly videoTexture: VideoTexture;
  44950. /**
  44951. * The skybox material
  44952. */
  44953. protected _material: BackgroundMaterial;
  44954. /**
  44955. * The surface used for the skybox
  44956. */
  44957. protected _mesh: Mesh;
  44958. /**
  44959. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44960. * Also see the options.resolution property.
  44961. */
  44962. fovMultiplier: number;
  44963. /**
  44964. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  44965. * @param name Element's name, child elements will append suffixes for their own names.
  44966. * @param urlsOrVideo defines the url(s) or the video element to use
  44967. * @param options An object containing optional or exposed sub element properties
  44968. */
  44969. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  44970. resolution?: number;
  44971. clickToPlay?: boolean;
  44972. autoPlay?: boolean;
  44973. loop?: boolean;
  44974. size?: number;
  44975. poster?: string;
  44976. useDirectMapping?: boolean;
  44977. }, scene: Scene);
  44978. /**
  44979. * Releases resources associated with this node.
  44980. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44981. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44982. */
  44983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44984. }
  44985. }
  44986. declare module "babylonjs/Helpers/index" {
  44987. export * from "babylonjs/Helpers/environmentHelper";
  44988. export * from "babylonjs/Helpers/photoDome";
  44989. export * from "babylonjs/Helpers/sceneHelpers";
  44990. export * from "babylonjs/Helpers/videoDome";
  44991. }
  44992. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  44993. import { PerfCounter } from "babylonjs/Misc/tools";
  44994. import { IDisposable } from "babylonjs/scene";
  44995. import { Engine } from "babylonjs/Engines/engine";
  44996. /**
  44997. * This class can be used to get instrumentation data from a Babylon engine
  44998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44999. */
  45000. export class EngineInstrumentation implements IDisposable {
  45001. /**
  45002. * Define the instrumented engine.
  45003. */
  45004. engine: Engine;
  45005. private _captureGPUFrameTime;
  45006. private _gpuFrameTimeToken;
  45007. private _gpuFrameTime;
  45008. private _captureShaderCompilationTime;
  45009. private _shaderCompilationTime;
  45010. private _onBeginFrameObserver;
  45011. private _onEndFrameObserver;
  45012. private _onBeforeShaderCompilationObserver;
  45013. private _onAfterShaderCompilationObserver;
  45014. /**
  45015. * Gets the perf counter used for GPU frame time
  45016. */
  45017. readonly gpuFrameTimeCounter: PerfCounter;
  45018. /**
  45019. * Gets the GPU frame time capture status
  45020. */
  45021. /**
  45022. * Enable or disable the GPU frame time capture
  45023. */
  45024. captureGPUFrameTime: boolean;
  45025. /**
  45026. * Gets the perf counter used for shader compilation time
  45027. */
  45028. readonly shaderCompilationTimeCounter: PerfCounter;
  45029. /**
  45030. * Gets the shader compilation time capture status
  45031. */
  45032. /**
  45033. * Enable or disable the shader compilation time capture
  45034. */
  45035. captureShaderCompilationTime: boolean;
  45036. /**
  45037. * Instantiates a new engine instrumentation.
  45038. * This class can be used to get instrumentation data from a Babylon engine
  45039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45040. * @param engine Defines the engine to instrument
  45041. */
  45042. constructor(
  45043. /**
  45044. * Define the instrumented engine.
  45045. */
  45046. engine: Engine);
  45047. /**
  45048. * Dispose and release associated resources.
  45049. */
  45050. dispose(): void;
  45051. }
  45052. }
  45053. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45054. import { PerfCounter } from "babylonjs/Misc/tools";
  45055. import { Scene, IDisposable } from "babylonjs/scene";
  45056. /**
  45057. * This class can be used to get instrumentation data from a Babylon engine
  45058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45059. */
  45060. export class SceneInstrumentation implements IDisposable {
  45061. /**
  45062. * Defines the scene to instrument
  45063. */
  45064. scene: Scene;
  45065. private _captureActiveMeshesEvaluationTime;
  45066. private _activeMeshesEvaluationTime;
  45067. private _captureRenderTargetsRenderTime;
  45068. private _renderTargetsRenderTime;
  45069. private _captureFrameTime;
  45070. private _frameTime;
  45071. private _captureRenderTime;
  45072. private _renderTime;
  45073. private _captureInterFrameTime;
  45074. private _interFrameTime;
  45075. private _captureParticlesRenderTime;
  45076. private _particlesRenderTime;
  45077. private _captureSpritesRenderTime;
  45078. private _spritesRenderTime;
  45079. private _capturePhysicsTime;
  45080. private _physicsTime;
  45081. private _captureAnimationsTime;
  45082. private _animationsTime;
  45083. private _captureCameraRenderTime;
  45084. private _cameraRenderTime;
  45085. private _onBeforeActiveMeshesEvaluationObserver;
  45086. private _onAfterActiveMeshesEvaluationObserver;
  45087. private _onBeforeRenderTargetsRenderObserver;
  45088. private _onAfterRenderTargetsRenderObserver;
  45089. private _onAfterRenderObserver;
  45090. private _onBeforeDrawPhaseObserver;
  45091. private _onAfterDrawPhaseObserver;
  45092. private _onBeforeAnimationsObserver;
  45093. private _onBeforeParticlesRenderingObserver;
  45094. private _onAfterParticlesRenderingObserver;
  45095. private _onBeforeSpritesRenderingObserver;
  45096. private _onAfterSpritesRenderingObserver;
  45097. private _onBeforePhysicsObserver;
  45098. private _onAfterPhysicsObserver;
  45099. private _onAfterAnimationsObserver;
  45100. private _onBeforeCameraRenderObserver;
  45101. private _onAfterCameraRenderObserver;
  45102. /**
  45103. * Gets the perf counter used for active meshes evaluation time
  45104. */
  45105. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45106. /**
  45107. * Gets the active meshes evaluation time capture status
  45108. */
  45109. /**
  45110. * Enable or disable the active meshes evaluation time capture
  45111. */
  45112. captureActiveMeshesEvaluationTime: boolean;
  45113. /**
  45114. * Gets the perf counter used for render targets render time
  45115. */
  45116. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45117. /**
  45118. * Gets the render targets render time capture status
  45119. */
  45120. /**
  45121. * Enable or disable the render targets render time capture
  45122. */
  45123. captureRenderTargetsRenderTime: boolean;
  45124. /**
  45125. * Gets the perf counter used for particles render time
  45126. */
  45127. readonly particlesRenderTimeCounter: PerfCounter;
  45128. /**
  45129. * Gets the particles render time capture status
  45130. */
  45131. /**
  45132. * Enable or disable the particles render time capture
  45133. */
  45134. captureParticlesRenderTime: boolean;
  45135. /**
  45136. * Gets the perf counter used for sprites render time
  45137. */
  45138. readonly spritesRenderTimeCounter: PerfCounter;
  45139. /**
  45140. * Gets the sprites render time capture status
  45141. */
  45142. /**
  45143. * Enable or disable the sprites render time capture
  45144. */
  45145. captureSpritesRenderTime: boolean;
  45146. /**
  45147. * Gets the perf counter used for physics time
  45148. */
  45149. readonly physicsTimeCounter: PerfCounter;
  45150. /**
  45151. * Gets the physics time capture status
  45152. */
  45153. /**
  45154. * Enable or disable the physics time capture
  45155. */
  45156. capturePhysicsTime: boolean;
  45157. /**
  45158. * Gets the perf counter used for animations time
  45159. */
  45160. readonly animationsTimeCounter: PerfCounter;
  45161. /**
  45162. * Gets the animations time capture status
  45163. */
  45164. /**
  45165. * Enable or disable the animations time capture
  45166. */
  45167. captureAnimationsTime: boolean;
  45168. /**
  45169. * Gets the perf counter used for frame time capture
  45170. */
  45171. readonly frameTimeCounter: PerfCounter;
  45172. /**
  45173. * Gets the frame time capture status
  45174. */
  45175. /**
  45176. * Enable or disable the frame time capture
  45177. */
  45178. captureFrameTime: boolean;
  45179. /**
  45180. * Gets the perf counter used for inter-frames time capture
  45181. */
  45182. readonly interFrameTimeCounter: PerfCounter;
  45183. /**
  45184. * Gets the inter-frames time capture status
  45185. */
  45186. /**
  45187. * Enable or disable the inter-frames time capture
  45188. */
  45189. captureInterFrameTime: boolean;
  45190. /**
  45191. * Gets the perf counter used for render time capture
  45192. */
  45193. readonly renderTimeCounter: PerfCounter;
  45194. /**
  45195. * Gets the render time capture status
  45196. */
  45197. /**
  45198. * Enable or disable the render time capture
  45199. */
  45200. captureRenderTime: boolean;
  45201. /**
  45202. * Gets the perf counter used for camera render time capture
  45203. */
  45204. readonly cameraRenderTimeCounter: PerfCounter;
  45205. /**
  45206. * Gets the camera render time capture status
  45207. */
  45208. /**
  45209. * Enable or disable the camera render time capture
  45210. */
  45211. captureCameraRenderTime: boolean;
  45212. /**
  45213. * Gets the perf counter used for draw calls
  45214. */
  45215. readonly drawCallsCounter: PerfCounter;
  45216. /**
  45217. * Gets the perf counter used for texture collisions
  45218. */
  45219. readonly textureCollisionsCounter: PerfCounter;
  45220. /**
  45221. * Instantiates a new scene instrumentation.
  45222. * This class can be used to get instrumentation data from a Babylon engine
  45223. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45224. * @param scene Defines the scene to instrument
  45225. */
  45226. constructor(
  45227. /**
  45228. * Defines the scene to instrument
  45229. */
  45230. scene: Scene);
  45231. /**
  45232. * Dispose and release associated resources.
  45233. */
  45234. dispose(): void;
  45235. }
  45236. }
  45237. declare module "babylonjs/Instrumentation/index" {
  45238. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45239. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45240. export * from "babylonjs/Instrumentation/timeToken";
  45241. }
  45242. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45243. /** @hidden */
  45244. export var glowMapGenerationPixelShader: {
  45245. name: string;
  45246. shader: string;
  45247. };
  45248. }
  45249. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45250. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45251. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45253. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45255. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45256. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45257. /** @hidden */
  45258. export var glowMapGenerationVertexShader: {
  45259. name: string;
  45260. shader: string;
  45261. };
  45262. }
  45263. declare module "babylonjs/Layers/effectLayer" {
  45264. import { Observable } from "babylonjs/Misc/observable";
  45265. import { Nullable } from "babylonjs/types";
  45266. import { Camera } from "babylonjs/Cameras/camera";
  45267. import { Scene } from "babylonjs/scene";
  45268. import { Color4, ISize } from "babylonjs/Maths/math";
  45269. import { Engine } from "babylonjs/Engines/engine";
  45270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45272. import { Mesh } from "babylonjs/Meshes/mesh";
  45273. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45274. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45275. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45276. import { Effect } from "babylonjs/Materials/effect";
  45277. import { Material } from "babylonjs/Materials/material";
  45278. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45279. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45280. /**
  45281. * Effect layer options. This helps customizing the behaviour
  45282. * of the effect layer.
  45283. */
  45284. export interface IEffectLayerOptions {
  45285. /**
  45286. * Multiplication factor apply to the canvas size to compute the render target size
  45287. * used to generated the objects (the smaller the faster).
  45288. */
  45289. mainTextureRatio: number;
  45290. /**
  45291. * Enforces a fixed size texture to ensure effect stability across devices.
  45292. */
  45293. mainTextureFixedSize?: number;
  45294. /**
  45295. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45296. */
  45297. alphaBlendingMode: number;
  45298. /**
  45299. * The camera attached to the layer.
  45300. */
  45301. camera: Nullable<Camera>;
  45302. /**
  45303. * The rendering group to draw the layer in.
  45304. */
  45305. renderingGroupId: number;
  45306. }
  45307. /**
  45308. * The effect layer Helps adding post process effect blended with the main pass.
  45309. *
  45310. * This can be for instance use to generate glow or higlight effects on the scene.
  45311. *
  45312. * The effect layer class can not be used directly and is intented to inherited from to be
  45313. * customized per effects.
  45314. */
  45315. export abstract class EffectLayer {
  45316. private _vertexBuffers;
  45317. private _indexBuffer;
  45318. private _cachedDefines;
  45319. private _effectLayerMapGenerationEffect;
  45320. private _effectLayerOptions;
  45321. private _mergeEffect;
  45322. protected _scene: Scene;
  45323. protected _engine: Engine;
  45324. protected _maxSize: number;
  45325. protected _mainTextureDesiredSize: ISize;
  45326. protected _mainTexture: RenderTargetTexture;
  45327. protected _shouldRender: boolean;
  45328. protected _postProcesses: PostProcess[];
  45329. protected _textures: BaseTexture[];
  45330. protected _emissiveTextureAndColor: {
  45331. texture: Nullable<BaseTexture>;
  45332. color: Color4;
  45333. };
  45334. /**
  45335. * The name of the layer
  45336. */
  45337. name: string;
  45338. /**
  45339. * The clear color of the texture used to generate the glow map.
  45340. */
  45341. neutralColor: Color4;
  45342. /**
  45343. * Specifies wether the highlight layer is enabled or not.
  45344. */
  45345. isEnabled: boolean;
  45346. /**
  45347. * Gets the camera attached to the layer.
  45348. */
  45349. readonly camera: Nullable<Camera>;
  45350. /**
  45351. * Gets the rendering group id the layer should render in.
  45352. */
  45353. readonly renderingGroupId: number;
  45354. /**
  45355. * An event triggered when the effect layer has been disposed.
  45356. */
  45357. onDisposeObservable: Observable<EffectLayer>;
  45358. /**
  45359. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45360. */
  45361. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45362. /**
  45363. * An event triggered when the generated texture is being merged in the scene.
  45364. */
  45365. onBeforeComposeObservable: Observable<EffectLayer>;
  45366. /**
  45367. * An event triggered when the generated texture has been merged in the scene.
  45368. */
  45369. onAfterComposeObservable: Observable<EffectLayer>;
  45370. /**
  45371. * An event triggered when the efffect layer changes its size.
  45372. */
  45373. onSizeChangedObservable: Observable<EffectLayer>;
  45374. /** @hidden */
  45375. static _SceneComponentInitialization: (scene: Scene) => void;
  45376. /**
  45377. * Instantiates a new effect Layer and references it in the scene.
  45378. * @param name The name of the layer
  45379. * @param scene The scene to use the layer in
  45380. */
  45381. constructor(
  45382. /** The Friendly of the effect in the scene */
  45383. name: string, scene: Scene);
  45384. /**
  45385. * Get the effect name of the layer.
  45386. * @return The effect name
  45387. */
  45388. abstract getEffectName(): string;
  45389. /**
  45390. * Checks for the readiness of the element composing the layer.
  45391. * @param subMesh the mesh to check for
  45392. * @param useInstances specify wether or not to use instances to render the mesh
  45393. * @return true if ready otherwise, false
  45394. */
  45395. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45396. /**
  45397. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45398. * @returns true if the effect requires stencil during the main canvas render pass.
  45399. */
  45400. abstract needStencil(): boolean;
  45401. /**
  45402. * Create the merge effect. This is the shader use to blit the information back
  45403. * to the main canvas at the end of the scene rendering.
  45404. * @returns The effect containing the shader used to merge the effect on the main canvas
  45405. */
  45406. protected abstract _createMergeEffect(): Effect;
  45407. /**
  45408. * Creates the render target textures and post processes used in the effect layer.
  45409. */
  45410. protected abstract _createTextureAndPostProcesses(): void;
  45411. /**
  45412. * Implementation specific of rendering the generating effect on the main canvas.
  45413. * @param effect The effect used to render through
  45414. */
  45415. protected abstract _internalRender(effect: Effect): void;
  45416. /**
  45417. * Sets the required values for both the emissive texture and and the main color.
  45418. */
  45419. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45420. /**
  45421. * Free any resources and references associated to a mesh.
  45422. * Internal use
  45423. * @param mesh The mesh to free.
  45424. */
  45425. abstract _disposeMesh(mesh: Mesh): void;
  45426. /**
  45427. * Serializes this layer (Glow or Highlight for example)
  45428. * @returns a serialized layer object
  45429. */
  45430. abstract serialize?(): any;
  45431. /**
  45432. * Initializes the effect layer with the required options.
  45433. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45434. */
  45435. protected _init(options: Partial<IEffectLayerOptions>): void;
  45436. /**
  45437. * Generates the index buffer of the full screen quad blending to the main canvas.
  45438. */
  45439. private _generateIndexBuffer;
  45440. /**
  45441. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45442. */
  45443. private _genrateVertexBuffer;
  45444. /**
  45445. * Sets the main texture desired size which is the closest power of two
  45446. * of the engine canvas size.
  45447. */
  45448. private _setMainTextureSize;
  45449. /**
  45450. * Creates the main texture for the effect layer.
  45451. */
  45452. protected _createMainTexture(): void;
  45453. /**
  45454. * Adds specific effects defines.
  45455. * @param defines The defines to add specifics to.
  45456. */
  45457. protected _addCustomEffectDefines(defines: string[]): void;
  45458. /**
  45459. * Checks for the readiness of the element composing the layer.
  45460. * @param subMesh the mesh to check for
  45461. * @param useInstances specify wether or not to use instances to render the mesh
  45462. * @param emissiveTexture the associated emissive texture used to generate the glow
  45463. * @return true if ready otherwise, false
  45464. */
  45465. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45466. /**
  45467. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45468. */
  45469. render(): void;
  45470. /**
  45471. * Determine if a given mesh will be used in the current effect.
  45472. * @param mesh mesh to test
  45473. * @returns true if the mesh will be used
  45474. */
  45475. hasMesh(mesh: AbstractMesh): boolean;
  45476. /**
  45477. * Returns true if the layer contains information to display, otherwise false.
  45478. * @returns true if the glow layer should be rendered
  45479. */
  45480. shouldRender(): boolean;
  45481. /**
  45482. * Returns true if the mesh should render, otherwise false.
  45483. * @param mesh The mesh to render
  45484. * @returns true if it should render otherwise false
  45485. */
  45486. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45487. /**
  45488. * Returns true if the mesh can be rendered, otherwise false.
  45489. * @param mesh The mesh to render
  45490. * @param material The material used on the mesh
  45491. * @returns true if it can be rendered otherwise false
  45492. */
  45493. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45494. /**
  45495. * Returns true if the mesh should render, otherwise false.
  45496. * @param mesh The mesh to render
  45497. * @returns true if it should render otherwise false
  45498. */
  45499. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45500. /**
  45501. * Renders the submesh passed in parameter to the generation map.
  45502. */
  45503. protected _renderSubMesh(subMesh: SubMesh): void;
  45504. /**
  45505. * Rebuild the required buffers.
  45506. * @hidden Internal use only.
  45507. */
  45508. _rebuild(): void;
  45509. /**
  45510. * Dispose only the render target textures and post process.
  45511. */
  45512. private _disposeTextureAndPostProcesses;
  45513. /**
  45514. * Dispose the highlight layer and free resources.
  45515. */
  45516. dispose(): void;
  45517. /**
  45518. * Gets the class name of the effect layer
  45519. * @returns the string with the class name of the effect layer
  45520. */
  45521. getClassName(): string;
  45522. /**
  45523. * Creates an effect layer from parsed effect layer data
  45524. * @param parsedEffectLayer defines effect layer data
  45525. * @param scene defines the current scene
  45526. * @param rootUrl defines the root URL containing the effect layer information
  45527. * @returns a parsed effect Layer
  45528. */
  45529. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45530. }
  45531. }
  45532. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45533. import { Scene } from "babylonjs/scene";
  45534. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45535. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45536. import { AbstractScene } from "babylonjs/abstractScene";
  45537. module "babylonjs/abstractScene" {
  45538. interface AbstractScene {
  45539. /**
  45540. * The list of effect layers (highlights/glow) added to the scene
  45541. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45542. * @see http://doc.babylonjs.com/how_to/glow_layer
  45543. */
  45544. effectLayers: Array<EffectLayer>;
  45545. /**
  45546. * Removes the given effect layer from this scene.
  45547. * @param toRemove defines the effect layer to remove
  45548. * @returns the index of the removed effect layer
  45549. */
  45550. removeEffectLayer(toRemove: EffectLayer): number;
  45551. /**
  45552. * Adds the given effect layer to this scene
  45553. * @param newEffectLayer defines the effect layer to add
  45554. */
  45555. addEffectLayer(newEffectLayer: EffectLayer): void;
  45556. }
  45557. }
  45558. /**
  45559. * Defines the layer scene component responsible to manage any effect layers
  45560. * in a given scene.
  45561. */
  45562. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45563. /**
  45564. * The component name helpfull to identify the component in the list of scene components.
  45565. */
  45566. readonly name: string;
  45567. /**
  45568. * The scene the component belongs to.
  45569. */
  45570. scene: Scene;
  45571. private _engine;
  45572. private _renderEffects;
  45573. private _needStencil;
  45574. private _previousStencilState;
  45575. /**
  45576. * Creates a new instance of the component for the given scene
  45577. * @param scene Defines the scene to register the component in
  45578. */
  45579. constructor(scene: Scene);
  45580. /**
  45581. * Registers the component in a given scene
  45582. */
  45583. register(): void;
  45584. /**
  45585. * Rebuilds the elements related to this component in case of
  45586. * context lost for instance.
  45587. */
  45588. rebuild(): void;
  45589. /**
  45590. * Serializes the component data to the specified json object
  45591. * @param serializationObject The object to serialize to
  45592. */
  45593. serialize(serializationObject: any): void;
  45594. /**
  45595. * Adds all the element from the container to the scene
  45596. * @param container the container holding the elements
  45597. */
  45598. addFromContainer(container: AbstractScene): void;
  45599. /**
  45600. * Removes all the elements in the container from the scene
  45601. * @param container contains the elements to remove
  45602. */
  45603. removeFromContainer(container: AbstractScene): void;
  45604. /**
  45605. * Disposes the component and the associated ressources.
  45606. */
  45607. dispose(): void;
  45608. private _isReadyForMesh;
  45609. private _renderMainTexture;
  45610. private _setStencil;
  45611. private _setStencilBack;
  45612. private _draw;
  45613. private _drawCamera;
  45614. private _drawRenderingGroup;
  45615. }
  45616. }
  45617. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45618. /** @hidden */
  45619. export var glowMapMergePixelShader: {
  45620. name: string;
  45621. shader: string;
  45622. };
  45623. }
  45624. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45625. /** @hidden */
  45626. export var glowMapMergeVertexShader: {
  45627. name: string;
  45628. shader: string;
  45629. };
  45630. }
  45631. declare module "babylonjs/Layers/glowLayer" {
  45632. import { Nullable } from "babylonjs/types";
  45633. import { Camera } from "babylonjs/Cameras/camera";
  45634. import { Scene } from "babylonjs/scene";
  45635. import { Color4 } from "babylonjs/Maths/math";
  45636. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45638. import { Mesh } from "babylonjs/Meshes/mesh";
  45639. import { Texture } from "babylonjs/Materials/Textures/texture";
  45640. import { Effect } from "babylonjs/Materials/effect";
  45641. import { Material } from "babylonjs/Materials/material";
  45642. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45643. import "babylonjs/Shaders/glowMapMerge.fragment";
  45644. import "babylonjs/Shaders/glowMapMerge.vertex";
  45645. module "babylonjs/abstractScene" {
  45646. interface AbstractScene {
  45647. /**
  45648. * Return a the first highlight layer of the scene with a given name.
  45649. * @param name The name of the highlight layer to look for.
  45650. * @return The highlight layer if found otherwise null.
  45651. */
  45652. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45653. }
  45654. }
  45655. /**
  45656. * Glow layer options. This helps customizing the behaviour
  45657. * of the glow layer.
  45658. */
  45659. export interface IGlowLayerOptions {
  45660. /**
  45661. * Multiplication factor apply to the canvas size to compute the render target size
  45662. * used to generated the glowing objects (the smaller the faster).
  45663. */
  45664. mainTextureRatio: number;
  45665. /**
  45666. * Enforces a fixed size texture to ensure resize independant blur.
  45667. */
  45668. mainTextureFixedSize?: number;
  45669. /**
  45670. * How big is the kernel of the blur texture.
  45671. */
  45672. blurKernelSize: number;
  45673. /**
  45674. * The camera attached to the layer.
  45675. */
  45676. camera: Nullable<Camera>;
  45677. /**
  45678. * Enable MSAA by chosing the number of samples.
  45679. */
  45680. mainTextureSamples?: number;
  45681. /**
  45682. * The rendering group to draw the layer in.
  45683. */
  45684. renderingGroupId: number;
  45685. }
  45686. /**
  45687. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45688. *
  45689. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45690. * glowy meshes to your scene.
  45691. *
  45692. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45693. */
  45694. export class GlowLayer extends EffectLayer {
  45695. /**
  45696. * Effect Name of the layer.
  45697. */
  45698. static readonly EffectName: string;
  45699. /**
  45700. * The default blur kernel size used for the glow.
  45701. */
  45702. static DefaultBlurKernelSize: number;
  45703. /**
  45704. * The default texture size ratio used for the glow.
  45705. */
  45706. static DefaultTextureRatio: number;
  45707. /**
  45708. * Sets the kernel size of the blur.
  45709. */
  45710. /**
  45711. * Gets the kernel size of the blur.
  45712. */
  45713. blurKernelSize: number;
  45714. /**
  45715. * Sets the glow intensity.
  45716. */
  45717. /**
  45718. * Gets the glow intensity.
  45719. */
  45720. intensity: number;
  45721. private _options;
  45722. private _intensity;
  45723. private _horizontalBlurPostprocess1;
  45724. private _verticalBlurPostprocess1;
  45725. private _horizontalBlurPostprocess2;
  45726. private _verticalBlurPostprocess2;
  45727. private _blurTexture1;
  45728. private _blurTexture2;
  45729. private _postProcesses1;
  45730. private _postProcesses2;
  45731. private _includedOnlyMeshes;
  45732. private _excludedMeshes;
  45733. /**
  45734. * Callback used to let the user override the color selection on a per mesh basis
  45735. */
  45736. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45737. /**
  45738. * Callback used to let the user override the texture selection on a per mesh basis
  45739. */
  45740. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45741. /**
  45742. * Instantiates a new glow Layer and references it to the scene.
  45743. * @param name The name of the layer
  45744. * @param scene The scene to use the layer in
  45745. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45746. */
  45747. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45748. /**
  45749. * Get the effect name of the layer.
  45750. * @return The effect name
  45751. */
  45752. getEffectName(): string;
  45753. /**
  45754. * Create the merge effect. This is the shader use to blit the information back
  45755. * to the main canvas at the end of the scene rendering.
  45756. */
  45757. protected _createMergeEffect(): Effect;
  45758. /**
  45759. * Creates the render target textures and post processes used in the glow layer.
  45760. */
  45761. protected _createTextureAndPostProcesses(): void;
  45762. /**
  45763. * Checks for the readiness of the element composing the layer.
  45764. * @param subMesh the mesh to check for
  45765. * @param useInstances specify wether or not to use instances to render the mesh
  45766. * @param emissiveTexture the associated emissive texture used to generate the glow
  45767. * @return true if ready otherwise, false
  45768. */
  45769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45770. /**
  45771. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45772. */
  45773. needStencil(): boolean;
  45774. /**
  45775. * Returns true if the mesh can be rendered, otherwise false.
  45776. * @param mesh The mesh to render
  45777. * @param material The material used on the mesh
  45778. * @returns true if it can be rendered otherwise false
  45779. */
  45780. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45781. /**
  45782. * Implementation specific of rendering the generating effect on the main canvas.
  45783. * @param effect The effect used to render through
  45784. */
  45785. protected _internalRender(effect: Effect): void;
  45786. /**
  45787. * Sets the required values for both the emissive texture and and the main color.
  45788. */
  45789. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45790. /**
  45791. * Returns true if the mesh should render, otherwise false.
  45792. * @param mesh The mesh to render
  45793. * @returns true if it should render otherwise false
  45794. */
  45795. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45796. /**
  45797. * Adds specific effects defines.
  45798. * @param defines The defines to add specifics to.
  45799. */
  45800. protected _addCustomEffectDefines(defines: string[]): void;
  45801. /**
  45802. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45803. * @param mesh The mesh to exclude from the glow layer
  45804. */
  45805. addExcludedMesh(mesh: Mesh): void;
  45806. /**
  45807. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45808. * @param mesh The mesh to remove
  45809. */
  45810. removeExcludedMesh(mesh: Mesh): void;
  45811. /**
  45812. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45813. * @param mesh The mesh to include in the glow layer
  45814. */
  45815. addIncludedOnlyMesh(mesh: Mesh): void;
  45816. /**
  45817. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45818. * @param mesh The mesh to remove
  45819. */
  45820. removeIncludedOnlyMesh(mesh: Mesh): void;
  45821. /**
  45822. * Determine if a given mesh will be used in the glow layer
  45823. * @param mesh The mesh to test
  45824. * @returns true if the mesh will be highlighted by the current glow layer
  45825. */
  45826. hasMesh(mesh: AbstractMesh): boolean;
  45827. /**
  45828. * Free any resources and references associated to a mesh.
  45829. * Internal use
  45830. * @param mesh The mesh to free.
  45831. * @hidden
  45832. */
  45833. _disposeMesh(mesh: Mesh): void;
  45834. /**
  45835. * Gets the class name of the effect layer
  45836. * @returns the string with the class name of the effect layer
  45837. */
  45838. getClassName(): string;
  45839. /**
  45840. * Serializes this glow layer
  45841. * @returns a serialized glow layer object
  45842. */
  45843. serialize(): any;
  45844. /**
  45845. * Creates a Glow Layer from parsed glow layer data
  45846. * @param parsedGlowLayer defines glow layer data
  45847. * @param scene defines the current scene
  45848. * @param rootUrl defines the root URL containing the glow layer information
  45849. * @returns a parsed Glow Layer
  45850. */
  45851. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  45852. }
  45853. }
  45854. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  45855. /** @hidden */
  45856. export var glowBlurPostProcessPixelShader: {
  45857. name: string;
  45858. shader: string;
  45859. };
  45860. }
  45861. declare module "babylonjs/Layers/highlightLayer" {
  45862. import { Observable } from "babylonjs/Misc/observable";
  45863. import { Nullable } from "babylonjs/types";
  45864. import { Camera } from "babylonjs/Cameras/camera";
  45865. import { Scene } from "babylonjs/scene";
  45866. import { Color3, Color4 } from "babylonjs/Maths/math";
  45867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45869. import { Mesh } from "babylonjs/Meshes/mesh";
  45870. import { Effect } from "babylonjs/Materials/effect";
  45871. import { Material } from "babylonjs/Materials/material";
  45872. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45873. import "babylonjs/Shaders/glowMapMerge.fragment";
  45874. import "babylonjs/Shaders/glowMapMerge.vertex";
  45875. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  45876. module "babylonjs/abstractScene" {
  45877. interface AbstractScene {
  45878. /**
  45879. * Return a the first highlight layer of the scene with a given name.
  45880. * @param name The name of the highlight layer to look for.
  45881. * @return The highlight layer if found otherwise null.
  45882. */
  45883. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  45884. }
  45885. }
  45886. /**
  45887. * Highlight layer options. This helps customizing the behaviour
  45888. * of the highlight layer.
  45889. */
  45890. export interface IHighlightLayerOptions {
  45891. /**
  45892. * Multiplication factor apply to the canvas size to compute the render target size
  45893. * used to generated the glowing objects (the smaller the faster).
  45894. */
  45895. mainTextureRatio: number;
  45896. /**
  45897. * Enforces a fixed size texture to ensure resize independant blur.
  45898. */
  45899. mainTextureFixedSize?: number;
  45900. /**
  45901. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  45902. * of the picture to blur (the smaller the faster).
  45903. */
  45904. blurTextureSizeRatio: number;
  45905. /**
  45906. * How big in texel of the blur texture is the vertical blur.
  45907. */
  45908. blurVerticalSize: number;
  45909. /**
  45910. * How big in texel of the blur texture is the horizontal blur.
  45911. */
  45912. blurHorizontalSize: number;
  45913. /**
  45914. * Alpha blending mode used to apply the blur. Default is combine.
  45915. */
  45916. alphaBlendingMode: number;
  45917. /**
  45918. * The camera attached to the layer.
  45919. */
  45920. camera: Nullable<Camera>;
  45921. /**
  45922. * Should we display highlight as a solid stroke?
  45923. */
  45924. isStroke?: boolean;
  45925. /**
  45926. * The rendering group to draw the layer in.
  45927. */
  45928. renderingGroupId: number;
  45929. }
  45930. /**
  45931. * The highlight layer Helps adding a glow effect around a mesh.
  45932. *
  45933. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45934. * glowy meshes to your scene.
  45935. *
  45936. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  45937. */
  45938. export class HighlightLayer extends EffectLayer {
  45939. name: string;
  45940. /**
  45941. * Effect Name of the highlight layer.
  45942. */
  45943. static readonly EffectName: string;
  45944. /**
  45945. * The neutral color used during the preparation of the glow effect.
  45946. * This is black by default as the blend operation is a blend operation.
  45947. */
  45948. static NeutralColor: Color4;
  45949. /**
  45950. * Stencil value used for glowing meshes.
  45951. */
  45952. static GlowingMeshStencilReference: number;
  45953. /**
  45954. * Stencil value used for the other meshes in the scene.
  45955. */
  45956. static NormalMeshStencilReference: number;
  45957. /**
  45958. * Specifies whether or not the inner glow is ACTIVE in the layer.
  45959. */
  45960. innerGlow: boolean;
  45961. /**
  45962. * Specifies whether or not the outer glow is ACTIVE in the layer.
  45963. */
  45964. outerGlow: boolean;
  45965. /**
  45966. * Specifies the horizontal size of the blur.
  45967. */
  45968. /**
  45969. * Gets the horizontal size of the blur.
  45970. */
  45971. blurHorizontalSize: number;
  45972. /**
  45973. * Specifies the vertical size of the blur.
  45974. */
  45975. /**
  45976. * Gets the vertical size of the blur.
  45977. */
  45978. blurVerticalSize: number;
  45979. /**
  45980. * An event triggered when the highlight layer is being blurred.
  45981. */
  45982. onBeforeBlurObservable: Observable<HighlightLayer>;
  45983. /**
  45984. * An event triggered when the highlight layer has been blurred.
  45985. */
  45986. onAfterBlurObservable: Observable<HighlightLayer>;
  45987. private _instanceGlowingMeshStencilReference;
  45988. private _options;
  45989. private _downSamplePostprocess;
  45990. private _horizontalBlurPostprocess;
  45991. private _verticalBlurPostprocess;
  45992. private _blurTexture;
  45993. private _meshes;
  45994. private _excludedMeshes;
  45995. /**
  45996. * Instantiates a new highlight Layer and references it to the scene..
  45997. * @param name The name of the layer
  45998. * @param scene The scene to use the layer in
  45999. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46000. */
  46001. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46002. /**
  46003. * Get the effect name of the layer.
  46004. * @return The effect name
  46005. */
  46006. getEffectName(): string;
  46007. /**
  46008. * Create the merge effect. This is the shader use to blit the information back
  46009. * to the main canvas at the end of the scene rendering.
  46010. */
  46011. protected _createMergeEffect(): Effect;
  46012. /**
  46013. * Creates the render target textures and post processes used in the highlight layer.
  46014. */
  46015. protected _createTextureAndPostProcesses(): void;
  46016. /**
  46017. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46018. */
  46019. needStencil(): boolean;
  46020. /**
  46021. * Checks for the readiness of the element composing the layer.
  46022. * @param subMesh the mesh to check for
  46023. * @param useInstances specify wether or not to use instances to render the mesh
  46024. * @param emissiveTexture the associated emissive texture used to generate the glow
  46025. * @return true if ready otherwise, false
  46026. */
  46027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46028. /**
  46029. * Implementation specific of rendering the generating effect on the main canvas.
  46030. * @param effect The effect used to render through
  46031. */
  46032. protected _internalRender(effect: Effect): void;
  46033. /**
  46034. * Returns true if the layer contains information to display, otherwise false.
  46035. */
  46036. shouldRender(): boolean;
  46037. /**
  46038. * Returns true if the mesh should render, otherwise false.
  46039. * @param mesh The mesh to render
  46040. * @returns true if it should render otherwise false
  46041. */
  46042. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46043. /**
  46044. * Sets the required values for both the emissive texture and and the main color.
  46045. */
  46046. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46047. /**
  46048. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46049. * @param mesh The mesh to exclude from the highlight layer
  46050. */
  46051. addExcludedMesh(mesh: Mesh): void;
  46052. /**
  46053. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46054. * @param mesh The mesh to highlight
  46055. */
  46056. removeExcludedMesh(mesh: Mesh): void;
  46057. /**
  46058. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46059. * @param mesh mesh to test
  46060. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46061. */
  46062. hasMesh(mesh: AbstractMesh): boolean;
  46063. /**
  46064. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46065. * @param mesh The mesh to highlight
  46066. * @param color The color of the highlight
  46067. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46068. */
  46069. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46070. /**
  46071. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46072. * @param mesh The mesh to highlight
  46073. */
  46074. removeMesh(mesh: Mesh): void;
  46075. /**
  46076. * Force the stencil to the normal expected value for none glowing parts
  46077. */
  46078. private _defaultStencilReference;
  46079. /**
  46080. * Free any resources and references associated to a mesh.
  46081. * Internal use
  46082. * @param mesh The mesh to free.
  46083. * @hidden
  46084. */
  46085. _disposeMesh(mesh: Mesh): void;
  46086. /**
  46087. * Dispose the highlight layer and free resources.
  46088. */
  46089. dispose(): void;
  46090. /**
  46091. * Gets the class name of the effect layer
  46092. * @returns the string with the class name of the effect layer
  46093. */
  46094. getClassName(): string;
  46095. /**
  46096. * Serializes this Highlight layer
  46097. * @returns a serialized Highlight layer object
  46098. */
  46099. serialize(): any;
  46100. /**
  46101. * Creates a Highlight layer from parsed Highlight layer data
  46102. * @param parsedHightlightLayer defines the Highlight layer data
  46103. * @param scene defines the current scene
  46104. * @param rootUrl defines the root URL containing the Highlight layer information
  46105. * @returns a parsed Highlight layer
  46106. */
  46107. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46108. }
  46109. }
  46110. declare module "babylonjs/Layers/index" {
  46111. export * from "babylonjs/Layers/effectLayer";
  46112. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46113. export * from "babylonjs/Layers/glowLayer";
  46114. export * from "babylonjs/Layers/highlightLayer";
  46115. export * from "babylonjs/Layers/layer";
  46116. export * from "babylonjs/Layers/layerSceneComponent";
  46117. }
  46118. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46119. /** @hidden */
  46120. export var lensFlarePixelShader: {
  46121. name: string;
  46122. shader: string;
  46123. };
  46124. }
  46125. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46126. /** @hidden */
  46127. export var lensFlareVertexShader: {
  46128. name: string;
  46129. shader: string;
  46130. };
  46131. }
  46132. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46133. import { Scene } from "babylonjs/scene";
  46134. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46136. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46137. import "babylonjs/Shaders/lensFlare.fragment";
  46138. import "babylonjs/Shaders/lensFlare.vertex";
  46139. /**
  46140. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46141. * It is usually composed of several `lensFlare`.
  46142. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46143. */
  46144. export class LensFlareSystem {
  46145. /**
  46146. * Define the name of the lens flare system
  46147. */
  46148. name: string;
  46149. /**
  46150. * List of lens flares used in this system.
  46151. */
  46152. lensFlares: LensFlare[];
  46153. /**
  46154. * Define a limit from the border the lens flare can be visible.
  46155. */
  46156. borderLimit: number;
  46157. /**
  46158. * Define a viewport border we do not want to see the lens flare in.
  46159. */
  46160. viewportBorder: number;
  46161. /**
  46162. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46163. */
  46164. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46165. /**
  46166. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46167. */
  46168. layerMask: number;
  46169. /**
  46170. * Define the id of the lens flare system in the scene.
  46171. * (equal to name by default)
  46172. */
  46173. id: string;
  46174. private _scene;
  46175. private _emitter;
  46176. private _vertexBuffers;
  46177. private _indexBuffer;
  46178. private _effect;
  46179. private _positionX;
  46180. private _positionY;
  46181. private _isEnabled;
  46182. /** @hidden */
  46183. static _SceneComponentInitialization: (scene: Scene) => void;
  46184. /**
  46185. * Instantiates a lens flare system.
  46186. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46187. * It is usually composed of several `lensFlare`.
  46188. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46189. * @param name Define the name of the lens flare system in the scene
  46190. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46191. * @param scene Define the scene the lens flare system belongs to
  46192. */
  46193. constructor(
  46194. /**
  46195. * Define the name of the lens flare system
  46196. */
  46197. name: string, emitter: any, scene: Scene);
  46198. /**
  46199. * Define if the lens flare system is enabled.
  46200. */
  46201. isEnabled: boolean;
  46202. /**
  46203. * Get the scene the effects belongs to.
  46204. * @returns the scene holding the lens flare system
  46205. */
  46206. getScene(): Scene;
  46207. /**
  46208. * Get the emitter of the lens flare system.
  46209. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46210. * @returns the emitter of the lens flare system
  46211. */
  46212. getEmitter(): any;
  46213. /**
  46214. * Set the emitter of the lens flare system.
  46215. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46216. * @param newEmitter Define the new emitter of the system
  46217. */
  46218. setEmitter(newEmitter: any): void;
  46219. /**
  46220. * Get the lens flare system emitter position.
  46221. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46222. * @returns the position
  46223. */
  46224. getEmitterPosition(): Vector3;
  46225. /**
  46226. * @hidden
  46227. */
  46228. computeEffectivePosition(globalViewport: Viewport): boolean;
  46229. /** @hidden */
  46230. _isVisible(): boolean;
  46231. /**
  46232. * @hidden
  46233. */
  46234. render(): boolean;
  46235. /**
  46236. * Dispose and release the lens flare with its associated resources.
  46237. */
  46238. dispose(): void;
  46239. /**
  46240. * Parse a lens flare system from a JSON repressentation
  46241. * @param parsedLensFlareSystem Define the JSON to parse
  46242. * @param scene Define the scene the parsed system should be instantiated in
  46243. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46244. * @returns the parsed system
  46245. */
  46246. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46247. /**
  46248. * Serialize the current Lens Flare System into a JSON representation.
  46249. * @returns the serialized JSON
  46250. */
  46251. serialize(): any;
  46252. }
  46253. }
  46254. declare module "babylonjs/LensFlares/lensFlare" {
  46255. import { Nullable } from "babylonjs/types";
  46256. import { Color3 } from "babylonjs/Maths/math";
  46257. import { Texture } from "babylonjs/Materials/Textures/texture";
  46258. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46259. /**
  46260. * This represents one of the lens effect in a `lensFlareSystem`.
  46261. * It controls one of the indiviual texture used in the effect.
  46262. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46263. */
  46264. export class LensFlare {
  46265. /**
  46266. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46267. */
  46268. size: number;
  46269. /**
  46270. * 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.
  46271. */
  46272. position: number;
  46273. /**
  46274. * Define the lens color.
  46275. */
  46276. color: Color3;
  46277. /**
  46278. * Define the lens texture.
  46279. */
  46280. texture: Nullable<Texture>;
  46281. /**
  46282. * Define the alpha mode to render this particular lens.
  46283. */
  46284. alphaMode: number;
  46285. private _system;
  46286. /**
  46287. * Creates a new Lens Flare.
  46288. * This represents one of the lens effect in a `lensFlareSystem`.
  46289. * It controls one of the indiviual texture used in the effect.
  46290. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46291. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46292. * @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.
  46293. * @param color Define the lens color
  46294. * @param imgUrl Define the lens texture url
  46295. * @param system Define the `lensFlareSystem` this flare is part of
  46296. * @returns The newly created Lens Flare
  46297. */
  46298. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46299. /**
  46300. * Instantiates a new Lens Flare.
  46301. * This represents one of the lens effect in a `lensFlareSystem`.
  46302. * It controls one of the indiviual texture used in the effect.
  46303. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46304. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46305. * @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.
  46306. * @param color Define the lens color
  46307. * @param imgUrl Define the lens texture url
  46308. * @param system Define the `lensFlareSystem` this flare is part of
  46309. */
  46310. constructor(
  46311. /**
  46312. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46313. */
  46314. size: number,
  46315. /**
  46316. * 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.
  46317. */
  46318. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46319. /**
  46320. * Dispose and release the lens flare with its associated resources.
  46321. */
  46322. dispose(): void;
  46323. }
  46324. }
  46325. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46326. import { Nullable } from "babylonjs/types";
  46327. import { Scene } from "babylonjs/scene";
  46328. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46329. import { AbstractScene } from "babylonjs/abstractScene";
  46330. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46331. module "babylonjs/abstractScene" {
  46332. interface AbstractScene {
  46333. /**
  46334. * The list of lens flare system added to the scene
  46335. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46336. */
  46337. lensFlareSystems: Array<LensFlareSystem>;
  46338. /**
  46339. * Removes the given lens flare system from this scene.
  46340. * @param toRemove The lens flare system to remove
  46341. * @returns The index of the removed lens flare system
  46342. */
  46343. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46344. /**
  46345. * Adds the given lens flare system to this scene
  46346. * @param newLensFlareSystem The lens flare system to add
  46347. */
  46348. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46349. /**
  46350. * Gets a lens flare system using its name
  46351. * @param name defines the name to look for
  46352. * @returns the lens flare system or null if not found
  46353. */
  46354. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46355. /**
  46356. * Gets a lens flare system using its id
  46357. * @param id defines the id to look for
  46358. * @returns the lens flare system or null if not found
  46359. */
  46360. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46361. }
  46362. }
  46363. /**
  46364. * Defines the lens flare scene component responsible to manage any lens flares
  46365. * in a given scene.
  46366. */
  46367. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46368. /**
  46369. * The component name helpfull to identify the component in the list of scene components.
  46370. */
  46371. readonly name: string;
  46372. /**
  46373. * The scene the component belongs to.
  46374. */
  46375. scene: Scene;
  46376. /**
  46377. * Creates a new instance of the component for the given scene
  46378. * @param scene Defines the scene to register the component in
  46379. */
  46380. constructor(scene: Scene);
  46381. /**
  46382. * Registers the component in a given scene
  46383. */
  46384. register(): void;
  46385. /**
  46386. * Rebuilds the elements related to this component in case of
  46387. * context lost for instance.
  46388. */
  46389. rebuild(): void;
  46390. /**
  46391. * Adds all the element from the container to the scene
  46392. * @param container the container holding the elements
  46393. */
  46394. addFromContainer(container: AbstractScene): void;
  46395. /**
  46396. * Removes all the elements in the container from the scene
  46397. * @param container contains the elements to remove
  46398. */
  46399. removeFromContainer(container: AbstractScene): void;
  46400. /**
  46401. * Serializes the component data to the specified json object
  46402. * @param serializationObject The object to serialize to
  46403. */
  46404. serialize(serializationObject: any): void;
  46405. /**
  46406. * Disposes the component and the associated ressources.
  46407. */
  46408. dispose(): void;
  46409. private _draw;
  46410. }
  46411. }
  46412. declare module "babylonjs/LensFlares/index" {
  46413. export * from "babylonjs/LensFlares/lensFlare";
  46414. export * from "babylonjs/LensFlares/lensFlareSystem";
  46415. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46416. }
  46417. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46418. import { Scene } from "babylonjs/scene";
  46419. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46420. import { AbstractScene } from "babylonjs/abstractScene";
  46421. /**
  46422. * Defines the shadow generator component responsible to manage any shadow generators
  46423. * in a given scene.
  46424. */
  46425. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46426. /**
  46427. * The component name helpfull to identify the component in the list of scene components.
  46428. */
  46429. readonly name: string;
  46430. /**
  46431. * The scene the component belongs to.
  46432. */
  46433. scene: Scene;
  46434. /**
  46435. * Creates a new instance of the component for the given scene
  46436. * @param scene Defines the scene to register the component in
  46437. */
  46438. constructor(scene: Scene);
  46439. /**
  46440. * Registers the component in a given scene
  46441. */
  46442. register(): void;
  46443. /**
  46444. * Rebuilds the elements related to this component in case of
  46445. * context lost for instance.
  46446. */
  46447. rebuild(): void;
  46448. /**
  46449. * Serializes the component data to the specified json object
  46450. * @param serializationObject The object to serialize to
  46451. */
  46452. serialize(serializationObject: any): void;
  46453. /**
  46454. * Adds all the element from the container to the scene
  46455. * @param container the container holding the elements
  46456. */
  46457. addFromContainer(container: AbstractScene): void;
  46458. /**
  46459. * Removes all the elements in the container from the scene
  46460. * @param container contains the elements to remove
  46461. */
  46462. removeFromContainer(container: AbstractScene): void;
  46463. /**
  46464. * Rebuilds the elements related to this component in case of
  46465. * context lost for instance.
  46466. */
  46467. dispose(): void;
  46468. private _gatherRenderTargets;
  46469. }
  46470. }
  46471. declare module "babylonjs/Lights/Shadows/index" {
  46472. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46473. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46474. }
  46475. declare module "babylonjs/Lights/directionalLight" {
  46476. import { Camera } from "babylonjs/Cameras/camera";
  46477. import { Scene } from "babylonjs/scene";
  46478. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46480. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46481. import { Effect } from "babylonjs/Materials/effect";
  46482. /**
  46483. * A directional light is defined by a direction (what a surprise!).
  46484. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46485. * 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.
  46486. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46487. */
  46488. export class DirectionalLight extends ShadowLight {
  46489. private _shadowFrustumSize;
  46490. /**
  46491. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46492. */
  46493. /**
  46494. * Specifies a fix frustum size for the shadow generation.
  46495. */
  46496. shadowFrustumSize: number;
  46497. private _shadowOrthoScale;
  46498. /**
  46499. * Gets the shadow projection scale against the optimal computed one.
  46500. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46501. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46502. */
  46503. /**
  46504. * Sets the shadow projection scale against the optimal computed one.
  46505. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46506. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46507. */
  46508. shadowOrthoScale: number;
  46509. /**
  46510. * Automatically compute the projection matrix to best fit (including all the casters)
  46511. * on each frame.
  46512. */
  46513. autoUpdateExtends: boolean;
  46514. private _orthoLeft;
  46515. private _orthoRight;
  46516. private _orthoTop;
  46517. private _orthoBottom;
  46518. /**
  46519. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46520. * The directional light is emitted from everywhere in the given direction.
  46521. * It can cast shadows.
  46522. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46523. * @param name The friendly name of the light
  46524. * @param direction The direction of the light
  46525. * @param scene The scene the light belongs to
  46526. */
  46527. constructor(name: string, direction: Vector3, scene: Scene);
  46528. /**
  46529. * Returns the string "DirectionalLight".
  46530. * @return The class name
  46531. */
  46532. getClassName(): string;
  46533. /**
  46534. * Returns the integer 1.
  46535. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46536. */
  46537. getTypeID(): number;
  46538. /**
  46539. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46540. * Returns the DirectionalLight Shadow projection matrix.
  46541. */
  46542. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46543. /**
  46544. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46545. * Returns the DirectionalLight Shadow projection matrix.
  46546. */
  46547. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46548. /**
  46549. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46550. * Returns the DirectionalLight Shadow projection matrix.
  46551. */
  46552. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46553. protected _buildUniformLayout(): void;
  46554. /**
  46555. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46556. * @param effect The effect to update
  46557. * @param lightIndex The index of the light in the effect to update
  46558. * @returns The directional light
  46559. */
  46560. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46561. /**
  46562. * Gets the minZ used for shadow according to both the scene and the light.
  46563. *
  46564. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46565. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46566. * @param activeCamera The camera we are returning the min for
  46567. * @returns the depth min z
  46568. */
  46569. getDepthMinZ(activeCamera: Camera): number;
  46570. /**
  46571. * Gets the maxZ 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 max for
  46576. * @returns the depth max z
  46577. */
  46578. getDepthMaxZ(activeCamera: Camera): number;
  46579. /**
  46580. * Prepares the list of defines specific to the light type.
  46581. * @param defines the list of defines
  46582. * @param lightIndex defines the index of the light for the effect
  46583. */
  46584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46585. }
  46586. }
  46587. declare module "babylonjs/Lights/pointLight" {
  46588. import { Scene } from "babylonjs/scene";
  46589. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46591. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46592. import { Effect } from "babylonjs/Materials/effect";
  46593. /**
  46594. * A point light is a light defined by an unique point in world space.
  46595. * The light is emitted in every direction from this point.
  46596. * A good example of a point light is a standard light bulb.
  46597. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46598. */
  46599. export class PointLight extends ShadowLight {
  46600. private _shadowAngle;
  46601. /**
  46602. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46603. * This specifies what angle the shadow will use to be created.
  46604. *
  46605. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46606. */
  46607. /**
  46608. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46609. * This specifies what angle the shadow will use to be created.
  46610. *
  46611. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46612. */
  46613. shadowAngle: number;
  46614. /**
  46615. * Gets the direction if it has been set.
  46616. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46617. */
  46618. /**
  46619. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46620. */
  46621. direction: Vector3;
  46622. /**
  46623. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46624. * A PointLight emits the light in every direction.
  46625. * It can cast shadows.
  46626. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46627. * ```javascript
  46628. * var pointLight = new PointLight("pl", camera.position, scene);
  46629. * ```
  46630. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46631. * @param name The light friendly name
  46632. * @param position The position of the point light in the scene
  46633. * @param scene The scene the lights belongs to
  46634. */
  46635. constructor(name: string, position: Vector3, scene: Scene);
  46636. /**
  46637. * Returns the string "PointLight"
  46638. * @returns the class name
  46639. */
  46640. getClassName(): string;
  46641. /**
  46642. * Returns the integer 0.
  46643. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46644. */
  46645. getTypeID(): number;
  46646. /**
  46647. * Specifies wether or not the shadowmap should be a cube texture.
  46648. * @returns true if the shadowmap needs to be a cube texture.
  46649. */
  46650. needCube(): boolean;
  46651. /**
  46652. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46653. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46654. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46655. */
  46656. getShadowDirection(faceIndex?: number): Vector3;
  46657. /**
  46658. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46659. * - fov = PI / 2
  46660. * - aspect ratio : 1.0
  46661. * - z-near and far equal to the active camera minZ and maxZ.
  46662. * Returns the PointLight.
  46663. */
  46664. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46665. protected _buildUniformLayout(): void;
  46666. /**
  46667. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46668. * @param effect The effect to update
  46669. * @param lightIndex The index of the light in the effect to update
  46670. * @returns The point light
  46671. */
  46672. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46673. /**
  46674. * Prepares the list of defines specific to the light type.
  46675. * @param defines the list of defines
  46676. * @param lightIndex defines the index of the light for the effect
  46677. */
  46678. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46679. }
  46680. }
  46681. declare module "babylonjs/Lights/spotLight" {
  46682. import { Nullable } from "babylonjs/types";
  46683. import { Scene } from "babylonjs/scene";
  46684. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46686. import { Effect } from "babylonjs/Materials/effect";
  46687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46688. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46689. /**
  46690. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46691. * These values define a cone of light starting from the position, emitting toward the direction.
  46692. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46693. * and the exponent defines the speed of the decay of the light with distance (reach).
  46694. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46695. */
  46696. export class SpotLight extends ShadowLight {
  46697. private _angle;
  46698. private _innerAngle;
  46699. private _cosHalfAngle;
  46700. private _lightAngleScale;
  46701. private _lightAngleOffset;
  46702. /**
  46703. * Gets the cone angle of the spot light in Radians.
  46704. */
  46705. /**
  46706. * Sets the cone angle of the spot light in Radians.
  46707. */
  46708. angle: number;
  46709. /**
  46710. * Only used in gltf falloff mode, this defines the angle where
  46711. * the directional falloff will start before cutting at angle which could be seen
  46712. * as outer angle.
  46713. */
  46714. /**
  46715. * Only used in gltf falloff mode, this defines the angle where
  46716. * the directional falloff will start before cutting at angle which could be seen
  46717. * as outer angle.
  46718. */
  46719. innerAngle: number;
  46720. private _shadowAngleScale;
  46721. /**
  46722. * Allows scaling the angle of the light for shadow generation only.
  46723. */
  46724. /**
  46725. * Allows scaling the angle of the light for shadow generation only.
  46726. */
  46727. shadowAngleScale: number;
  46728. /**
  46729. * The light decay speed with the distance from the emission spot.
  46730. */
  46731. exponent: number;
  46732. private _projectionTextureMatrix;
  46733. /**
  46734. * Allows reading the projecton texture
  46735. */
  46736. readonly projectionTextureMatrix: Matrix;
  46737. protected _projectionTextureLightNear: number;
  46738. /**
  46739. * Gets the near clip of the Spotlight for texture projection.
  46740. */
  46741. /**
  46742. * Sets the near clip of the Spotlight for texture projection.
  46743. */
  46744. projectionTextureLightNear: number;
  46745. protected _projectionTextureLightFar: number;
  46746. /**
  46747. * Gets the far clip of the Spotlight for texture projection.
  46748. */
  46749. /**
  46750. * Sets the far clip of the Spotlight for texture projection.
  46751. */
  46752. projectionTextureLightFar: number;
  46753. protected _projectionTextureUpDirection: Vector3;
  46754. /**
  46755. * Gets the Up vector of the Spotlight for texture projection.
  46756. */
  46757. /**
  46758. * Sets the Up vector of the Spotlight for texture projection.
  46759. */
  46760. projectionTextureUpDirection: Vector3;
  46761. private _projectionTexture;
  46762. /**
  46763. * Gets the projection texture of the light.
  46764. */
  46765. /**
  46766. * Sets the projection texture of the light.
  46767. */
  46768. projectionTexture: Nullable<BaseTexture>;
  46769. private _projectionTextureViewLightDirty;
  46770. private _projectionTextureProjectionLightDirty;
  46771. private _projectionTextureDirty;
  46772. private _projectionTextureViewTargetVector;
  46773. private _projectionTextureViewLightMatrix;
  46774. private _projectionTextureProjectionLightMatrix;
  46775. private _projectionTextureScalingMatrix;
  46776. /**
  46777. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46778. * It can cast shadows.
  46779. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46780. * @param name The light friendly name
  46781. * @param position The position of the spot light in the scene
  46782. * @param direction The direction of the light in the scene
  46783. * @param angle The cone angle of the light in Radians
  46784. * @param exponent The light decay speed with the distance from the emission spot
  46785. * @param scene The scene the lights belongs to
  46786. */
  46787. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46788. /**
  46789. * Returns the string "SpotLight".
  46790. * @returns the class name
  46791. */
  46792. getClassName(): string;
  46793. /**
  46794. * Returns the integer 2.
  46795. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46796. */
  46797. getTypeID(): number;
  46798. /**
  46799. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46800. */
  46801. protected _setDirection(value: Vector3): void;
  46802. /**
  46803. * Overrides the position setter to recompute the projection texture view light Matrix.
  46804. */
  46805. protected _setPosition(value: Vector3): void;
  46806. /**
  46807. * 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.
  46808. * Returns the SpotLight.
  46809. */
  46810. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46811. protected _computeProjectionTextureViewLightMatrix(): void;
  46812. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46813. /**
  46814. * Main function for light texture projection matrix computing.
  46815. */
  46816. protected _computeProjectionTextureMatrix(): void;
  46817. protected _buildUniformLayout(): void;
  46818. private _computeAngleValues;
  46819. /**
  46820. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46821. * @param effect The effect to update
  46822. * @param lightIndex The index of the light in the effect to update
  46823. * @returns The spot light
  46824. */
  46825. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46826. /**
  46827. * Disposes the light and the associated resources.
  46828. */
  46829. dispose(): void;
  46830. /**
  46831. * Prepares the list of defines specific to the light type.
  46832. * @param defines the list of defines
  46833. * @param lightIndex defines the index of the light for the effect
  46834. */
  46835. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46836. }
  46837. }
  46838. declare module "babylonjs/Lights/index" {
  46839. export * from "babylonjs/Lights/light";
  46840. export * from "babylonjs/Lights/shadowLight";
  46841. export * from "babylonjs/Lights/Shadows/index";
  46842. export * from "babylonjs/Lights/directionalLight";
  46843. export * from "babylonjs/Lights/hemisphericLight";
  46844. export * from "babylonjs/Lights/pointLight";
  46845. export * from "babylonjs/Lights/spotLight";
  46846. }
  46847. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  46848. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46849. /**
  46850. * Header information of HDR texture files.
  46851. */
  46852. export interface HDRInfo {
  46853. /**
  46854. * The height of the texture in pixels.
  46855. */
  46856. height: number;
  46857. /**
  46858. * The width of the texture in pixels.
  46859. */
  46860. width: number;
  46861. /**
  46862. * The index of the beginning of the data in the binary file.
  46863. */
  46864. dataPosition: number;
  46865. }
  46866. /**
  46867. * This groups tools to convert HDR texture to native colors array.
  46868. */
  46869. export class HDRTools {
  46870. private static Ldexp;
  46871. private static Rgbe2float;
  46872. private static readStringLine;
  46873. /**
  46874. * Reads header information from an RGBE texture stored in a native array.
  46875. * More information on this format are available here:
  46876. * https://en.wikipedia.org/wiki/RGBE_image_format
  46877. *
  46878. * @param uint8array The binary file stored in native array.
  46879. * @return The header information.
  46880. */
  46881. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46882. /**
  46883. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46884. * This RGBE texture needs to store the information as a panorama.
  46885. *
  46886. * More information on this format are available here:
  46887. * https://en.wikipedia.org/wiki/RGBE_image_format
  46888. *
  46889. * @param buffer The binary file stored in an array buffer.
  46890. * @param size The expected size of the extracted cubemap.
  46891. * @return The Cube Map information.
  46892. */
  46893. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46894. /**
  46895. * Returns the pixels data extracted from an RGBE texture.
  46896. * This pixels will be stored left to right up to down in the R G B order in one array.
  46897. *
  46898. * More information on this format are available here:
  46899. * https://en.wikipedia.org/wiki/RGBE_image_format
  46900. *
  46901. * @param uint8array The binary file stored in an array buffer.
  46902. * @param hdrInfo The header information of the file.
  46903. * @return The pixels data in RGB right to left up to down order.
  46904. */
  46905. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46906. private static RGBE_ReadPixels_RLE;
  46907. }
  46908. }
  46909. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  46910. import { Nullable } from "babylonjs/types";
  46911. import { Scene } from "babylonjs/scene";
  46912. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46914. /**
  46915. * This represents a texture coming from an HDR input.
  46916. *
  46917. * The only supported format is currently panorama picture stored in RGBE format.
  46918. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46919. */
  46920. export class HDRCubeTexture extends BaseTexture {
  46921. private static _facesMapping;
  46922. private _generateHarmonics;
  46923. private _noMipmap;
  46924. private _textureMatrix;
  46925. private _size;
  46926. private _onLoad;
  46927. private _onError;
  46928. /**
  46929. * The texture URL.
  46930. */
  46931. url: string;
  46932. /**
  46933. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46934. */
  46935. coordinatesMode: number;
  46936. protected _isBlocking: boolean;
  46937. /**
  46938. * Sets wether or not the texture is blocking during loading.
  46939. */
  46940. /**
  46941. * Gets wether or not the texture is blocking during loading.
  46942. */
  46943. isBlocking: boolean;
  46944. protected _rotationY: number;
  46945. /**
  46946. * Sets texture matrix rotation angle around Y axis in radians.
  46947. */
  46948. /**
  46949. * Gets texture matrix rotation angle around Y axis radians.
  46950. */
  46951. rotationY: number;
  46952. /**
  46953. * Gets or sets the center of the bounding box associated with the cube texture
  46954. * It must define where the camera used to render the texture was set
  46955. */
  46956. boundingBoxPosition: Vector3;
  46957. private _boundingBoxSize;
  46958. /**
  46959. * Gets or sets the size of the bounding box associated with the cube texture
  46960. * When defined, the cubemap will switch to local mode
  46961. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46962. * @example https://www.babylonjs-playground.com/#RNASML
  46963. */
  46964. boundingBoxSize: Vector3;
  46965. /**
  46966. * Instantiates an HDRTexture from the following parameters.
  46967. *
  46968. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46969. * @param scene The scene the texture will be used in
  46970. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46971. * @param noMipmap Forces to not generate the mipmap if true
  46972. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46973. * @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)
  46974. * @param reserved Reserved flag for internal use.
  46975. */
  46976. 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>);
  46977. /**
  46978. * Get the current class name of the texture useful for serialization or dynamic coding.
  46979. * @returns "HDRCubeTexture"
  46980. */
  46981. getClassName(): string;
  46982. /**
  46983. * Occurs when the file is raw .hdr file.
  46984. */
  46985. private loadTexture;
  46986. clone(): HDRCubeTexture;
  46987. delayLoad(): void;
  46988. /**
  46989. * Get the texture reflection matrix used to rotate/transform the reflection.
  46990. * @returns the reflection matrix
  46991. */
  46992. getReflectionTextureMatrix(): Matrix;
  46993. /**
  46994. * Set the texture reflection matrix used to rotate/transform the reflection.
  46995. * @param value Define the reflection matrix to set
  46996. */
  46997. setReflectionTextureMatrix(value: Matrix): void;
  46998. /**
  46999. * Parses a JSON representation of an HDR Texture in order to create the texture
  47000. * @param parsedTexture Define the JSON representation
  47001. * @param scene Define the scene the texture should be created in
  47002. * @param rootUrl Define the root url in case we need to load relative dependencies
  47003. * @returns the newly created texture after parsing
  47004. */
  47005. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47006. serialize(): any;
  47007. }
  47008. }
  47009. declare module "babylonjs/Physics/physicsEngine" {
  47010. import { Nullable } from "babylonjs/types";
  47011. import { Vector3 } from "babylonjs/Maths/math";
  47012. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47013. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47014. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47015. /**
  47016. * Class used to control physics engine
  47017. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47018. */
  47019. export class PhysicsEngine implements IPhysicsEngine {
  47020. private _physicsPlugin;
  47021. /**
  47022. * Global value used to control the smallest number supported by the simulation
  47023. */
  47024. static Epsilon: number;
  47025. private _impostors;
  47026. private _joints;
  47027. /**
  47028. * Gets the gravity vector used by the simulation
  47029. */
  47030. gravity: Vector3;
  47031. /**
  47032. * Factory used to create the default physics plugin.
  47033. * @returns The default physics plugin
  47034. */
  47035. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47036. /**
  47037. * Creates a new Physics Engine
  47038. * @param gravity defines the gravity vector used by the simulation
  47039. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47040. */
  47041. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47042. /**
  47043. * Sets the gravity vector used by the simulation
  47044. * @param gravity defines the gravity vector to use
  47045. */
  47046. setGravity(gravity: Vector3): void;
  47047. /**
  47048. * Set the time step of the physics engine.
  47049. * Default is 1/60.
  47050. * To slow it down, enter 1/600 for example.
  47051. * To speed it up, 1/30
  47052. * @param newTimeStep defines the new timestep to apply to this world.
  47053. */
  47054. setTimeStep(newTimeStep?: number): void;
  47055. /**
  47056. * Get the time step of the physics engine.
  47057. * @returns the current time step
  47058. */
  47059. getTimeStep(): number;
  47060. /**
  47061. * Release all resources
  47062. */
  47063. dispose(): void;
  47064. /**
  47065. * Gets the name of the current physics plugin
  47066. * @returns the name of the plugin
  47067. */
  47068. getPhysicsPluginName(): string;
  47069. /**
  47070. * Adding a new impostor for the impostor tracking.
  47071. * This will be done by the impostor itself.
  47072. * @param impostor the impostor to add
  47073. */
  47074. addImpostor(impostor: PhysicsImpostor): void;
  47075. /**
  47076. * Remove an impostor from the engine.
  47077. * This impostor and its mesh will not longer be updated by the physics engine.
  47078. * @param impostor the impostor to remove
  47079. */
  47080. removeImpostor(impostor: PhysicsImpostor): void;
  47081. /**
  47082. * Add a joint to the physics engine
  47083. * @param mainImpostor defines the main impostor to which the joint is added.
  47084. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47085. * @param joint defines the joint that will connect both impostors.
  47086. */
  47087. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47088. /**
  47089. * Removes a joint from the simulation
  47090. * @param mainImpostor defines the impostor used with the joint
  47091. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47092. * @param joint defines the joint to remove
  47093. */
  47094. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47095. /**
  47096. * Called by the scene. No need to call it.
  47097. * @param delta defines the timespam between frames
  47098. */
  47099. _step(delta: number): void;
  47100. /**
  47101. * Gets the current plugin used to run the simulation
  47102. * @returns current plugin
  47103. */
  47104. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47105. /**
  47106. * Gets the list of physic impostors
  47107. * @returns an array of PhysicsImpostor
  47108. */
  47109. getImpostors(): Array<PhysicsImpostor>;
  47110. /**
  47111. * Gets the impostor for a physics enabled object
  47112. * @param object defines the object impersonated by the impostor
  47113. * @returns the PhysicsImpostor or null if not found
  47114. */
  47115. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47116. /**
  47117. * Gets the impostor for a physics body object
  47118. * @param body defines physics body used by the impostor
  47119. * @returns the PhysicsImpostor or null if not found
  47120. */
  47121. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47122. }
  47123. }
  47124. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47125. import { Nullable } from "babylonjs/types";
  47126. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47128. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47129. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47130. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47131. /** @hidden */
  47132. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47133. private _useDeltaForWorldStep;
  47134. world: any;
  47135. name: string;
  47136. private _physicsMaterials;
  47137. private _fixedTimeStep;
  47138. BJSCANNON: any;
  47139. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47140. setGravity(gravity: Vector3): void;
  47141. setTimeStep(timeStep: number): void;
  47142. getTimeStep(): number;
  47143. executeStep(delta: number): void;
  47144. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47145. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47146. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47147. private _processChildMeshes;
  47148. removePhysicsBody(impostor: PhysicsImpostor): void;
  47149. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47150. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47151. private _addMaterial;
  47152. private _checkWithEpsilon;
  47153. private _createShape;
  47154. private _createHeightmap;
  47155. private _minus90X;
  47156. private _plus90X;
  47157. private _tmpPosition;
  47158. private _tmpDeltaPosition;
  47159. private _tmpUnityRotation;
  47160. private _updatePhysicsBodyTransformation;
  47161. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47162. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47163. isSupported(): boolean;
  47164. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47165. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47166. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47167. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47168. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47169. getBodyMass(impostor: PhysicsImpostor): number;
  47170. getBodyFriction(impostor: PhysicsImpostor): number;
  47171. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47172. getBodyRestitution(impostor: PhysicsImpostor): number;
  47173. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47174. sleepBody(impostor: PhysicsImpostor): void;
  47175. wakeUpBody(impostor: PhysicsImpostor): void;
  47176. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47177. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47178. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47179. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47180. getRadius(impostor: PhysicsImpostor): number;
  47181. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47182. dispose(): void;
  47183. private _extendNamespace;
  47184. }
  47185. }
  47186. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47187. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47188. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47189. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47191. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47192. import { Nullable } from "babylonjs/types";
  47193. /** @hidden */
  47194. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47195. world: any;
  47196. name: string;
  47197. BJSOIMO: any;
  47198. constructor(iterations?: number, oimoInjection?: any);
  47199. setGravity(gravity: Vector3): void;
  47200. setTimeStep(timeStep: number): void;
  47201. getTimeStep(): number;
  47202. private _tmpImpostorsArray;
  47203. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47204. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47205. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47206. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47207. private _tmpPositionVector;
  47208. removePhysicsBody(impostor: PhysicsImpostor): void;
  47209. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47210. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47211. isSupported(): boolean;
  47212. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47213. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47214. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47215. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47216. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47217. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47218. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47219. getBodyMass(impostor: PhysicsImpostor): number;
  47220. getBodyFriction(impostor: PhysicsImpostor): number;
  47221. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47222. getBodyRestitution(impostor: PhysicsImpostor): number;
  47223. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47224. sleepBody(impostor: PhysicsImpostor): void;
  47225. wakeUpBody(impostor: PhysicsImpostor): void;
  47226. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47227. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47228. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47229. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47230. getRadius(impostor: PhysicsImpostor): number;
  47231. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47232. dispose(): void;
  47233. }
  47234. }
  47235. declare module "babylonjs/Probes/reflectionProbe" {
  47236. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47237. import { Vector3 } from "babylonjs/Maths/math";
  47238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47239. import { Nullable } from "babylonjs/types";
  47240. import { Scene } from "babylonjs/scene";
  47241. module "babylonjs/abstractScene" {
  47242. interface AbstractScene {
  47243. /**
  47244. * The list of reflection probes added to the scene
  47245. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47246. */
  47247. reflectionProbes: Array<ReflectionProbe>;
  47248. /**
  47249. * Removes the given reflection probe from this scene.
  47250. * @param toRemove The reflection probe to remove
  47251. * @returns The index of the removed reflection probe
  47252. */
  47253. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47254. /**
  47255. * Adds the given reflection probe to this scene.
  47256. * @param newReflectionProbe The reflection probe to add
  47257. */
  47258. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47259. }
  47260. }
  47261. /**
  47262. * Class used to generate realtime reflection / refraction cube textures
  47263. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47264. */
  47265. export class ReflectionProbe {
  47266. /** defines the name of the probe */
  47267. name: string;
  47268. private _scene;
  47269. private _renderTargetTexture;
  47270. private _projectionMatrix;
  47271. private _viewMatrix;
  47272. private _target;
  47273. private _add;
  47274. private _attachedMesh;
  47275. private _invertYAxis;
  47276. /** Gets or sets probe position (center of the cube map) */
  47277. position: Vector3;
  47278. /**
  47279. * Creates a new reflection probe
  47280. * @param name defines the name of the probe
  47281. * @param size defines the texture resolution (for each face)
  47282. * @param scene defines the hosting scene
  47283. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47284. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47285. */
  47286. constructor(
  47287. /** defines the name of the probe */
  47288. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47289. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47290. samples: number;
  47291. /** Gets or sets the refresh rate to use (on every frame by default) */
  47292. refreshRate: number;
  47293. /**
  47294. * Gets the hosting scene
  47295. * @returns a Scene
  47296. */
  47297. getScene(): Scene;
  47298. /** Gets the internal CubeTexture used to render to */
  47299. readonly cubeTexture: RenderTargetTexture;
  47300. /** Gets the list of meshes to render */
  47301. readonly renderList: Nullable<AbstractMesh[]>;
  47302. /**
  47303. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47304. * @param mesh defines the mesh to attach to
  47305. */
  47306. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47307. /**
  47308. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47309. * @param renderingGroupId The rendering group id corresponding to its index
  47310. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47311. */
  47312. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47313. /**
  47314. * Clean all associated resources
  47315. */
  47316. dispose(): void;
  47317. /**
  47318. * Converts the reflection probe information to a readable string for debug purpose.
  47319. * @param fullDetails Supports for multiple levels of logging within scene loading
  47320. * @returns the human readable reflection probe info
  47321. */
  47322. toString(fullDetails?: boolean): string;
  47323. /**
  47324. * Get the class name of the relfection probe.
  47325. * @returns "ReflectionProbe"
  47326. */
  47327. getClassName(): string;
  47328. /**
  47329. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47330. * @returns The JSON representation of the texture
  47331. */
  47332. serialize(): any;
  47333. /**
  47334. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47335. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47336. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47337. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47338. * @returns The parsed reflection probe if successful
  47339. */
  47340. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47341. }
  47342. }
  47343. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47344. /** @hidden */
  47345. export var _BabylonLoaderRegistered: boolean;
  47346. }
  47347. declare module "babylonjs/Loading/Plugins/index" {
  47348. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47349. }
  47350. declare module "babylonjs/Loading/index" {
  47351. export * from "babylonjs/Loading/loadingScreen";
  47352. export * from "babylonjs/Loading/Plugins/index";
  47353. export * from "babylonjs/Loading/sceneLoader";
  47354. export * from "babylonjs/Loading/sceneLoaderFlags";
  47355. }
  47356. declare module "babylonjs/Materials/Background/index" {
  47357. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47358. }
  47359. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47360. import { Scene } from "babylonjs/scene";
  47361. import { Color3 } from "babylonjs/Maths/math";
  47362. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47363. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47364. /**
  47365. * The Physically based simple base material of BJS.
  47366. *
  47367. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47368. * It is used as the base class for both the specGloss and metalRough conventions.
  47369. */
  47370. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47371. /**
  47372. * Number of Simultaneous lights allowed on the material.
  47373. */
  47374. maxSimultaneousLights: number;
  47375. /**
  47376. * If sets to true, disables all the lights affecting the material.
  47377. */
  47378. disableLighting: boolean;
  47379. /**
  47380. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47381. */
  47382. environmentTexture: BaseTexture;
  47383. /**
  47384. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47385. */
  47386. invertNormalMapX: boolean;
  47387. /**
  47388. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47389. */
  47390. invertNormalMapY: boolean;
  47391. /**
  47392. * Normal map used in the model.
  47393. */
  47394. normalTexture: BaseTexture;
  47395. /**
  47396. * Emissivie color used to self-illuminate the model.
  47397. */
  47398. emissiveColor: Color3;
  47399. /**
  47400. * Emissivie texture used to self-illuminate the model.
  47401. */
  47402. emissiveTexture: BaseTexture;
  47403. /**
  47404. * Occlusion Channel Strenght.
  47405. */
  47406. occlusionStrength: number;
  47407. /**
  47408. * Occlusion Texture of the material (adding extra occlusion effects).
  47409. */
  47410. occlusionTexture: BaseTexture;
  47411. /**
  47412. * Defines the alpha limits in alpha test mode.
  47413. */
  47414. alphaCutOff: number;
  47415. /**
  47416. * Gets the current double sided mode.
  47417. */
  47418. /**
  47419. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47420. */
  47421. doubleSided: boolean;
  47422. /**
  47423. * Stores the pre-calculated light information of a mesh in a texture.
  47424. */
  47425. lightmapTexture: BaseTexture;
  47426. /**
  47427. * If true, the light map contains occlusion information instead of lighting info.
  47428. */
  47429. useLightmapAsShadowmap: boolean;
  47430. /**
  47431. * Return the active textures of the material.
  47432. */
  47433. getActiveTextures(): BaseTexture[];
  47434. hasTexture(texture: BaseTexture): boolean;
  47435. /**
  47436. * Instantiates a new PBRMaterial instance.
  47437. *
  47438. * @param name The material name
  47439. * @param scene The scene the material will be use in.
  47440. */
  47441. constructor(name: string, scene: Scene);
  47442. getClassName(): string;
  47443. }
  47444. }
  47445. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47446. import { Scene } from "babylonjs/scene";
  47447. import { Color3 } from "babylonjs/Maths/math";
  47448. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47449. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47450. /**
  47451. * The PBR material of BJS following the metal roughness convention.
  47452. *
  47453. * This fits to the PBR convention in the GLTF definition:
  47454. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47455. */
  47456. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47457. /**
  47458. * The base color has two different interpretations depending on the value of metalness.
  47459. * When the material is a metal, the base color is the specific measured reflectance value
  47460. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47461. * of the material.
  47462. */
  47463. baseColor: Color3;
  47464. /**
  47465. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47466. * well as opacity information in the alpha channel.
  47467. */
  47468. baseTexture: BaseTexture;
  47469. /**
  47470. * Specifies the metallic scalar value of the material.
  47471. * Can also be used to scale the metalness values of the metallic texture.
  47472. */
  47473. metallic: number;
  47474. /**
  47475. * Specifies the roughness scalar value of the material.
  47476. * Can also be used to scale the roughness values of the metallic texture.
  47477. */
  47478. roughness: number;
  47479. /**
  47480. * Texture containing both the metallic value in the B channel and the
  47481. * roughness value in the G channel to keep better precision.
  47482. */
  47483. metallicRoughnessTexture: BaseTexture;
  47484. /**
  47485. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47486. *
  47487. * @param name The material name
  47488. * @param scene The scene the material will be use in.
  47489. */
  47490. constructor(name: string, scene: Scene);
  47491. /**
  47492. * Return the currrent class name of the material.
  47493. */
  47494. getClassName(): string;
  47495. /**
  47496. * Return the active textures of the material.
  47497. */
  47498. getActiveTextures(): BaseTexture[];
  47499. /**
  47500. * Checks to see if a texture is used in the material.
  47501. * @param texture - Base texture to use.
  47502. * @returns - Boolean specifying if a texture is used in the material.
  47503. */
  47504. hasTexture(texture: BaseTexture): boolean;
  47505. /**
  47506. * Makes a duplicate of the current material.
  47507. * @param name - name to use for the new material.
  47508. */
  47509. clone(name: string): PBRMetallicRoughnessMaterial;
  47510. /**
  47511. * Serialize the material to a parsable JSON object.
  47512. */
  47513. serialize(): any;
  47514. /**
  47515. * Parses a JSON object correponding to the serialize function.
  47516. */
  47517. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47518. }
  47519. }
  47520. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47521. import { Scene } from "babylonjs/scene";
  47522. import { Color3 } from "babylonjs/Maths/math";
  47523. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47524. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47525. /**
  47526. * The PBR material of BJS following the specular glossiness convention.
  47527. *
  47528. * This fits to the PBR convention in the GLTF definition:
  47529. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47530. */
  47531. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47532. /**
  47533. * Specifies the diffuse color of the material.
  47534. */
  47535. diffuseColor: Color3;
  47536. /**
  47537. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47538. * channel.
  47539. */
  47540. diffuseTexture: BaseTexture;
  47541. /**
  47542. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47543. */
  47544. specularColor: Color3;
  47545. /**
  47546. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47547. */
  47548. glossiness: number;
  47549. /**
  47550. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47551. */
  47552. specularGlossinessTexture: BaseTexture;
  47553. /**
  47554. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47555. *
  47556. * @param name The material name
  47557. * @param scene The scene the material will be use in.
  47558. */
  47559. constructor(name: string, scene: Scene);
  47560. /**
  47561. * Return the currrent class name of the material.
  47562. */
  47563. getClassName(): string;
  47564. /**
  47565. * Return the active textures of the material.
  47566. */
  47567. getActiveTextures(): BaseTexture[];
  47568. /**
  47569. * Checks to see if a texture is used in the material.
  47570. * @param texture - Base texture to use.
  47571. * @returns - Boolean specifying if a texture is used in the material.
  47572. */
  47573. hasTexture(texture: BaseTexture): boolean;
  47574. /**
  47575. * Makes a duplicate of the current material.
  47576. * @param name - name to use for the new material.
  47577. */
  47578. clone(name: string): PBRSpecularGlossinessMaterial;
  47579. /**
  47580. * Serialize the material to a parsable JSON object.
  47581. */
  47582. serialize(): any;
  47583. /**
  47584. * Parses a JSON object correponding to the serialize function.
  47585. */
  47586. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47587. }
  47588. }
  47589. declare module "babylonjs/Materials/PBR/index" {
  47590. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47591. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47592. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47593. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47594. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47595. }
  47596. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47597. import { Nullable } from "babylonjs/types";
  47598. import { Scene } from "babylonjs/scene";
  47599. import { Matrix } from "babylonjs/Maths/math";
  47600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47601. /**
  47602. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47603. * It can help converting any input color in a desired output one. This can then be used to create effects
  47604. * from sepia, black and white to sixties or futuristic rendering...
  47605. *
  47606. * The only supported format is currently 3dl.
  47607. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47608. */
  47609. export class ColorGradingTexture extends BaseTexture {
  47610. /**
  47611. * The current texture matrix. (will always be identity in color grading texture)
  47612. */
  47613. private _textureMatrix;
  47614. /**
  47615. * The texture URL.
  47616. */
  47617. url: string;
  47618. /**
  47619. * Empty line regex stored for GC.
  47620. */
  47621. private static _noneEmptyLineRegex;
  47622. private _engine;
  47623. /**
  47624. * Instantiates a ColorGradingTexture from the following parameters.
  47625. *
  47626. * @param url The location of the color gradind data (currently only supporting 3dl)
  47627. * @param scene The scene the texture will be used in
  47628. */
  47629. constructor(url: string, scene: Scene);
  47630. /**
  47631. * Returns the texture matrix used in most of the material.
  47632. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47633. */
  47634. getTextureMatrix(): Matrix;
  47635. /**
  47636. * Occurs when the file being loaded is a .3dl LUT file.
  47637. */
  47638. private load3dlTexture;
  47639. /**
  47640. * Starts the loading process of the texture.
  47641. */
  47642. private loadTexture;
  47643. /**
  47644. * Clones the color gradind texture.
  47645. */
  47646. clone(): ColorGradingTexture;
  47647. /**
  47648. * Called during delayed load for textures.
  47649. */
  47650. delayLoad(): void;
  47651. /**
  47652. * Parses a color grading texture serialized by Babylon.
  47653. * @param parsedTexture The texture information being parsedTexture
  47654. * @param scene The scene to load the texture in
  47655. * @param rootUrl The root url of the data assets to load
  47656. * @return A color gradind texture
  47657. */
  47658. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47659. /**
  47660. * Serializes the LUT texture to json format.
  47661. */
  47662. serialize(): any;
  47663. }
  47664. }
  47665. declare module "babylonjs/Misc/dds" {
  47666. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47667. import { Engine } from "babylonjs/Engines/engine";
  47668. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47669. import { Nullable } from "babylonjs/types";
  47670. import { Scene } from "babylonjs/scene";
  47671. /**
  47672. * Direct draw surface info
  47673. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47674. */
  47675. export interface DDSInfo {
  47676. /**
  47677. * Width of the texture
  47678. */
  47679. width: number;
  47680. /**
  47681. * Width of the texture
  47682. */
  47683. height: number;
  47684. /**
  47685. * Number of Mipmaps for the texture
  47686. * @see https://en.wikipedia.org/wiki/Mipmap
  47687. */
  47688. mipmapCount: number;
  47689. /**
  47690. * If the textures format is a known fourCC format
  47691. * @see https://www.fourcc.org/
  47692. */
  47693. isFourCC: boolean;
  47694. /**
  47695. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47696. */
  47697. isRGB: boolean;
  47698. /**
  47699. * If the texture is a lumincance format
  47700. */
  47701. isLuminance: boolean;
  47702. /**
  47703. * If this is a cube texture
  47704. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47705. */
  47706. isCube: boolean;
  47707. /**
  47708. * If the texture is a compressed format eg. FOURCC_DXT1
  47709. */
  47710. isCompressed: boolean;
  47711. /**
  47712. * The dxgiFormat of the texture
  47713. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47714. */
  47715. dxgiFormat: number;
  47716. /**
  47717. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47718. */
  47719. textureType: number;
  47720. /**
  47721. * Sphericle polynomial created for the dds texture
  47722. */
  47723. sphericalPolynomial?: SphericalPolynomial;
  47724. }
  47725. /**
  47726. * Class used to provide DDS decompression tools
  47727. */
  47728. export class DDSTools {
  47729. /**
  47730. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47731. */
  47732. static StoreLODInAlphaChannel: boolean;
  47733. /**
  47734. * Gets DDS information from an array buffer
  47735. * @param arrayBuffer defines the array buffer to read data from
  47736. * @returns the DDS information
  47737. */
  47738. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47739. private static _FloatView;
  47740. private static _Int32View;
  47741. private static _ToHalfFloat;
  47742. private static _FromHalfFloat;
  47743. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47744. private static _GetHalfFloatRGBAArrayBuffer;
  47745. private static _GetFloatRGBAArrayBuffer;
  47746. private static _GetFloatAsUIntRGBAArrayBuffer;
  47747. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47748. private static _GetRGBAArrayBuffer;
  47749. private static _ExtractLongWordOrder;
  47750. private static _GetRGBArrayBuffer;
  47751. private static _GetLuminanceArrayBuffer;
  47752. /**
  47753. * Uploads DDS Levels to a Babylon Texture
  47754. * @hidden
  47755. */
  47756. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47757. }
  47758. module "babylonjs/Engines/engine" {
  47759. interface Engine {
  47760. /**
  47761. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47762. * @param rootUrl defines the url where the file to load is located
  47763. * @param scene defines the current scene
  47764. * @param lodScale defines scale to apply to the mip map selection
  47765. * @param lodOffset defines offset to apply to the mip map selection
  47766. * @param onLoad defines an optional callback raised when the texture is loaded
  47767. * @param onError defines an optional callback raised if there is an issue to load the texture
  47768. * @param format defines the format of the data
  47769. * @param forcedExtension defines the extension to use to pick the right loader
  47770. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47771. * @returns the cube texture as an InternalTexture
  47772. */
  47773. 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;
  47774. }
  47775. }
  47776. }
  47777. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47778. import { Nullable } from "babylonjs/types";
  47779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47780. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47781. /**
  47782. * Implementation of the DDS Texture Loader.
  47783. * @hidden
  47784. */
  47785. export class _DDSTextureLoader implements IInternalTextureLoader {
  47786. /**
  47787. * Defines wether the loader supports cascade loading the different faces.
  47788. */
  47789. readonly supportCascades: boolean;
  47790. /**
  47791. * This returns if the loader support the current file information.
  47792. * @param extension defines the file extension of the file being loaded
  47793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47794. * @param fallback defines the fallback internal texture if any
  47795. * @param isBase64 defines whether the texture is encoded as a base64
  47796. * @param isBuffer defines whether the texture data are stored as a buffer
  47797. * @returns true if the loader can load the specified file
  47798. */
  47799. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47800. /**
  47801. * Transform the url before loading if required.
  47802. * @param rootUrl the url of the texture
  47803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47804. * @returns the transformed texture
  47805. */
  47806. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47807. /**
  47808. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47809. * @param rootUrl the url of the texture
  47810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47811. * @returns the fallback texture
  47812. */
  47813. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47814. /**
  47815. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47816. * @param data contains the texture data
  47817. * @param texture defines the BabylonJS internal texture
  47818. * @param createPolynomials will be true if polynomials have been requested
  47819. * @param onLoad defines the callback to trigger once the texture is ready
  47820. * @param onError defines the callback to trigger in case of error
  47821. */
  47822. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47823. /**
  47824. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47825. * @param data contains the texture data
  47826. * @param texture defines the BabylonJS internal texture
  47827. * @param callback defines the method to call once ready to upload
  47828. */
  47829. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47830. }
  47831. }
  47832. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47834. /** @hidden */
  47835. export var rgbdEncodePixelShader: {
  47836. name: string;
  47837. shader: string;
  47838. };
  47839. }
  47840. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47841. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47842. /** @hidden */
  47843. export var rgbdDecodePixelShader: {
  47844. name: string;
  47845. shader: string;
  47846. };
  47847. }
  47848. declare module "babylonjs/Misc/environmentTextureTools" {
  47849. import { Nullable } from "babylonjs/types";
  47850. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47851. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47852. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47853. import "babylonjs/Shaders/rgbdEncode.fragment";
  47854. import "babylonjs/Shaders/rgbdDecode.fragment";
  47855. /**
  47856. * Raw texture data and descriptor sufficient for WebGL texture upload
  47857. */
  47858. export interface EnvironmentTextureInfo {
  47859. /**
  47860. * Version of the environment map
  47861. */
  47862. version: number;
  47863. /**
  47864. * Width of image
  47865. */
  47866. width: number;
  47867. /**
  47868. * Irradiance information stored in the file.
  47869. */
  47870. irradiance: any;
  47871. /**
  47872. * Specular information stored in the file.
  47873. */
  47874. specular: any;
  47875. }
  47876. /**
  47877. * Sets of helpers addressing the serialization and deserialization of environment texture
  47878. * stored in a BabylonJS env file.
  47879. * Those files are usually stored as .env files.
  47880. */
  47881. export class EnvironmentTextureTools {
  47882. /**
  47883. * Magic number identifying the env file.
  47884. */
  47885. private static _MagicBytes;
  47886. /**
  47887. * Gets the environment info from an env file.
  47888. * @param data The array buffer containing the .env bytes.
  47889. * @returns the environment file info (the json header) if successfully parsed.
  47890. */
  47891. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47892. /**
  47893. * Creates an environment texture from a loaded cube texture.
  47894. * @param texture defines the cube texture to convert in env file
  47895. * @return a promise containing the environment data if succesfull.
  47896. */
  47897. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47898. /**
  47899. * Creates a JSON representation of the spherical data.
  47900. * @param texture defines the texture containing the polynomials
  47901. * @return the JSON representation of the spherical info
  47902. */
  47903. private static _CreateEnvTextureIrradiance;
  47904. /**
  47905. * Uploads the texture info contained in the env file to the GPU.
  47906. * @param texture defines the internal texture to upload to
  47907. * @param arrayBuffer defines the buffer cotaining the data to load
  47908. * @param info defines the texture info retrieved through the GetEnvInfo method
  47909. * @returns a promise
  47910. */
  47911. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47912. /**
  47913. * Uploads the levels of image data to the GPU.
  47914. * @param texture defines the internal texture to upload to
  47915. * @param imageData defines the array buffer views of image data [mipmap][face]
  47916. * @returns a promise
  47917. */
  47918. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47919. /**
  47920. * Uploads spherical polynomials information to the texture.
  47921. * @param texture defines the texture we are trying to upload the information to
  47922. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47923. */
  47924. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47925. /** @hidden */
  47926. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47927. }
  47928. }
  47929. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47930. import { Nullable } from "babylonjs/types";
  47931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47932. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47933. /**
  47934. * Implementation of the ENV Texture Loader.
  47935. * @hidden
  47936. */
  47937. export class _ENVTextureLoader implements IInternalTextureLoader {
  47938. /**
  47939. * Defines wether the loader supports cascade loading the different faces.
  47940. */
  47941. readonly supportCascades: boolean;
  47942. /**
  47943. * This returns if the loader support the current file information.
  47944. * @param extension defines the file extension of the file being loaded
  47945. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47946. * @param fallback defines the fallback internal texture if any
  47947. * @param isBase64 defines whether the texture is encoded as a base64
  47948. * @param isBuffer defines whether the texture data are stored as a buffer
  47949. * @returns true if the loader can load the specified file
  47950. */
  47951. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47952. /**
  47953. * Transform the url before loading if required.
  47954. * @param rootUrl the url of the texture
  47955. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47956. * @returns the transformed texture
  47957. */
  47958. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47959. /**
  47960. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47961. * @param rootUrl the url of the texture
  47962. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47963. * @returns the fallback texture
  47964. */
  47965. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47966. /**
  47967. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47968. * @param data contains the texture data
  47969. * @param texture defines the BabylonJS internal texture
  47970. * @param createPolynomials will be true if polynomials have been requested
  47971. * @param onLoad defines the callback to trigger once the texture is ready
  47972. * @param onError defines the callback to trigger in case of error
  47973. */
  47974. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47975. /**
  47976. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47977. * @param data contains the texture data
  47978. * @param texture defines the BabylonJS internal texture
  47979. * @param callback defines the method to call once ready to upload
  47980. */
  47981. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47982. }
  47983. }
  47984. declare module "babylonjs/Misc/khronosTextureContainer" {
  47985. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47986. /**
  47987. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47988. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47989. */
  47990. export class KhronosTextureContainer {
  47991. /** contents of the KTX container file */
  47992. arrayBuffer: any;
  47993. private static HEADER_LEN;
  47994. private static COMPRESSED_2D;
  47995. private static COMPRESSED_3D;
  47996. private static TEX_2D;
  47997. private static TEX_3D;
  47998. /**
  47999. * Gets the openGL type
  48000. */
  48001. glType: number;
  48002. /**
  48003. * Gets the openGL type size
  48004. */
  48005. glTypeSize: number;
  48006. /**
  48007. * Gets the openGL format
  48008. */
  48009. glFormat: number;
  48010. /**
  48011. * Gets the openGL internal format
  48012. */
  48013. glInternalFormat: number;
  48014. /**
  48015. * Gets the base internal format
  48016. */
  48017. glBaseInternalFormat: number;
  48018. /**
  48019. * Gets image width in pixel
  48020. */
  48021. pixelWidth: number;
  48022. /**
  48023. * Gets image height in pixel
  48024. */
  48025. pixelHeight: number;
  48026. /**
  48027. * Gets image depth in pixels
  48028. */
  48029. pixelDepth: number;
  48030. /**
  48031. * Gets the number of array elements
  48032. */
  48033. numberOfArrayElements: number;
  48034. /**
  48035. * Gets the number of faces
  48036. */
  48037. numberOfFaces: number;
  48038. /**
  48039. * Gets the number of mipmap levels
  48040. */
  48041. numberOfMipmapLevels: number;
  48042. /**
  48043. * Gets the bytes of key value data
  48044. */
  48045. bytesOfKeyValueData: number;
  48046. /**
  48047. * Gets the load type
  48048. */
  48049. loadType: number;
  48050. /**
  48051. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48052. */
  48053. isInvalid: boolean;
  48054. /**
  48055. * Creates a new KhronosTextureContainer
  48056. * @param arrayBuffer contents of the KTX container file
  48057. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48058. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48059. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48060. */
  48061. constructor(
  48062. /** contents of the KTX container file */
  48063. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48064. /**
  48065. * Uploads KTX content to a Babylon Texture.
  48066. * It is assumed that the texture has already been created & is currently bound
  48067. * @hidden
  48068. */
  48069. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48070. private _upload2DCompressedLevels;
  48071. }
  48072. }
  48073. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48074. import { Nullable } from "babylonjs/types";
  48075. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48076. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48077. /**
  48078. * Implementation of the KTX Texture Loader.
  48079. * @hidden
  48080. */
  48081. export class _KTXTextureLoader implements IInternalTextureLoader {
  48082. /**
  48083. * Defines wether the loader supports cascade loading the different faces.
  48084. */
  48085. readonly supportCascades: boolean;
  48086. /**
  48087. * This returns if the loader support the current file information.
  48088. * @param extension defines the file extension of the file being loaded
  48089. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48090. * @param fallback defines the fallback internal texture if any
  48091. * @param isBase64 defines whether the texture is encoded as a base64
  48092. * @param isBuffer defines whether the texture data are stored as a buffer
  48093. * @returns true if the loader can load the specified file
  48094. */
  48095. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48096. /**
  48097. * Transform the url before loading if required.
  48098. * @param rootUrl the url of the texture
  48099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48100. * @returns the transformed texture
  48101. */
  48102. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48103. /**
  48104. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48105. * @param rootUrl the url of the texture
  48106. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48107. * @returns the fallback texture
  48108. */
  48109. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48110. /**
  48111. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48112. * @param data contains the texture data
  48113. * @param texture defines the BabylonJS internal texture
  48114. * @param createPolynomials will be true if polynomials have been requested
  48115. * @param onLoad defines the callback to trigger once the texture is ready
  48116. * @param onError defines the callback to trigger in case of error
  48117. */
  48118. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48119. /**
  48120. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48121. * @param data contains the texture data
  48122. * @param texture defines the BabylonJS internal texture
  48123. * @param callback defines the method to call once ready to upload
  48124. */
  48125. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Misc/tga" {
  48129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48130. /**
  48131. * Based on jsTGALoader - Javascript loader for TGA file
  48132. * By Vincent Thibault
  48133. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48134. */
  48135. export class TGATools {
  48136. private static _TYPE_INDEXED;
  48137. private static _TYPE_RGB;
  48138. private static _TYPE_GREY;
  48139. private static _TYPE_RLE_INDEXED;
  48140. private static _TYPE_RLE_RGB;
  48141. private static _TYPE_RLE_GREY;
  48142. private static _ORIGIN_MASK;
  48143. private static _ORIGIN_SHIFT;
  48144. private static _ORIGIN_BL;
  48145. private static _ORIGIN_BR;
  48146. private static _ORIGIN_UL;
  48147. private static _ORIGIN_UR;
  48148. /**
  48149. * Gets the header of a TGA file
  48150. * @param data defines the TGA data
  48151. * @returns the header
  48152. */
  48153. static GetTGAHeader(data: Uint8Array): any;
  48154. /**
  48155. * Uploads TGA content to a Babylon Texture
  48156. * @hidden
  48157. */
  48158. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48159. /** @hidden */
  48160. 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;
  48161. /** @hidden */
  48162. 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;
  48163. /** @hidden */
  48164. 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;
  48165. /** @hidden */
  48166. 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;
  48167. /** @hidden */
  48168. 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;
  48169. /** @hidden */
  48170. 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;
  48171. }
  48172. }
  48173. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48174. import { Nullable } from "babylonjs/types";
  48175. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48176. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48177. /**
  48178. * Implementation of the TGA Texture Loader.
  48179. * @hidden
  48180. */
  48181. export class _TGATextureLoader implements IInternalTextureLoader {
  48182. /**
  48183. * Defines wether the loader supports cascade loading the different faces.
  48184. */
  48185. readonly supportCascades: boolean;
  48186. /**
  48187. * This returns if the loader support the current file information.
  48188. * @param extension defines the file extension of the file being loaded
  48189. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48190. * @param fallback defines the fallback internal texture if any
  48191. * @param isBase64 defines whether the texture is encoded as a base64
  48192. * @param isBuffer defines whether the texture data are stored as a buffer
  48193. * @returns true if the loader can load the specified file
  48194. */
  48195. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48196. /**
  48197. * Transform the url before loading if required.
  48198. * @param rootUrl the url of the texture
  48199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48200. * @returns the transformed texture
  48201. */
  48202. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48203. /**
  48204. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48205. * @param rootUrl the url of the texture
  48206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48207. * @returns the fallback texture
  48208. */
  48209. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48210. /**
  48211. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48212. * @param data contains the texture data
  48213. * @param texture defines the BabylonJS internal texture
  48214. * @param createPolynomials will be true if polynomials have been requested
  48215. * @param onLoad defines the callback to trigger once the texture is ready
  48216. * @param onError defines the callback to trigger in case of error
  48217. */
  48218. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48219. /**
  48220. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48221. * @param data contains the texture data
  48222. * @param texture defines the BabylonJS internal texture
  48223. * @param callback defines the method to call once ready to upload
  48224. */
  48225. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48226. }
  48227. }
  48228. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48229. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48230. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48231. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48232. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48233. }
  48234. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48235. import { Scene } from "babylonjs/scene";
  48236. import { Texture } from "babylonjs/Materials/Textures/texture";
  48237. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48238. /**
  48239. * 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.
  48240. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48241. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48242. */
  48243. export class CustomProceduralTexture extends ProceduralTexture {
  48244. private _animate;
  48245. private _time;
  48246. private _config;
  48247. private _texturePath;
  48248. /**
  48249. * Instantiates a new Custom Procedural Texture.
  48250. * 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.
  48251. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48252. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48253. * @param name Define the name of the texture
  48254. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48255. * @param size Define the size of the texture to create
  48256. * @param scene Define the scene the texture belongs to
  48257. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48258. * @param generateMipMaps Define if the texture should creates mip maps or not
  48259. */
  48260. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48261. private _loadJson;
  48262. /**
  48263. * Is the texture ready to be used ? (rendered at least once)
  48264. * @returns true if ready, otherwise, false.
  48265. */
  48266. isReady(): boolean;
  48267. /**
  48268. * Render the texture to its associated render target.
  48269. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48270. */
  48271. render(useCameraPostProcess?: boolean): void;
  48272. /**
  48273. * Update the list of dependant textures samplers in the shader.
  48274. */
  48275. updateTextures(): void;
  48276. /**
  48277. * Update the uniform values of the procedural texture in the shader.
  48278. */
  48279. updateShaderUniforms(): void;
  48280. /**
  48281. * Define if the texture animates or not.
  48282. */
  48283. animate: boolean;
  48284. }
  48285. }
  48286. declare module "babylonjs/Shaders/noise.fragment" {
  48287. /** @hidden */
  48288. export var noisePixelShader: {
  48289. name: string;
  48290. shader: string;
  48291. };
  48292. }
  48293. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48294. import { Nullable } from "babylonjs/types";
  48295. import { Scene } from "babylonjs/scene";
  48296. import { Texture } from "babylonjs/Materials/Textures/texture";
  48297. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48298. import "babylonjs/Shaders/noise.fragment";
  48299. /**
  48300. * Class used to generate noise procedural textures
  48301. */
  48302. export class NoiseProceduralTexture extends ProceduralTexture {
  48303. private _time;
  48304. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48305. brightness: number;
  48306. /** Defines the number of octaves to process */
  48307. octaves: number;
  48308. /** Defines the level of persistence (0.8 by default) */
  48309. persistence: number;
  48310. /** Gets or sets animation speed factor (default is 1) */
  48311. animationSpeedFactor: number;
  48312. /**
  48313. * Creates a new NoiseProceduralTexture
  48314. * @param name defines the name fo the texture
  48315. * @param size defines the size of the texture (default is 256)
  48316. * @param scene defines the hosting scene
  48317. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48318. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48319. */
  48320. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48321. private _updateShaderUniforms;
  48322. protected _getDefines(): string;
  48323. /** Generate the current state of the procedural texture */
  48324. render(useCameraPostProcess?: boolean): void;
  48325. /**
  48326. * Serializes this noise procedural texture
  48327. * @returns a serialized noise procedural texture object
  48328. */
  48329. serialize(): any;
  48330. /**
  48331. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48332. * @param parsedTexture defines parsed texture data
  48333. * @param scene defines the current scene
  48334. * @param rootUrl defines the root URL containing noise procedural texture information
  48335. * @returns a parsed NoiseProceduralTexture
  48336. */
  48337. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48338. }
  48339. }
  48340. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48341. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48342. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48343. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48344. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48345. }
  48346. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48347. import { Nullable } from "babylonjs/types";
  48348. import { Scene } from "babylonjs/scene";
  48349. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48351. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48352. /**
  48353. * Raw cube texture where the raw buffers are passed in
  48354. */
  48355. export class RawCubeTexture extends CubeTexture {
  48356. /**
  48357. * Creates a cube texture where the raw buffers are passed in.
  48358. * @param scene defines the scene the texture is attached to
  48359. * @param data defines the array of data to use to create each face
  48360. * @param size defines the size of the textures
  48361. * @param format defines the format of the data
  48362. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48363. * @param generateMipMaps defines if the engine should generate the mip levels
  48364. * @param invertY defines if data must be stored with Y axis inverted
  48365. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48366. * @param compression defines the compression used (null by default)
  48367. */
  48368. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48369. /**
  48370. * Updates the raw cube texture.
  48371. * @param data defines the data to store
  48372. * @param format defines the data format
  48373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48374. * @param invertY defines if data must be stored with Y axis inverted
  48375. * @param compression defines the compression used (null by default)
  48376. * @param level defines which level of the texture to update
  48377. */
  48378. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48379. /**
  48380. * Updates a raw cube texture with RGBD encoded data.
  48381. * @param data defines the array of data [mipmap][face] to use to create each face
  48382. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48383. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48384. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48385. * @returns a promsie that resolves when the operation is complete
  48386. */
  48387. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48388. /**
  48389. * Clones the raw cube texture.
  48390. * @return a new cube texture
  48391. */
  48392. clone(): CubeTexture;
  48393. /** @hidden */
  48394. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48395. }
  48396. }
  48397. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48398. import { Scene } from "babylonjs/scene";
  48399. import { Texture } from "babylonjs/Materials/Textures/texture";
  48400. /**
  48401. * Class used to store 3D textures containing user data
  48402. */
  48403. export class RawTexture3D extends Texture {
  48404. /** Gets or sets the texture format to use */
  48405. format: number;
  48406. private _engine;
  48407. /**
  48408. * Create a new RawTexture3D
  48409. * @param data defines the data of the texture
  48410. * @param width defines the width of the texture
  48411. * @param height defines the height of the texture
  48412. * @param depth defines the depth of the texture
  48413. * @param format defines the texture format to use
  48414. * @param scene defines the hosting scene
  48415. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48416. * @param invertY defines if texture must be stored with Y axis inverted
  48417. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48418. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48419. */
  48420. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48421. /** Gets or sets the texture format to use */
  48422. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48423. /**
  48424. * Update the texture with new data
  48425. * @param data defines the data to store in the texture
  48426. */
  48427. update(data: ArrayBufferView): void;
  48428. }
  48429. }
  48430. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48431. import { Scene } from "babylonjs/scene";
  48432. import { Plane } from "babylonjs/Maths/math";
  48433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48434. /**
  48435. * Creates a refraction texture used by refraction channel of the standard material.
  48436. * It is like a mirror but to see through a material.
  48437. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48438. */
  48439. export class RefractionTexture extends RenderTargetTexture {
  48440. /**
  48441. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48442. * 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.
  48443. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48444. */
  48445. refractionPlane: Plane;
  48446. /**
  48447. * Define how deep under the surface we should see.
  48448. */
  48449. depth: number;
  48450. /**
  48451. * Creates a refraction texture used by refraction channel of the standard material.
  48452. * It is like a mirror but to see through a material.
  48453. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48454. * @param name Define the texture name
  48455. * @param size Define the size of the underlying texture
  48456. * @param scene Define the scene the refraction belongs to
  48457. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48458. */
  48459. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48460. /**
  48461. * Clone the refraction texture.
  48462. * @returns the cloned texture
  48463. */
  48464. clone(): RefractionTexture;
  48465. /**
  48466. * Serialize the texture to a JSON representation you could use in Parse later on
  48467. * @returns the serialized JSON representation
  48468. */
  48469. serialize(): any;
  48470. }
  48471. }
  48472. declare module "babylonjs/Materials/Textures/index" {
  48473. export * from "babylonjs/Materials/Textures/baseTexture";
  48474. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48475. export * from "babylonjs/Materials/Textures/cubeTexture";
  48476. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48477. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48478. export * from "babylonjs/Materials/Textures/internalTexture";
  48479. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48480. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48481. export * from "babylonjs/Materials/Textures/Loaders/index";
  48482. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48483. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48484. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48485. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48486. export * from "babylonjs/Materials/Textures/rawTexture";
  48487. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48488. export * from "babylonjs/Materials/Textures/refractionTexture";
  48489. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48490. export * from "babylonjs/Materials/Textures/texture";
  48491. export * from "babylonjs/Materials/Textures/videoTexture";
  48492. }
  48493. declare module "babylonjs/Materials/index" {
  48494. export * from "babylonjs/Materials/Background/index";
  48495. export * from "babylonjs/Materials/colorCurves";
  48496. export * from "babylonjs/Materials/effect";
  48497. export * from "babylonjs/Materials/fresnelParameters";
  48498. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48499. export * from "babylonjs/Materials/material";
  48500. export * from "babylonjs/Materials/materialDefines";
  48501. export * from "babylonjs/Materials/materialHelper";
  48502. export * from "babylonjs/Materials/multiMaterial";
  48503. export * from "babylonjs/Materials/PBR/index";
  48504. export * from "babylonjs/Materials/pushMaterial";
  48505. export * from "babylonjs/Materials/shaderMaterial";
  48506. export * from "babylonjs/Materials/standardMaterial";
  48507. export * from "babylonjs/Materials/Textures/index";
  48508. export * from "babylonjs/Materials/uniformBuffer";
  48509. export * from "babylonjs/Materials/materialFlags";
  48510. }
  48511. declare module "babylonjs/Maths/index" {
  48512. export * from "babylonjs/Maths/math.scalar";
  48513. export * from "babylonjs/Maths/math";
  48514. export * from "babylonjs/Maths/sphericalPolynomial";
  48515. }
  48516. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48517. import { IDisposable } from "babylonjs/scene";
  48518. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48519. /**
  48520. * Configuration for Draco compression
  48521. */
  48522. export interface IDracoCompressionConfiguration {
  48523. /**
  48524. * Configuration for the decoder.
  48525. */
  48526. decoder?: {
  48527. /**
  48528. * The url to the WebAssembly module.
  48529. */
  48530. wasmUrl?: string;
  48531. /**
  48532. * The url to the WebAssembly binary.
  48533. */
  48534. wasmBinaryUrl?: string;
  48535. /**
  48536. * The url to the fallback JavaScript module.
  48537. */
  48538. fallbackUrl?: string;
  48539. };
  48540. }
  48541. /**
  48542. * Draco compression (https://google.github.io/draco/)
  48543. *
  48544. * This class wraps the Draco module.
  48545. *
  48546. * **Encoder**
  48547. *
  48548. * The encoder is not currently implemented.
  48549. *
  48550. * **Decoder**
  48551. *
  48552. * 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.
  48553. *
  48554. * To update the configuration, use the following code:
  48555. * ```javascript
  48556. * DracoCompression.Configuration = {
  48557. * decoder: {
  48558. * wasmUrl: "<url to the WebAssembly library>",
  48559. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48560. * fallbackUrl: "<url to the fallback JavaScript library>",
  48561. * }
  48562. * };
  48563. * ```
  48564. *
  48565. * 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.
  48566. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48567. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48568. *
  48569. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48570. * ```javascript
  48571. * var dracoCompression = new DracoCompression();
  48572. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48573. * [VertexBuffer.PositionKind]: 0
  48574. * });
  48575. * ```
  48576. *
  48577. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48578. */
  48579. export class DracoCompression implements IDisposable {
  48580. private static _DecoderModulePromise;
  48581. /**
  48582. * The configuration. Defaults to the following urls:
  48583. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48584. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48585. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48586. */
  48587. static Configuration: IDracoCompressionConfiguration;
  48588. /**
  48589. * Returns true if the decoder is available.
  48590. */
  48591. static readonly DecoderAvailable: boolean;
  48592. /**
  48593. * Constructor
  48594. */
  48595. constructor();
  48596. /**
  48597. * Stop all async operations and release resources.
  48598. */
  48599. dispose(): void;
  48600. /**
  48601. * Decode Draco compressed mesh data to vertex data.
  48602. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48603. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48604. * @returns A promise that resolves with the decoded vertex data
  48605. */
  48606. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48607. [kind: string]: number;
  48608. }): Promise<VertexData>;
  48609. private static _GetDecoderModule;
  48610. private static _LoadScriptAsync;
  48611. private static _LoadFileAsync;
  48612. }
  48613. }
  48614. declare module "babylonjs/Meshes/Compression/index" {
  48615. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48616. }
  48617. declare module "babylonjs/Meshes/csg" {
  48618. import { Nullable } from "babylonjs/types";
  48619. import { Scene } from "babylonjs/scene";
  48620. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48621. import { Mesh } from "babylonjs/Meshes/mesh";
  48622. import { Material } from "babylonjs/Materials/material";
  48623. /**
  48624. * Class for building Constructive Solid Geometry
  48625. */
  48626. export class CSG {
  48627. private polygons;
  48628. /**
  48629. * The world matrix
  48630. */
  48631. matrix: Matrix;
  48632. /**
  48633. * Stores the position
  48634. */
  48635. position: Vector3;
  48636. /**
  48637. * Stores the rotation
  48638. */
  48639. rotation: Vector3;
  48640. /**
  48641. * Stores the rotation quaternion
  48642. */
  48643. rotationQuaternion: Nullable<Quaternion>;
  48644. /**
  48645. * Stores the scaling vector
  48646. */
  48647. scaling: Vector3;
  48648. /**
  48649. * Convert the Mesh to CSG
  48650. * @param mesh The Mesh to convert to CSG
  48651. * @returns A new CSG from the Mesh
  48652. */
  48653. static FromMesh(mesh: Mesh): CSG;
  48654. /**
  48655. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48656. * @param polygons Polygons used to construct a CSG solid
  48657. */
  48658. private static FromPolygons;
  48659. /**
  48660. * Clones, or makes a deep copy, of the CSG
  48661. * @returns A new CSG
  48662. */
  48663. clone(): CSG;
  48664. /**
  48665. * Unions this CSG with another CSG
  48666. * @param csg The CSG to union against this CSG
  48667. * @returns The unioned CSG
  48668. */
  48669. union(csg: CSG): CSG;
  48670. /**
  48671. * Unions this CSG with another CSG in place
  48672. * @param csg The CSG to union against this CSG
  48673. */
  48674. unionInPlace(csg: CSG): void;
  48675. /**
  48676. * Subtracts this CSG with another CSG
  48677. * @param csg The CSG to subtract against this CSG
  48678. * @returns A new CSG
  48679. */
  48680. subtract(csg: CSG): CSG;
  48681. /**
  48682. * Subtracts this CSG with another CSG in place
  48683. * @param csg The CSG to subtact against this CSG
  48684. */
  48685. subtractInPlace(csg: CSG): void;
  48686. /**
  48687. * Intersect this CSG with another CSG
  48688. * @param csg The CSG to intersect against this CSG
  48689. * @returns A new CSG
  48690. */
  48691. intersect(csg: CSG): CSG;
  48692. /**
  48693. * Intersects this CSG with another CSG in place
  48694. * @param csg The CSG to intersect against this CSG
  48695. */
  48696. intersectInPlace(csg: CSG): void;
  48697. /**
  48698. * Return a new CSG solid with solid and empty space switched. This solid is
  48699. * not modified.
  48700. * @returns A new CSG solid with solid and empty space switched
  48701. */
  48702. inverse(): CSG;
  48703. /**
  48704. * Inverses the CSG in place
  48705. */
  48706. inverseInPlace(): void;
  48707. /**
  48708. * This is used to keep meshes transformations so they can be restored
  48709. * when we build back a Babylon Mesh
  48710. * NB : All CSG operations are performed in world coordinates
  48711. * @param csg The CSG to copy the transform attributes from
  48712. * @returns This CSG
  48713. */
  48714. copyTransformAttributes(csg: CSG): CSG;
  48715. /**
  48716. * Build Raw mesh from CSG
  48717. * Coordinates here are in world space
  48718. * @param name The name of the mesh geometry
  48719. * @param scene The Scene
  48720. * @param keepSubMeshes Specifies if the submeshes should be kept
  48721. * @returns A new Mesh
  48722. */
  48723. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48724. /**
  48725. * Build Mesh from CSG taking material and transforms into account
  48726. * @param name The name of the Mesh
  48727. * @param material The material of the Mesh
  48728. * @param scene The Scene
  48729. * @param keepSubMeshes Specifies if submeshes should be kept
  48730. * @returns The new Mesh
  48731. */
  48732. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48733. }
  48734. }
  48735. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  48736. import { Nullable } from "babylonjs/types";
  48737. import { Scene } from "babylonjs/scene";
  48738. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  48739. import { Mesh } from "babylonjs/Meshes/mesh";
  48740. /**
  48741. * Class containing static functions to help procedurally build meshes
  48742. */
  48743. export class RibbonBuilder {
  48744. /**
  48745. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48746. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48747. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48748. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48749. * * 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
  48750. * * 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
  48751. * * 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
  48752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48755. * * 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
  48756. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48757. * * 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
  48758. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48760. * @param name defines the name of the mesh
  48761. * @param options defines the options used to create the mesh
  48762. * @param scene defines the hosting scene
  48763. * @returns the ribbon mesh
  48764. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48765. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48766. */
  48767. static CreateRibbon(name: string, options: {
  48768. pathArray: Vector3[][];
  48769. closeArray?: boolean;
  48770. closePath?: boolean;
  48771. offset?: number;
  48772. updatable?: boolean;
  48773. sideOrientation?: number;
  48774. frontUVs?: Vector4;
  48775. backUVs?: Vector4;
  48776. instance?: Mesh;
  48777. invertUV?: boolean;
  48778. uvs?: Vector2[];
  48779. colors?: Color4[];
  48780. }, scene?: Nullable<Scene>): Mesh;
  48781. }
  48782. }
  48783. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  48784. import { Vector4 } from "babylonjs/Maths/math";
  48785. import { Mesh } from "babylonjs/Meshes/mesh";
  48786. /**
  48787. * Class containing static functions to help procedurally build meshes
  48788. */
  48789. export class TorusKnotBuilder {
  48790. /**
  48791. * Creates a torus knot mesh
  48792. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48793. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48794. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48795. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48799. * @param name defines the name of the mesh
  48800. * @param options defines the options used to create the mesh
  48801. * @param scene defines the hosting scene
  48802. * @returns the torus knot mesh
  48803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48804. */
  48805. static CreateTorusKnot(name: string, options: {
  48806. radius?: number;
  48807. tube?: number;
  48808. radialSegments?: number;
  48809. tubularSegments?: number;
  48810. p?: number;
  48811. q?: number;
  48812. updatable?: boolean;
  48813. sideOrientation?: number;
  48814. frontUVs?: Vector4;
  48815. backUVs?: Vector4;
  48816. }, scene: any): Mesh;
  48817. }
  48818. }
  48819. declare module "babylonjs/Meshes/polygonMesh" {
  48820. import { Scene } from "babylonjs/scene";
  48821. import { Vector2, Path2 } from "babylonjs/Maths/math";
  48822. import { Mesh } from "babylonjs/Meshes/mesh";
  48823. /**
  48824. * Polygon
  48825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48826. */
  48827. export class Polygon {
  48828. /**
  48829. * Creates a rectangle
  48830. * @param xmin bottom X coord
  48831. * @param ymin bottom Y coord
  48832. * @param xmax top X coord
  48833. * @param ymax top Y coord
  48834. * @returns points that make the resulting rectation
  48835. */
  48836. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48837. /**
  48838. * Creates a circle
  48839. * @param radius radius of circle
  48840. * @param cx scale in x
  48841. * @param cy scale in y
  48842. * @param numberOfSides number of sides that make up the circle
  48843. * @returns points that make the resulting circle
  48844. */
  48845. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48846. /**
  48847. * Creates a polygon from input string
  48848. * @param input Input polygon data
  48849. * @returns the parsed points
  48850. */
  48851. static Parse(input: string): Vector2[];
  48852. /**
  48853. * Starts building a polygon from x and y coordinates
  48854. * @param x x coordinate
  48855. * @param y y coordinate
  48856. * @returns the started path2
  48857. */
  48858. static StartingAt(x: number, y: number): Path2;
  48859. }
  48860. /**
  48861. * Builds a polygon
  48862. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48863. */
  48864. export class PolygonMeshBuilder {
  48865. private _points;
  48866. private _outlinepoints;
  48867. private _holes;
  48868. private _name;
  48869. private _scene;
  48870. private _epoints;
  48871. private _eholes;
  48872. private _addToepoint;
  48873. /**
  48874. * Babylon reference to the earcut plugin.
  48875. */
  48876. bjsEarcut: any;
  48877. /**
  48878. * Creates a PolygonMeshBuilder
  48879. * @param name name of the builder
  48880. * @param contours Path of the polygon
  48881. * @param scene scene to add to
  48882. * @param earcutInjection can be used to inject your own earcut reference
  48883. */
  48884. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  48885. /**
  48886. * Adds a whole within the polygon
  48887. * @param hole Array of points defining the hole
  48888. * @returns this
  48889. */
  48890. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48891. /**
  48892. * Creates the polygon
  48893. * @param updatable If the mesh should be updatable
  48894. * @param depth The depth of the mesh created
  48895. * @returns the created mesh
  48896. */
  48897. build(updatable?: boolean, depth?: number): Mesh;
  48898. /**
  48899. * Adds a side to the polygon
  48900. * @param positions points that make the polygon
  48901. * @param normals normals of the polygon
  48902. * @param uvs uvs of the polygon
  48903. * @param indices indices of the polygon
  48904. * @param bounds bounds of the polygon
  48905. * @param points points of the polygon
  48906. * @param depth depth of the polygon
  48907. * @param flip flip of the polygon
  48908. */
  48909. private addSide;
  48910. }
  48911. }
  48912. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  48913. import { Scene } from "babylonjs/scene";
  48914. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  48915. import { Mesh } from "babylonjs/Meshes/mesh";
  48916. /**
  48917. * Class containing static functions to help procedurally build meshes
  48918. */
  48919. export class PolygonBuilder {
  48920. /**
  48921. * Creates a polygon mesh
  48922. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48923. * * 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
  48924. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  48927. * * Remember you can only change the shape positions, not their number when updating a polygon
  48928. * @param name defines the name of the mesh
  48929. * @param options defines the options used to create the mesh
  48930. * @param scene defines the hosting scene
  48931. * @param earcutInjection can be used to inject your own earcut reference
  48932. * @returns the polygon mesh
  48933. */
  48934. static CreatePolygon(name: string, options: {
  48935. shape: Vector3[];
  48936. holes?: Vector3[][];
  48937. depth?: number;
  48938. faceUV?: Vector4[];
  48939. faceColors?: Color4[];
  48940. updatable?: boolean;
  48941. sideOrientation?: number;
  48942. frontUVs?: Vector4;
  48943. backUVs?: Vector4;
  48944. }, scene: Scene, earcutInjection?: any): Mesh;
  48945. /**
  48946. * Creates an extruded polygon mesh, with depth in the Y direction.
  48947. * * 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)
  48948. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48949. * @param name defines the name of the mesh
  48950. * @param options defines the options used to create the mesh
  48951. * @param scene defines the hosting scene
  48952. * @param earcutInjection can be used to inject your own earcut reference
  48953. * @returns the polygon mesh
  48954. */
  48955. static ExtrudePolygon(name: string, options: {
  48956. shape: Vector3[];
  48957. holes?: Vector3[][];
  48958. depth?: number;
  48959. faceUV?: Vector4[];
  48960. faceColors?: Color4[];
  48961. updatable?: boolean;
  48962. sideOrientation?: number;
  48963. frontUVs?: Vector4;
  48964. backUVs?: Vector4;
  48965. }, scene: Scene, earcutInjection?: any): Mesh;
  48966. }
  48967. }
  48968. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  48969. import { Nullable } from "babylonjs/types";
  48970. import { Scene } from "babylonjs/scene";
  48971. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  48972. import { Mesh } from "babylonjs/Meshes/mesh";
  48973. /**
  48974. * Class containing static functions to help procedurally build meshes
  48975. */
  48976. export class ShapeBuilder {
  48977. /**
  48978. * 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.
  48979. * * 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.
  48980. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48981. * * 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.
  48982. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48983. * * 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
  48984. * * 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
  48985. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48990. * @param name defines the name of the mesh
  48991. * @param options defines the options used to create the mesh
  48992. * @param scene defines the hosting scene
  48993. * @returns the extruded shape mesh
  48994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48996. */
  48997. static ExtrudeShape(name: string, options: {
  48998. shape: Vector3[];
  48999. path: Vector3[];
  49000. scale?: number;
  49001. rotation?: number;
  49002. cap?: number;
  49003. updatable?: boolean;
  49004. sideOrientation?: number;
  49005. frontUVs?: Vector4;
  49006. backUVs?: Vector4;
  49007. instance?: Mesh;
  49008. invertUV?: boolean;
  49009. }, scene?: Nullable<Scene>): Mesh;
  49010. /**
  49011. * Creates an custom extruded shape mesh.
  49012. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49013. * * 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.
  49014. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49015. * * 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
  49016. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49017. * * 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
  49018. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49019. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49020. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49021. * * 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
  49022. * * 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
  49023. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49026. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49028. * @param name defines the name of the mesh
  49029. * @param options defines the options used to create the mesh
  49030. * @param scene defines the hosting scene
  49031. * @returns the custom extruded shape mesh
  49032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49035. */
  49036. static ExtrudeShapeCustom(name: string, options: {
  49037. shape: Vector3[];
  49038. path: Vector3[];
  49039. scaleFunction?: any;
  49040. rotationFunction?: any;
  49041. ribbonCloseArray?: boolean;
  49042. ribbonClosePath?: boolean;
  49043. cap?: number;
  49044. updatable?: boolean;
  49045. sideOrientation?: number;
  49046. frontUVs?: Vector4;
  49047. backUVs?: Vector4;
  49048. instance?: Mesh;
  49049. invertUV?: boolean;
  49050. }, scene: Scene): Mesh;
  49051. private static _ExtrudeShapeGeneric;
  49052. }
  49053. }
  49054. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49055. import { Scene } from "babylonjs/scene";
  49056. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49057. import { Mesh } from "babylonjs/Meshes/mesh";
  49058. /**
  49059. * Class containing static functions to help procedurally build meshes
  49060. */
  49061. export class LatheBuilder {
  49062. /**
  49063. * Creates lathe mesh.
  49064. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49065. * * 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
  49066. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49067. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49068. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49069. * * 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
  49070. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49071. * * 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
  49072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49076. * @param name defines the name of the mesh
  49077. * @param options defines the options used to create the mesh
  49078. * @param scene defines the hosting scene
  49079. * @returns the lathe mesh
  49080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49081. */
  49082. static CreateLathe(name: string, options: {
  49083. shape: Vector3[];
  49084. radius?: number;
  49085. tessellation?: number;
  49086. clip?: number;
  49087. arc?: number;
  49088. closed?: boolean;
  49089. updatable?: boolean;
  49090. sideOrientation?: number;
  49091. frontUVs?: Vector4;
  49092. backUVs?: Vector4;
  49093. cap?: number;
  49094. invertUV?: boolean;
  49095. }, scene: Scene): Mesh;
  49096. }
  49097. }
  49098. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49099. import { Scene } from "babylonjs/scene";
  49100. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49101. import { Mesh } from "babylonjs/Meshes/mesh";
  49102. /**
  49103. * Class containing static functions to help procedurally build meshes
  49104. */
  49105. export class TubeBuilder {
  49106. /**
  49107. * Creates a tube mesh.
  49108. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49109. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49110. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49111. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49112. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49113. * * 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)
  49114. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49115. * * 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
  49116. * * 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
  49117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49119. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49121. * @param name defines the name of the mesh
  49122. * @param options defines the options used to create the mesh
  49123. * @param scene defines the hosting scene
  49124. * @returns the tube mesh
  49125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49126. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49127. */
  49128. static CreateTube(name: string, options: {
  49129. path: Vector3[];
  49130. radius?: number;
  49131. tessellation?: number;
  49132. radiusFunction?: {
  49133. (i: number, distance: number): number;
  49134. };
  49135. cap?: number;
  49136. arc?: number;
  49137. updatable?: boolean;
  49138. sideOrientation?: number;
  49139. frontUVs?: Vector4;
  49140. backUVs?: Vector4;
  49141. instance?: Mesh;
  49142. invertUV?: boolean;
  49143. }, scene: Scene): Mesh;
  49144. }
  49145. }
  49146. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49147. import { Scene } from "babylonjs/scene";
  49148. import { Vector4 } from "babylonjs/Maths/math";
  49149. import { Mesh } from "babylonjs/Meshes/mesh";
  49150. /**
  49151. * Class containing static functions to help procedurally build meshes
  49152. */
  49153. export class IcoSphereBuilder {
  49154. /**
  49155. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49156. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49157. * * 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`)
  49158. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49159. * * 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
  49160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49163. * @param name defines the name of the mesh
  49164. * @param options defines the options used to create the mesh
  49165. * @param scene defines the hosting scene
  49166. * @returns the icosahedron mesh
  49167. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49168. */
  49169. static CreateIcoSphere(name: string, options: {
  49170. radius?: number;
  49171. radiusX?: number;
  49172. radiusY?: number;
  49173. radiusZ?: number;
  49174. flat?: boolean;
  49175. subdivisions?: number;
  49176. sideOrientation?: number;
  49177. frontUVs?: Vector4;
  49178. backUVs?: Vector4;
  49179. updatable?: boolean;
  49180. }, scene: Scene): Mesh;
  49181. }
  49182. }
  49183. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49184. import { Vector3 } from "babylonjs/Maths/math";
  49185. import { Mesh } from "babylonjs/Meshes/mesh";
  49186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49187. /**
  49188. * Class containing static functions to help procedurally build meshes
  49189. */
  49190. export class DecalBuilder {
  49191. /**
  49192. * Creates a decal mesh.
  49193. * 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
  49194. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49195. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49196. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49197. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49198. * @param name defines the name of the mesh
  49199. * @param sourceMesh defines the mesh where the decal must be applied
  49200. * @param options defines the options used to create the mesh
  49201. * @param scene defines the hosting scene
  49202. * @returns the decal mesh
  49203. * @see https://doc.babylonjs.com/how_to/decals
  49204. */
  49205. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49206. position?: Vector3;
  49207. normal?: Vector3;
  49208. size?: Vector3;
  49209. angle?: number;
  49210. }): Mesh;
  49211. }
  49212. }
  49213. declare module "babylonjs/Meshes/meshBuilder" {
  49214. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49215. import { Nullable } from "babylonjs/types";
  49216. import { Scene } from "babylonjs/scene";
  49217. import { Mesh } from "babylonjs/Meshes/mesh";
  49218. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49219. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49221. /**
  49222. * Class containing static functions to help procedurally build meshes
  49223. */
  49224. export class MeshBuilder {
  49225. /**
  49226. * Creates a box mesh
  49227. * * The parameter `size` sets the size (float) of each box side (default 1)
  49228. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49229. * * 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)
  49230. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49234. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49235. * @param name defines the name of the mesh
  49236. * @param options defines the options used to create the mesh
  49237. * @param scene defines the hosting scene
  49238. * @returns the box mesh
  49239. */
  49240. static CreateBox(name: string, options: {
  49241. size?: number;
  49242. width?: number;
  49243. height?: number;
  49244. depth?: number;
  49245. faceUV?: Vector4[];
  49246. faceColors?: Color4[];
  49247. sideOrientation?: number;
  49248. frontUVs?: Vector4;
  49249. backUVs?: Vector4;
  49250. updatable?: boolean;
  49251. }, scene?: Nullable<Scene>): Mesh;
  49252. /**
  49253. * Creates a sphere mesh
  49254. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49255. * * 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`)
  49256. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49257. * * 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
  49258. * * 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)
  49259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49262. * @param name defines the name of the mesh
  49263. * @param options defines the options used to create the mesh
  49264. * @param scene defines the hosting scene
  49265. * @returns the sphere mesh
  49266. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49267. */
  49268. static CreateSphere(name: string, options: {
  49269. segments?: number;
  49270. diameter?: number;
  49271. diameterX?: number;
  49272. diameterY?: number;
  49273. diameterZ?: number;
  49274. arc?: number;
  49275. slice?: number;
  49276. sideOrientation?: number;
  49277. frontUVs?: Vector4;
  49278. backUVs?: Vector4;
  49279. updatable?: boolean;
  49280. }, scene: any): Mesh;
  49281. /**
  49282. * Creates a plane polygonal mesh. By default, this is a disc
  49283. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49284. * * 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
  49285. * * 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
  49286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49289. * @param name defines the name of the mesh
  49290. * @param options defines the options used to create the mesh
  49291. * @param scene defines the hosting scene
  49292. * @returns the plane polygonal mesh
  49293. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49294. */
  49295. static CreateDisc(name: string, options: {
  49296. radius?: number;
  49297. tessellation?: number;
  49298. arc?: number;
  49299. updatable?: boolean;
  49300. sideOrientation?: number;
  49301. frontUVs?: Vector4;
  49302. backUVs?: Vector4;
  49303. }, scene?: Nullable<Scene>): Mesh;
  49304. /**
  49305. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49306. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49307. * * 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`)
  49308. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49309. * * 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
  49310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49313. * @param name defines the name of the mesh
  49314. * @param options defines the options used to create the mesh
  49315. * @param scene defines the hosting scene
  49316. * @returns the icosahedron mesh
  49317. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49318. */
  49319. static CreateIcoSphere(name: string, options: {
  49320. radius?: number;
  49321. radiusX?: number;
  49322. radiusY?: number;
  49323. radiusZ?: number;
  49324. flat?: boolean;
  49325. subdivisions?: number;
  49326. sideOrientation?: number;
  49327. frontUVs?: Vector4;
  49328. backUVs?: Vector4;
  49329. updatable?: boolean;
  49330. }, scene: Scene): Mesh;
  49331. /**
  49332. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49333. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49334. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49335. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49336. * * 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
  49337. * * 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
  49338. * * 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
  49339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49342. * * 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
  49343. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49344. * * 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
  49345. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49347. * @param name defines the name of the mesh
  49348. * @param options defines the options used to create the mesh
  49349. * @param scene defines the hosting scene
  49350. * @returns the ribbon mesh
  49351. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49352. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49353. */
  49354. static CreateRibbon(name: string, options: {
  49355. pathArray: Vector3[][];
  49356. closeArray?: boolean;
  49357. closePath?: boolean;
  49358. offset?: number;
  49359. updatable?: boolean;
  49360. sideOrientation?: number;
  49361. frontUVs?: Vector4;
  49362. backUVs?: Vector4;
  49363. instance?: Mesh;
  49364. invertUV?: boolean;
  49365. uvs?: Vector2[];
  49366. colors?: Color4[];
  49367. }, scene?: Nullable<Scene>): Mesh;
  49368. /**
  49369. * Creates a cylinder or a cone mesh
  49370. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49371. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49372. * * 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.
  49373. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49374. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49375. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49376. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49377. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49378. * * 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).
  49379. * * 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
  49380. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49381. * * 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
  49382. * * 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.
  49383. * * If `enclose` is false, a ring surface is one element.
  49384. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49385. * * 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
  49386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49389. * @param name defines the name of the mesh
  49390. * @param options defines the options used to create the mesh
  49391. * @param scene defines the hosting scene
  49392. * @returns the cylinder mesh
  49393. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49394. */
  49395. static CreateCylinder(name: string, options: {
  49396. height?: number;
  49397. diameterTop?: number;
  49398. diameterBottom?: number;
  49399. diameter?: number;
  49400. tessellation?: number;
  49401. subdivisions?: number;
  49402. arc?: number;
  49403. faceColors?: Color4[];
  49404. faceUV?: Vector4[];
  49405. updatable?: boolean;
  49406. hasRings?: boolean;
  49407. enclose?: boolean;
  49408. sideOrientation?: number;
  49409. frontUVs?: Vector4;
  49410. backUVs?: Vector4;
  49411. }, scene: any): Mesh;
  49412. /**
  49413. * Creates a torus mesh
  49414. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49415. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49416. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49420. * @param name defines the name of the mesh
  49421. * @param options defines the options used to create the mesh
  49422. * @param scene defines the hosting scene
  49423. * @returns the torus mesh
  49424. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49425. */
  49426. static CreateTorus(name: string, options: {
  49427. diameter?: number;
  49428. thickness?: number;
  49429. tessellation?: number;
  49430. updatable?: boolean;
  49431. sideOrientation?: number;
  49432. frontUVs?: Vector4;
  49433. backUVs?: Vector4;
  49434. }, scene: any): Mesh;
  49435. /**
  49436. * Creates a torus knot mesh
  49437. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49438. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49439. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49440. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49444. * @param name defines the name of the mesh
  49445. * @param options defines the options used to create the mesh
  49446. * @param scene defines the hosting scene
  49447. * @returns the torus knot mesh
  49448. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49449. */
  49450. static CreateTorusKnot(name: string, options: {
  49451. radius?: number;
  49452. tube?: number;
  49453. radialSegments?: number;
  49454. tubularSegments?: number;
  49455. p?: number;
  49456. q?: number;
  49457. updatable?: boolean;
  49458. sideOrientation?: number;
  49459. frontUVs?: Vector4;
  49460. backUVs?: Vector4;
  49461. }, scene: any): Mesh;
  49462. /**
  49463. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49464. * * 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
  49465. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49466. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49467. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49468. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49469. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49470. * * 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
  49471. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49474. * @param name defines the name of the new line system
  49475. * @param options defines the options used to create the line system
  49476. * @param scene defines the hosting scene
  49477. * @returns a new line system mesh
  49478. */
  49479. static CreateLineSystem(name: string, options: {
  49480. lines: Vector3[][];
  49481. updatable?: boolean;
  49482. instance?: Nullable<LinesMesh>;
  49483. colors?: Nullable<Color4[][]>;
  49484. useVertexAlpha?: boolean;
  49485. }, scene: Nullable<Scene>): LinesMesh;
  49486. /**
  49487. * Creates a line mesh
  49488. * 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
  49489. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49490. * * The parameter `points` is an array successive Vector3
  49491. * * 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
  49492. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49493. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49494. * * When updating an instance, remember that only point positions can change, not the number of points
  49495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49497. * @param name defines the name of the new line system
  49498. * @param options defines the options used to create the line system
  49499. * @param scene defines the hosting scene
  49500. * @returns a new line mesh
  49501. */
  49502. static CreateLines(name: string, options: {
  49503. points: Vector3[];
  49504. updatable?: boolean;
  49505. instance?: Nullable<LinesMesh>;
  49506. colors?: Color4[];
  49507. useVertexAlpha?: boolean;
  49508. }, scene?: Nullable<Scene>): LinesMesh;
  49509. /**
  49510. * Creates a dashed line mesh
  49511. * * 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
  49512. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49513. * * The parameter `points` is an array successive Vector3
  49514. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49515. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49516. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49517. * * 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
  49518. * * When updating an instance, remember that only point positions can change, not the number of points
  49519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49520. * @param name defines the name of the mesh
  49521. * @param options defines the options used to create the mesh
  49522. * @param scene defines the hosting scene
  49523. * @returns the dashed line mesh
  49524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49525. */
  49526. static CreateDashedLines(name: string, options: {
  49527. points: Vector3[];
  49528. dashSize?: number;
  49529. gapSize?: number;
  49530. dashNb?: number;
  49531. updatable?: boolean;
  49532. instance?: LinesMesh;
  49533. }, scene?: Nullable<Scene>): LinesMesh;
  49534. /**
  49535. * 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.
  49536. * * 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.
  49537. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49538. * * 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.
  49539. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49540. * * 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
  49541. * * 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
  49542. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49545. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49547. * @param name defines the name of the mesh
  49548. * @param options defines the options used to create the mesh
  49549. * @param scene defines the hosting scene
  49550. * @returns the extruded shape mesh
  49551. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49553. */
  49554. static ExtrudeShape(name: string, options: {
  49555. shape: Vector3[];
  49556. path: Vector3[];
  49557. scale?: number;
  49558. rotation?: number;
  49559. cap?: number;
  49560. updatable?: boolean;
  49561. sideOrientation?: number;
  49562. frontUVs?: Vector4;
  49563. backUVs?: Vector4;
  49564. instance?: Mesh;
  49565. invertUV?: boolean;
  49566. }, scene?: Nullable<Scene>): Mesh;
  49567. /**
  49568. * Creates an custom extruded shape mesh.
  49569. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49570. * * 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.
  49571. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49572. * * 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
  49573. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49574. * * 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
  49575. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49576. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49577. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49578. * * 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
  49579. * * 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
  49580. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49585. * @param name defines the name of the mesh
  49586. * @param options defines the options used to create the mesh
  49587. * @param scene defines the hosting scene
  49588. * @returns the custom extruded shape mesh
  49589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49592. */
  49593. static ExtrudeShapeCustom(name: string, options: {
  49594. shape: Vector3[];
  49595. path: Vector3[];
  49596. scaleFunction?: any;
  49597. rotationFunction?: any;
  49598. ribbonCloseArray?: boolean;
  49599. ribbonClosePath?: boolean;
  49600. cap?: number;
  49601. updatable?: boolean;
  49602. sideOrientation?: number;
  49603. frontUVs?: Vector4;
  49604. backUVs?: Vector4;
  49605. instance?: Mesh;
  49606. invertUV?: boolean;
  49607. }, scene: Scene): Mesh;
  49608. /**
  49609. * Creates lathe mesh.
  49610. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49611. * * 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
  49612. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49613. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49614. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49615. * * 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
  49616. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49617. * * 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
  49618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49622. * @param name defines the name of the mesh
  49623. * @param options defines the options used to create the mesh
  49624. * @param scene defines the hosting scene
  49625. * @returns the lathe mesh
  49626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49627. */
  49628. static CreateLathe(name: string, options: {
  49629. shape: Vector3[];
  49630. radius?: number;
  49631. tessellation?: number;
  49632. clip?: number;
  49633. arc?: number;
  49634. closed?: boolean;
  49635. updatable?: boolean;
  49636. sideOrientation?: number;
  49637. frontUVs?: Vector4;
  49638. backUVs?: Vector4;
  49639. cap?: number;
  49640. invertUV?: boolean;
  49641. }, scene: Scene): Mesh;
  49642. /**
  49643. * Creates a plane mesh
  49644. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49645. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49646. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49650. * @param name defines the name of the mesh
  49651. * @param options defines the options used to create the mesh
  49652. * @param scene defines the hosting scene
  49653. * @returns the plane mesh
  49654. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49655. */
  49656. static CreatePlane(name: string, options: {
  49657. size?: number;
  49658. width?: number;
  49659. height?: number;
  49660. sideOrientation?: number;
  49661. frontUVs?: Vector4;
  49662. backUVs?: Vector4;
  49663. updatable?: boolean;
  49664. sourcePlane?: Plane;
  49665. }, scene: Scene): Mesh;
  49666. /**
  49667. * Creates a ground mesh
  49668. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49669. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49671. * @param name defines the name of the mesh
  49672. * @param options defines the options used to create the mesh
  49673. * @param scene defines the hosting scene
  49674. * @returns the ground mesh
  49675. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49676. */
  49677. static CreateGround(name: string, options: {
  49678. width?: number;
  49679. height?: number;
  49680. subdivisions?: number;
  49681. subdivisionsX?: number;
  49682. subdivisionsY?: number;
  49683. updatable?: boolean;
  49684. }, scene: any): Mesh;
  49685. /**
  49686. * Creates a tiled ground mesh
  49687. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49688. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49689. * * 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
  49690. * * 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
  49691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49692. * @param name defines the name of the mesh
  49693. * @param options defines the options used to create the mesh
  49694. * @param scene defines the hosting scene
  49695. * @returns the tiled ground mesh
  49696. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49697. */
  49698. static CreateTiledGround(name: string, options: {
  49699. xmin: number;
  49700. zmin: number;
  49701. xmax: number;
  49702. zmax: number;
  49703. subdivisions?: {
  49704. w: number;
  49705. h: number;
  49706. };
  49707. precision?: {
  49708. w: number;
  49709. h: number;
  49710. };
  49711. updatable?: boolean;
  49712. }, scene: Scene): Mesh;
  49713. /**
  49714. * Creates a ground mesh from a height map
  49715. * * The parameter `url` sets the URL of the height map image resource.
  49716. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49717. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49718. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49719. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49720. * * 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.
  49721. * * 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).
  49722. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49724. * @param name defines the name of the mesh
  49725. * @param url defines the url to the height map
  49726. * @param options defines the options used to create the mesh
  49727. * @param scene defines the hosting scene
  49728. * @returns the ground mesh
  49729. * @see https://doc.babylonjs.com/babylon101/height_map
  49730. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49731. */
  49732. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49733. width?: number;
  49734. height?: number;
  49735. subdivisions?: number;
  49736. minHeight?: number;
  49737. maxHeight?: number;
  49738. colorFilter?: Color3;
  49739. alphaFilter?: number;
  49740. updatable?: boolean;
  49741. onReady?: (mesh: GroundMesh) => void;
  49742. }, scene: Scene): GroundMesh;
  49743. /**
  49744. * Creates a polygon mesh
  49745. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49746. * * 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
  49747. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49750. * * Remember you can only change the shape positions, not their number when updating a polygon
  49751. * @param name defines the name of the mesh
  49752. * @param options defines the options used to create the mesh
  49753. * @param scene defines the hosting scene
  49754. * @param earcutInjection can be used to inject your own earcut reference
  49755. * @returns the polygon mesh
  49756. */
  49757. static CreatePolygon(name: string, options: {
  49758. shape: Vector3[];
  49759. holes?: Vector3[][];
  49760. depth?: number;
  49761. faceUV?: Vector4[];
  49762. faceColors?: Color4[];
  49763. updatable?: boolean;
  49764. sideOrientation?: number;
  49765. frontUVs?: Vector4;
  49766. backUVs?: Vector4;
  49767. }, scene: Scene, earcutInjection?: any): Mesh;
  49768. /**
  49769. * Creates an extruded polygon mesh, with depth in the Y direction.
  49770. * * 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)
  49771. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49772. * @param name defines the name of the mesh
  49773. * @param options defines the options used to create the mesh
  49774. * @param scene defines the hosting scene
  49775. * @param earcutInjection can be used to inject your own earcut reference
  49776. * @returns the polygon mesh
  49777. */
  49778. static ExtrudePolygon(name: string, options: {
  49779. shape: Vector3[];
  49780. holes?: Vector3[][];
  49781. depth?: number;
  49782. faceUV?: Vector4[];
  49783. faceColors?: Color4[];
  49784. updatable?: boolean;
  49785. sideOrientation?: number;
  49786. frontUVs?: Vector4;
  49787. backUVs?: Vector4;
  49788. }, scene: Scene, earcutInjection?: any): Mesh;
  49789. /**
  49790. * Creates a tube mesh.
  49791. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49792. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49793. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49794. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49795. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49796. * * 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)
  49797. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49798. * * 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
  49799. * * 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
  49800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49802. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49804. * @param name defines the name of the mesh
  49805. * @param options defines the options used to create the mesh
  49806. * @param scene defines the hosting scene
  49807. * @returns the tube mesh
  49808. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49809. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49810. */
  49811. static CreateTube(name: string, options: {
  49812. path: Vector3[];
  49813. radius?: number;
  49814. tessellation?: number;
  49815. radiusFunction?: {
  49816. (i: number, distance: number): number;
  49817. };
  49818. cap?: number;
  49819. arc?: number;
  49820. updatable?: boolean;
  49821. sideOrientation?: number;
  49822. frontUVs?: Vector4;
  49823. backUVs?: Vector4;
  49824. instance?: Mesh;
  49825. invertUV?: boolean;
  49826. }, scene: Scene): Mesh;
  49827. /**
  49828. * Creates a polyhedron mesh
  49829. * * 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
  49830. * * The parameter `size` (positive float, default 1) sets the polygon size
  49831. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49832. * * 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`
  49833. * * 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
  49834. * * 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)`)
  49835. * * 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
  49836. * * 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
  49837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49840. * @param name defines the name of the mesh
  49841. * @param options defines the options used to create the mesh
  49842. * @param scene defines the hosting scene
  49843. * @returns the polyhedron mesh
  49844. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49845. */
  49846. static CreatePolyhedron(name: string, options: {
  49847. type?: number;
  49848. size?: number;
  49849. sizeX?: number;
  49850. sizeY?: number;
  49851. sizeZ?: number;
  49852. custom?: any;
  49853. faceUV?: Vector4[];
  49854. faceColors?: Color4[];
  49855. flat?: boolean;
  49856. updatable?: boolean;
  49857. sideOrientation?: number;
  49858. frontUVs?: Vector4;
  49859. backUVs?: Vector4;
  49860. }, scene: Scene): Mesh;
  49861. /**
  49862. * Creates a decal mesh.
  49863. * 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
  49864. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49865. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49866. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49867. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49868. * @param name defines the name of the mesh
  49869. * @param sourceMesh defines the mesh where the decal must be applied
  49870. * @param options defines the options used to create the mesh
  49871. * @param scene defines the hosting scene
  49872. * @returns the decal mesh
  49873. * @see https://doc.babylonjs.com/how_to/decals
  49874. */
  49875. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49876. position?: Vector3;
  49877. normal?: Vector3;
  49878. size?: Vector3;
  49879. angle?: number;
  49880. }): Mesh;
  49881. }
  49882. }
  49883. declare module "babylonjs/Meshes/meshSimplification" {
  49884. import { Mesh } from "babylonjs/Meshes/mesh";
  49885. /**
  49886. * A simplifier interface for future simplification implementations
  49887. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49888. */
  49889. export interface ISimplifier {
  49890. /**
  49891. * Simplification of a given mesh according to the given settings.
  49892. * Since this requires computation, it is assumed that the function runs async.
  49893. * @param settings The settings of the simplification, including quality and distance
  49894. * @param successCallback A callback that will be called after the mesh was simplified.
  49895. * @param errorCallback in case of an error, this callback will be called. optional.
  49896. */
  49897. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49898. }
  49899. /**
  49900. * Expected simplification settings.
  49901. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49902. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49903. */
  49904. export interface ISimplificationSettings {
  49905. /**
  49906. * Gets or sets the expected quality
  49907. */
  49908. quality: number;
  49909. /**
  49910. * Gets or sets the distance when this optimized version should be used
  49911. */
  49912. distance: number;
  49913. /**
  49914. * Gets an already optimized mesh
  49915. */
  49916. optimizeMesh?: boolean;
  49917. }
  49918. /**
  49919. * Class used to specify simplification options
  49920. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49921. */
  49922. export class SimplificationSettings implements ISimplificationSettings {
  49923. /** expected quality */
  49924. quality: number;
  49925. /** distance when this optimized version should be used */
  49926. distance: number;
  49927. /** already optimized mesh */
  49928. optimizeMesh?: boolean | undefined;
  49929. /**
  49930. * Creates a SimplificationSettings
  49931. * @param quality expected quality
  49932. * @param distance distance when this optimized version should be used
  49933. * @param optimizeMesh already optimized mesh
  49934. */
  49935. constructor(
  49936. /** expected quality */
  49937. quality: number,
  49938. /** distance when this optimized version should be used */
  49939. distance: number,
  49940. /** already optimized mesh */
  49941. optimizeMesh?: boolean | undefined);
  49942. }
  49943. /**
  49944. * Interface used to define a simplification task
  49945. */
  49946. export interface ISimplificationTask {
  49947. /**
  49948. * Array of settings
  49949. */
  49950. settings: Array<ISimplificationSettings>;
  49951. /**
  49952. * Simplification type
  49953. */
  49954. simplificationType: SimplificationType;
  49955. /**
  49956. * Mesh to simplify
  49957. */
  49958. mesh: Mesh;
  49959. /**
  49960. * Callback called on success
  49961. */
  49962. successCallback?: () => void;
  49963. /**
  49964. * Defines if parallel processing can be used
  49965. */
  49966. parallelProcessing: boolean;
  49967. }
  49968. /**
  49969. * Queue used to order the simplification tasks
  49970. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49971. */
  49972. export class SimplificationQueue {
  49973. private _simplificationArray;
  49974. /**
  49975. * Gets a boolean indicating that the process is still running
  49976. */
  49977. running: boolean;
  49978. /**
  49979. * Creates a new queue
  49980. */
  49981. constructor();
  49982. /**
  49983. * Adds a new simplification task
  49984. * @param task defines a task to add
  49985. */
  49986. addTask(task: ISimplificationTask): void;
  49987. /**
  49988. * Execute next task
  49989. */
  49990. executeNext(): void;
  49991. /**
  49992. * Execute a simplification task
  49993. * @param task defines the task to run
  49994. */
  49995. runSimplification(task: ISimplificationTask): void;
  49996. private getSimplifier;
  49997. }
  49998. /**
  49999. * The implemented types of simplification
  50000. * At the moment only Quadratic Error Decimation is implemented
  50001. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50002. */
  50003. export enum SimplificationType {
  50004. /** Quadratic error decimation */
  50005. QUADRATIC = 0
  50006. }
  50007. }
  50008. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50009. import { Scene } from "babylonjs/scene";
  50010. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50011. import { ISceneComponent } from "babylonjs/sceneComponent";
  50012. module "babylonjs/scene" {
  50013. interface Scene {
  50014. /** @hidden (Backing field) */
  50015. _simplificationQueue: SimplificationQueue;
  50016. /**
  50017. * Gets or sets the simplification queue attached to the scene
  50018. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50019. */
  50020. simplificationQueue: SimplificationQueue;
  50021. }
  50022. }
  50023. module "babylonjs/Meshes/mesh" {
  50024. interface Mesh {
  50025. /**
  50026. * Simplify the mesh according to the given array of settings.
  50027. * Function will return immediately and will simplify async
  50028. * @param settings a collection of simplification settings
  50029. * @param parallelProcessing should all levels calculate parallel or one after the other
  50030. * @param simplificationType the type of simplification to run
  50031. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50032. * @returns the current mesh
  50033. */
  50034. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50035. }
  50036. }
  50037. /**
  50038. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50039. * created in a scene
  50040. */
  50041. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50042. /**
  50043. * The component name helpfull to identify the component in the list of scene components.
  50044. */
  50045. readonly name: string;
  50046. /**
  50047. * The scene the component belongs to.
  50048. */
  50049. scene: Scene;
  50050. /**
  50051. * Creates a new instance of the component for the given scene
  50052. * @param scene Defines the scene to register the component in
  50053. */
  50054. constructor(scene: Scene);
  50055. /**
  50056. * Registers the component in a given scene
  50057. */
  50058. register(): void;
  50059. /**
  50060. * Rebuilds the elements related to this component in case of
  50061. * context lost for instance.
  50062. */
  50063. rebuild(): void;
  50064. /**
  50065. * Disposes the component and the associated ressources
  50066. */
  50067. dispose(): void;
  50068. private _beforeCameraUpdate;
  50069. }
  50070. }
  50071. declare module "babylonjs/Meshes/Builders/index" {
  50072. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50073. export * from "babylonjs/Meshes/Builders/discBuilder";
  50074. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50075. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50076. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50077. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50078. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50079. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50080. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50081. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50082. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50083. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50084. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50085. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50086. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50087. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50088. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50089. }
  50090. declare module "babylonjs/Meshes/index" {
  50091. export * from "babylonjs/Meshes/abstractMesh";
  50092. export * from "babylonjs/Meshes/buffer";
  50093. export * from "babylonjs/Meshes/Compression/index";
  50094. export * from "babylonjs/Meshes/csg";
  50095. export * from "babylonjs/Meshes/geometry";
  50096. export * from "babylonjs/Meshes/groundMesh";
  50097. export * from "babylonjs/Meshes/instancedMesh";
  50098. export * from "babylonjs/Meshes/linesMesh";
  50099. export * from "babylonjs/Meshes/mesh";
  50100. export * from "babylonjs/Meshes/mesh.vertexData";
  50101. export * from "babylonjs/Meshes/meshBuilder";
  50102. export * from "babylonjs/Meshes/meshSimplification";
  50103. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50104. export * from "babylonjs/Meshes/polygonMesh";
  50105. export * from "babylonjs/Meshes/subMesh";
  50106. export * from "babylonjs/Meshes/transformNode";
  50107. export * from "babylonjs/Meshes/Builders/index";
  50108. }
  50109. declare module "babylonjs/Morph/index" {
  50110. export * from "babylonjs/Morph/morphTarget";
  50111. export * from "babylonjs/Morph/morphTargetManager";
  50112. }
  50113. declare module "babylonjs/Offline/database" {
  50114. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50115. /**
  50116. * Class used to enable access to IndexedDB
  50117. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50118. */
  50119. export class Database implements IOfflineProvider {
  50120. private _callbackManifestChecked;
  50121. private _currentSceneUrl;
  50122. private _db;
  50123. private _enableSceneOffline;
  50124. private _enableTexturesOffline;
  50125. private _manifestVersionFound;
  50126. private _mustUpdateRessources;
  50127. private _hasReachedQuota;
  50128. private _isSupported;
  50129. private _idbFactory;
  50130. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50131. private static IsUASupportingBlobStorage;
  50132. /**
  50133. * Gets a boolean indicating if Database storate is enabled (off by default)
  50134. */
  50135. static IDBStorageEnabled: boolean;
  50136. /**
  50137. * Gets a boolean indicating if scene must be saved in the database
  50138. */
  50139. readonly enableSceneOffline: boolean;
  50140. /**
  50141. * Gets a boolean indicating if textures must be saved in the database
  50142. */
  50143. readonly enableTexturesOffline: boolean;
  50144. /**
  50145. * Creates a new Database
  50146. * @param urlToScene defines the url to load the scene
  50147. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50148. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50149. */
  50150. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50151. private static _ParseURL;
  50152. private static _ReturnFullUrlLocation;
  50153. private _checkManifestFile;
  50154. /**
  50155. * Open the database and make it available
  50156. * @param successCallback defines the callback to call on success
  50157. * @param errorCallback defines the callback to call on error
  50158. */
  50159. open(successCallback: () => void, errorCallback: () => void): void;
  50160. /**
  50161. * Loads an image from the database
  50162. * @param url defines the url to load from
  50163. * @param image defines the target DOM image
  50164. */
  50165. loadImage(url: string, image: HTMLImageElement): void;
  50166. private _loadImageFromDBAsync;
  50167. private _saveImageIntoDBAsync;
  50168. private _checkVersionFromDB;
  50169. private _loadVersionFromDBAsync;
  50170. private _saveVersionIntoDBAsync;
  50171. /**
  50172. * Loads a file from database
  50173. * @param url defines the URL to load from
  50174. * @param sceneLoaded defines a callback to call on success
  50175. * @param progressCallBack defines a callback to call when progress changed
  50176. * @param errorCallback defines a callback to call on error
  50177. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50178. */
  50179. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50180. private _loadFileAsync;
  50181. private _saveFileAsync;
  50182. /**
  50183. * Validates if xhr data is correct
  50184. * @param xhr defines the request to validate
  50185. * @param dataType defines the expected data type
  50186. * @returns true if data is correct
  50187. */
  50188. private static _ValidateXHRData;
  50189. }
  50190. }
  50191. declare module "babylonjs/Offline/index" {
  50192. export * from "babylonjs/Offline/database";
  50193. export * from "babylonjs/Offline/IOfflineProvider";
  50194. }
  50195. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50196. /** @hidden */
  50197. export var gpuUpdateParticlesPixelShader: {
  50198. name: string;
  50199. shader: string;
  50200. };
  50201. }
  50202. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50203. /** @hidden */
  50204. export var gpuUpdateParticlesVertexShader: {
  50205. name: string;
  50206. shader: string;
  50207. };
  50208. }
  50209. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50210. /** @hidden */
  50211. export var clipPlaneFragmentDeclaration2: {
  50212. name: string;
  50213. shader: string;
  50214. };
  50215. }
  50216. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50217. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50218. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50219. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50220. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50221. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50222. /** @hidden */
  50223. export var gpuRenderParticlesPixelShader: {
  50224. name: string;
  50225. shader: string;
  50226. };
  50227. }
  50228. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50229. /** @hidden */
  50230. export var clipPlaneVertexDeclaration2: {
  50231. name: string;
  50232. shader: string;
  50233. };
  50234. }
  50235. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50236. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50237. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50238. /** @hidden */
  50239. export var gpuRenderParticlesVertexShader: {
  50240. name: string;
  50241. shader: string;
  50242. };
  50243. }
  50244. declare module "babylonjs/Particles/gpuParticleSystem" {
  50245. import { Nullable } from "babylonjs/types";
  50246. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50247. import { Observable } from "babylonjs/Misc/observable";
  50248. import { Color4, Color3 } from "babylonjs/Maths/math";
  50249. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50250. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50251. import { Scene, IDisposable } from "babylonjs/scene";
  50252. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50253. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50254. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50255. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50256. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50257. /**
  50258. * This represents a GPU particle system in Babylon
  50259. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50260. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50261. */
  50262. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50263. /**
  50264. * The layer mask we are rendering the particles through.
  50265. */
  50266. layerMask: number;
  50267. private _capacity;
  50268. private _activeCount;
  50269. private _currentActiveCount;
  50270. private _accumulatedCount;
  50271. private _renderEffect;
  50272. private _updateEffect;
  50273. private _buffer0;
  50274. private _buffer1;
  50275. private _spriteBuffer;
  50276. private _updateVAO;
  50277. private _renderVAO;
  50278. private _targetIndex;
  50279. private _sourceBuffer;
  50280. private _targetBuffer;
  50281. private _engine;
  50282. private _currentRenderId;
  50283. private _started;
  50284. private _stopped;
  50285. private _timeDelta;
  50286. private _randomTexture;
  50287. private _randomTexture2;
  50288. private _attributesStrideSize;
  50289. private _updateEffectOptions;
  50290. private _randomTextureSize;
  50291. private _actualFrame;
  50292. private readonly _rawTextureWidth;
  50293. /**
  50294. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50295. */
  50296. static readonly IsSupported: boolean;
  50297. /**
  50298. * An event triggered when the system is disposed.
  50299. */
  50300. onDisposeObservable: Observable<GPUParticleSystem>;
  50301. /**
  50302. * Gets the maximum number of particles active at the same time.
  50303. * @returns The max number of active particles.
  50304. */
  50305. getCapacity(): number;
  50306. /**
  50307. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50308. * to override the particles.
  50309. */
  50310. forceDepthWrite: boolean;
  50311. /**
  50312. * Gets or set the number of active particles
  50313. */
  50314. activeParticleCount: number;
  50315. private _preWarmDone;
  50316. /**
  50317. * Is this system ready to be used/rendered
  50318. * @return true if the system is ready
  50319. */
  50320. isReady(): boolean;
  50321. /**
  50322. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50323. * @returns True if it has been started, otherwise false.
  50324. */
  50325. isStarted(): boolean;
  50326. /**
  50327. * Starts the particle system and begins to emit
  50328. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50329. */
  50330. start(delay?: number): void;
  50331. /**
  50332. * Stops the particle system.
  50333. */
  50334. stop(): void;
  50335. /**
  50336. * Remove all active particles
  50337. */
  50338. reset(): void;
  50339. /**
  50340. * Returns the string "GPUParticleSystem"
  50341. * @returns a string containing the class name
  50342. */
  50343. getClassName(): string;
  50344. private _colorGradientsTexture;
  50345. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50346. /**
  50347. * Adds a new color gradient
  50348. * @param gradient defines the gradient to use (between 0 and 1)
  50349. * @param color1 defines the color to affect to the specified gradient
  50350. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50351. * @returns the current particle system
  50352. */
  50353. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50354. /**
  50355. * Remove a specific color gradient
  50356. * @param gradient defines the gradient to remove
  50357. * @returns the current particle system
  50358. */
  50359. removeColorGradient(gradient: number): GPUParticleSystem;
  50360. private _angularSpeedGradientsTexture;
  50361. private _sizeGradientsTexture;
  50362. private _velocityGradientsTexture;
  50363. private _limitVelocityGradientsTexture;
  50364. private _dragGradientsTexture;
  50365. private _addFactorGradient;
  50366. /**
  50367. * Adds a new size gradient
  50368. * @param gradient defines the gradient to use (between 0 and 1)
  50369. * @param factor defines the size factor to affect to the specified gradient
  50370. * @returns the current particle system
  50371. */
  50372. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50373. /**
  50374. * Remove a specific size gradient
  50375. * @param gradient defines the gradient to remove
  50376. * @returns the current particle system
  50377. */
  50378. removeSizeGradient(gradient: number): GPUParticleSystem;
  50379. /**
  50380. * Adds a new angular speed gradient
  50381. * @param gradient defines the gradient to use (between 0 and 1)
  50382. * @param factor defines the angular speed to affect to the specified gradient
  50383. * @returns the current particle system
  50384. */
  50385. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50386. /**
  50387. * Remove a specific angular speed gradient
  50388. * @param gradient defines the gradient to remove
  50389. * @returns the current particle system
  50390. */
  50391. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50392. /**
  50393. * Adds a new velocity gradient
  50394. * @param gradient defines the gradient to use (between 0 and 1)
  50395. * @param factor defines the velocity to affect to the specified gradient
  50396. * @returns the current particle system
  50397. */
  50398. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50399. /**
  50400. * Remove a specific velocity gradient
  50401. * @param gradient defines the gradient to remove
  50402. * @returns the current particle system
  50403. */
  50404. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50405. /**
  50406. * Adds a new limit velocity gradient
  50407. * @param gradient defines the gradient to use (between 0 and 1)
  50408. * @param factor defines the limit velocity value to affect to the specified gradient
  50409. * @returns the current particle system
  50410. */
  50411. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50412. /**
  50413. * Remove a specific limit velocity gradient
  50414. * @param gradient defines the gradient to remove
  50415. * @returns the current particle system
  50416. */
  50417. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50418. /**
  50419. * Adds a new drag gradient
  50420. * @param gradient defines the gradient to use (between 0 and 1)
  50421. * @param factor defines the drag value to affect to the specified gradient
  50422. * @returns the current particle system
  50423. */
  50424. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50425. /**
  50426. * Remove a specific drag gradient
  50427. * @param gradient defines the gradient to remove
  50428. * @returns the current particle system
  50429. */
  50430. removeDragGradient(gradient: number): GPUParticleSystem;
  50431. /**
  50432. * Not supported by GPUParticleSystem
  50433. * @param gradient defines the gradient to use (between 0 and 1)
  50434. * @param factor defines the emit rate value to affect to the specified gradient
  50435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50436. * @returns the current particle system
  50437. */
  50438. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50439. /**
  50440. * Not supported by GPUParticleSystem
  50441. * @param gradient defines the gradient to remove
  50442. * @returns the current particle system
  50443. */
  50444. removeEmitRateGradient(gradient: number): IParticleSystem;
  50445. /**
  50446. * Not supported by GPUParticleSystem
  50447. * @param gradient defines the gradient to use (between 0 and 1)
  50448. * @param factor defines the start size value to affect to the specified gradient
  50449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50450. * @returns the current particle system
  50451. */
  50452. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50453. /**
  50454. * Not supported by GPUParticleSystem
  50455. * @param gradient defines the gradient to remove
  50456. * @returns the current particle system
  50457. */
  50458. removeStartSizeGradient(gradient: number): IParticleSystem;
  50459. /**
  50460. * Not supported by GPUParticleSystem
  50461. * @param gradient defines the gradient to use (between 0 and 1)
  50462. * @param min defines the color remap minimal range
  50463. * @param max defines the color remap maximal range
  50464. * @returns the current particle system
  50465. */
  50466. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50467. /**
  50468. * Not supported by GPUParticleSystem
  50469. * @param gradient defines the gradient to remove
  50470. * @returns the current particle system
  50471. */
  50472. removeColorRemapGradient(): IParticleSystem;
  50473. /**
  50474. * Not supported by GPUParticleSystem
  50475. * @param gradient defines the gradient to use (between 0 and 1)
  50476. * @param min defines the alpha remap minimal range
  50477. * @param max defines the alpha remap maximal range
  50478. * @returns the current particle system
  50479. */
  50480. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50481. /**
  50482. * Not supported by GPUParticleSystem
  50483. * @param gradient defines the gradient to remove
  50484. * @returns the current particle system
  50485. */
  50486. removeAlphaRemapGradient(): IParticleSystem;
  50487. /**
  50488. * Not supported by GPUParticleSystem
  50489. * @param gradient defines the gradient to use (between 0 and 1)
  50490. * @param color defines the color to affect to the specified gradient
  50491. * @returns the current particle system
  50492. */
  50493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50494. /**
  50495. * Not supported by GPUParticleSystem
  50496. * @param gradient defines the gradient to remove
  50497. * @returns the current particle system
  50498. */
  50499. removeRampGradient(): IParticleSystem;
  50500. /**
  50501. * Not supported by GPUParticleSystem
  50502. * @returns the list of ramp gradients
  50503. */
  50504. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50505. /**
  50506. * Not supported by GPUParticleSystem
  50507. * Gets or sets a boolean indicating that ramp gradients must be used
  50508. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50509. */
  50510. useRampGradients: boolean;
  50511. /**
  50512. * Not supported by GPUParticleSystem
  50513. * @param gradient defines the gradient to use (between 0 and 1)
  50514. * @param factor defines the life time factor to affect to the specified gradient
  50515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50516. * @returns the current particle system
  50517. */
  50518. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50519. /**
  50520. * Not supported by GPUParticleSystem
  50521. * @param gradient defines the gradient to remove
  50522. * @returns the current particle system
  50523. */
  50524. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50525. /**
  50526. * Instantiates a GPU particle system.
  50527. * 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.
  50528. * @param name The name of the particle system
  50529. * @param options The options used to create the system
  50530. * @param scene The scene the particle system belongs to
  50531. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50532. */
  50533. constructor(name: string, options: Partial<{
  50534. capacity: number;
  50535. randomTextureSize: number;
  50536. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50537. protected _reset(): void;
  50538. private _createUpdateVAO;
  50539. private _createRenderVAO;
  50540. private _initialize;
  50541. /** @hidden */
  50542. _recreateUpdateEffect(): void;
  50543. /** @hidden */
  50544. _recreateRenderEffect(): void;
  50545. /**
  50546. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50547. * @param preWarm defines if we are in the pre-warmimg phase
  50548. */
  50549. animate(preWarm?: boolean): void;
  50550. private _createFactorGradientTexture;
  50551. private _createSizeGradientTexture;
  50552. private _createAngularSpeedGradientTexture;
  50553. private _createVelocityGradientTexture;
  50554. private _createLimitVelocityGradientTexture;
  50555. private _createDragGradientTexture;
  50556. private _createColorGradientTexture;
  50557. /**
  50558. * Renders the particle system in its current state
  50559. * @param preWarm defines if the system should only update the particles but not render them
  50560. * @returns the current number of particles
  50561. */
  50562. render(preWarm?: boolean): number;
  50563. /**
  50564. * Rebuilds the particle system
  50565. */
  50566. rebuild(): void;
  50567. private _releaseBuffers;
  50568. private _releaseVAOs;
  50569. /**
  50570. * Disposes the particle system and free the associated resources
  50571. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50572. */
  50573. dispose(disposeTexture?: boolean): void;
  50574. /**
  50575. * Clones the particle system.
  50576. * @param name The name of the cloned object
  50577. * @param newEmitter The new emitter to use
  50578. * @returns the cloned particle system
  50579. */
  50580. clone(name: string, newEmitter: any): GPUParticleSystem;
  50581. /**
  50582. * Serializes the particle system to a JSON object.
  50583. * @returns the JSON object
  50584. */
  50585. serialize(): any;
  50586. /**
  50587. * Parses a JSON object to create a GPU particle system.
  50588. * @param parsedParticleSystem The JSON object to parse
  50589. * @param scene The scene to create the particle system in
  50590. * @param rootUrl The root url to use to load external dependencies like texture
  50591. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50592. * @returns the parsed GPU particle system
  50593. */
  50594. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50595. }
  50596. }
  50597. declare module "babylonjs/Particles/particleSystemSet" {
  50598. import { Nullable } from "babylonjs/types";
  50599. import { Color3 } from "babylonjs/Maths/math";
  50600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50603. import { Scene, IDisposable } from "babylonjs/scene";
  50604. /**
  50605. * Represents a set of particle systems working together to create a specific effect
  50606. */
  50607. export class ParticleSystemSet implements IDisposable {
  50608. private _emitterCreationOptions;
  50609. private _emitterNode;
  50610. /**
  50611. * Gets the particle system list
  50612. */
  50613. systems: IParticleSystem[];
  50614. /**
  50615. * Gets the emitter node used with this set
  50616. */
  50617. readonly emitterNode: Nullable<TransformNode>;
  50618. /**
  50619. * Creates a new emitter mesh as a sphere
  50620. * @param options defines the options used to create the sphere
  50621. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50622. * @param scene defines the hosting scene
  50623. */
  50624. setEmitterAsSphere(options: {
  50625. diameter: number;
  50626. segments: number;
  50627. color: Color3;
  50628. }, renderingGroupId: number, scene: Scene): void;
  50629. /**
  50630. * Starts all particle systems of the set
  50631. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50632. */
  50633. start(emitter?: AbstractMesh): void;
  50634. /**
  50635. * Release all associated resources
  50636. */
  50637. dispose(): void;
  50638. /**
  50639. * Serialize the set into a JSON compatible object
  50640. * @returns a JSON compatible representation of the set
  50641. */
  50642. serialize(): any;
  50643. /**
  50644. * Parse a new ParticleSystemSet from a serialized source
  50645. * @param data defines a JSON compatible representation of the set
  50646. * @param scene defines the hosting scene
  50647. * @param gpu defines if we want GPU particles or CPU particles
  50648. * @returns a new ParticleSystemSet
  50649. */
  50650. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50651. }
  50652. }
  50653. declare module "babylonjs/Particles/particleHelper" {
  50654. import { Nullable } from "babylonjs/types";
  50655. import { Scene } from "babylonjs/scene";
  50656. import { Vector3 } from "babylonjs/Maths/math";
  50657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50658. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50659. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50660. /**
  50661. * This class is made for on one-liner static method to help creating particle system set.
  50662. */
  50663. export class ParticleHelper {
  50664. /**
  50665. * Gets or sets base Assets URL
  50666. */
  50667. static BaseAssetsUrl: string;
  50668. /**
  50669. * Create a default particle system that you can tweak
  50670. * @param emitter defines the emitter to use
  50671. * @param capacity defines the system capacity (default is 500 particles)
  50672. * @param scene defines the hosting scene
  50673. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50674. * @returns the new Particle system
  50675. */
  50676. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50677. /**
  50678. * This is the main static method (one-liner) of this helper to create different particle systems
  50679. * @param type This string represents the type to the particle system to create
  50680. * @param scene The scene where the particle system should live
  50681. * @param gpu If the system will use gpu
  50682. * @returns the ParticleSystemSet created
  50683. */
  50684. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50685. /**
  50686. * Static function used to export a particle system to a ParticleSystemSet variable.
  50687. * Please note that the emitter shape is not exported
  50688. * @param systems defines the particle systems to export
  50689. * @returns the created particle system set
  50690. */
  50691. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50692. }
  50693. }
  50694. declare module "babylonjs/Particles/particleSystemComponent" {
  50695. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50696. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50697. import "babylonjs/Shaders/particles.vertex";
  50698. module "babylonjs/Engines/engine" {
  50699. interface Engine {
  50700. /**
  50701. * Create an effect to use with particle systems.
  50702. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50703. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50704. * @param uniformsNames defines a list of attribute names
  50705. * @param samplers defines an array of string used to represent textures
  50706. * @param defines defines the string containing the defines to use to compile the shaders
  50707. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50708. * @param onCompiled defines a function to call when the effect creation is successful
  50709. * @param onError defines a function to call when the effect creation has failed
  50710. * @returns the new Effect
  50711. */
  50712. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50713. }
  50714. }
  50715. module "babylonjs/Meshes/mesh" {
  50716. interface Mesh {
  50717. /**
  50718. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50719. * @returns an array of IParticleSystem
  50720. */
  50721. getEmittedParticleSystems(): IParticleSystem[];
  50722. /**
  50723. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50724. * @returns an array of IParticleSystem
  50725. */
  50726. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50727. }
  50728. }
  50729. /**
  50730. * @hidden
  50731. */
  50732. export var _IDoNeedToBeInTheBuild: number;
  50733. }
  50734. declare module "babylonjs/Particles/index" {
  50735. export * from "babylonjs/Particles/baseParticleSystem";
  50736. export * from "babylonjs/Particles/EmitterTypes/index";
  50737. export * from "babylonjs/Particles/gpuParticleSystem";
  50738. export * from "babylonjs/Particles/IParticleSystem";
  50739. export * from "babylonjs/Particles/particle";
  50740. export * from "babylonjs/Particles/particleHelper";
  50741. export * from "babylonjs/Particles/particleSystem";
  50742. export * from "babylonjs/Particles/particleSystemComponent";
  50743. export * from "babylonjs/Particles/particleSystemSet";
  50744. export * from "babylonjs/Particles/solidParticle";
  50745. export * from "babylonjs/Particles/solidParticleSystem";
  50746. export * from "babylonjs/Particles/subEmitter";
  50747. }
  50748. declare module "babylonjs/Physics/physicsEngineComponent" {
  50749. import { Nullable } from "babylonjs/types";
  50750. import { Observable, Observer } from "babylonjs/Misc/observable";
  50751. import { Vector3 } from "babylonjs/Maths/math";
  50752. import { Mesh } from "babylonjs/Meshes/mesh";
  50753. import { ISceneComponent } from "babylonjs/sceneComponent";
  50754. import { Scene } from "babylonjs/scene";
  50755. import { Node } from "babylonjs/node";
  50756. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50757. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50758. module "babylonjs/scene" {
  50759. interface Scene {
  50760. /** @hidden (Backing field) */
  50761. _physicsEngine: Nullable<IPhysicsEngine>;
  50762. /**
  50763. * Gets the current physics engine
  50764. * @returns a IPhysicsEngine or null if none attached
  50765. */
  50766. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50767. /**
  50768. * Enables physics to the current scene
  50769. * @param gravity defines the scene's gravity for the physics engine
  50770. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50771. * @return a boolean indicating if the physics engine was initialized
  50772. */
  50773. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50774. /**
  50775. * Disables and disposes the physics engine associated with the scene
  50776. */
  50777. disablePhysicsEngine(): void;
  50778. /**
  50779. * Gets a boolean indicating if there is an active physics engine
  50780. * @returns a boolean indicating if there is an active physics engine
  50781. */
  50782. isPhysicsEnabled(): boolean;
  50783. /**
  50784. * Deletes a physics compound impostor
  50785. * @param compound defines the compound to delete
  50786. */
  50787. deleteCompoundImpostor(compound: any): void;
  50788. /**
  50789. * An event triggered when physic simulation is about to be run
  50790. */
  50791. onBeforePhysicsObservable: Observable<Scene>;
  50792. /**
  50793. * An event triggered when physic simulation has been done
  50794. */
  50795. onAfterPhysicsObservable: Observable<Scene>;
  50796. }
  50797. }
  50798. module "babylonjs/Meshes/abstractMesh" {
  50799. interface AbstractMesh {
  50800. /** @hidden */
  50801. _physicsImpostor: Nullable<PhysicsImpostor>;
  50802. /**
  50803. * Gets or sets impostor used for physic simulation
  50804. * @see http://doc.babylonjs.com/features/physics_engine
  50805. */
  50806. physicsImpostor: Nullable<PhysicsImpostor>;
  50807. /**
  50808. * Gets the current physics impostor
  50809. * @see http://doc.babylonjs.com/features/physics_engine
  50810. * @returns a physics impostor or null
  50811. */
  50812. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50813. /** Apply a physic impulse to the mesh
  50814. * @param force defines the force to apply
  50815. * @param contactPoint defines where to apply the force
  50816. * @returns the current mesh
  50817. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50818. */
  50819. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50820. /**
  50821. * Creates a physic joint between two meshes
  50822. * @param otherMesh defines the other mesh to use
  50823. * @param pivot1 defines the pivot to use on this mesh
  50824. * @param pivot2 defines the pivot to use on the other mesh
  50825. * @param options defines additional options (can be plugin dependent)
  50826. * @returns the current mesh
  50827. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50828. */
  50829. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50830. /** @hidden */
  50831. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50832. }
  50833. }
  50834. /**
  50835. * Defines the physics engine scene component responsible to manage a physics engine
  50836. */
  50837. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50838. /**
  50839. * The component name helpful to identify the component in the list of scene components.
  50840. */
  50841. readonly name: string;
  50842. /**
  50843. * The scene the component belongs to.
  50844. */
  50845. scene: Scene;
  50846. /**
  50847. * Creates a new instance of the component for the given scene
  50848. * @param scene Defines the scene to register the component in
  50849. */
  50850. constructor(scene: Scene);
  50851. /**
  50852. * Registers the component in a given scene
  50853. */
  50854. register(): void;
  50855. /**
  50856. * Rebuilds the elements related to this component in case of
  50857. * context lost for instance.
  50858. */
  50859. rebuild(): void;
  50860. /**
  50861. * Disposes the component and the associated ressources
  50862. */
  50863. dispose(): void;
  50864. }
  50865. }
  50866. declare module "babylonjs/Physics/physicsHelper" {
  50867. import { Nullable } from "babylonjs/types";
  50868. import { Vector3 } from "babylonjs/Maths/math";
  50869. import { Mesh } from "babylonjs/Meshes/mesh";
  50870. import { Ray } from "babylonjs/Culling/ray";
  50871. import { Scene } from "babylonjs/scene";
  50872. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50873. /**
  50874. * A helper for physics simulations
  50875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50876. */
  50877. export class PhysicsHelper {
  50878. private _scene;
  50879. private _physicsEngine;
  50880. /**
  50881. * Initializes the Physics helper
  50882. * @param scene Babylon.js scene
  50883. */
  50884. constructor(scene: Scene);
  50885. /**
  50886. * Applies a radial explosion impulse
  50887. * @param origin the origin of the explosion
  50888. * @param radius the explosion radius
  50889. * @param strength the explosion strength
  50890. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50891. * @returns A physics radial explosion event, or null
  50892. */
  50893. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50894. /**
  50895. * Applies a radial explosion force
  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. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50903. /**
  50904. * Creates a gravitational field
  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 gravitational field event, or null
  50910. */
  50911. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50912. /**
  50913. * Creates a physics updraft event
  50914. * @param origin the origin of the updraft
  50915. * @param radius the radius of the updraft
  50916. * @param strength the strength of the updraft
  50917. * @param height the height of the updraft
  50918. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50919. * @returns A physics updraft event, or null
  50920. */
  50921. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50922. /**
  50923. * Creates a physics vortex event
  50924. * @param origin the of the vortex
  50925. * @param radius the radius of the vortex
  50926. * @param strength the strength of the vortex
  50927. * @param height the height of the vortex
  50928. * @returns a Physics vortex event, or null
  50929. * A physics vortex event or null
  50930. */
  50931. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50932. }
  50933. /**
  50934. * Represents a physics radial explosion event
  50935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50936. */
  50937. export class PhysicsRadialExplosionEvent {
  50938. private _scene;
  50939. private _sphere;
  50940. private _sphereOptions;
  50941. private _rays;
  50942. private _dataFetched;
  50943. /**
  50944. * Initializes a radial explosioin event
  50945. * @param scene BabylonJS scene
  50946. */
  50947. constructor(scene: Scene);
  50948. /**
  50949. * Returns the data related to the radial explosion event (sphere & rays).
  50950. * @returns The radial explosion event data
  50951. */
  50952. getData(): PhysicsRadialExplosionEventData;
  50953. /**
  50954. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50955. * @param impostor A physics imposter
  50956. * @param origin the origin of the explosion
  50957. * @param radius the explosion radius
  50958. * @param strength the explosion strength
  50959. * @param falloff possible options: Constant & Linear
  50960. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50961. */
  50962. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50963. /**
  50964. * Disposes the sphere.
  50965. * @param force Specifies if the sphere should be disposed by force
  50966. */
  50967. dispose(force?: boolean): void;
  50968. /*** Helpers ***/
  50969. private _prepareSphere;
  50970. private _intersectsWithSphere;
  50971. }
  50972. /**
  50973. * Represents a gravitational field event
  50974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50975. */
  50976. export class PhysicsGravitationalFieldEvent {
  50977. private _physicsHelper;
  50978. private _scene;
  50979. private _origin;
  50980. private _radius;
  50981. private _strength;
  50982. private _falloff;
  50983. private _tickCallback;
  50984. private _sphere;
  50985. private _dataFetched;
  50986. /**
  50987. * Initializes the physics gravitational field event
  50988. * @param physicsHelper A physics helper
  50989. * @param scene BabylonJS scene
  50990. * @param origin The origin position of the gravitational field event
  50991. * @param radius The radius of the gravitational field event
  50992. * @param strength The strength of the gravitational field event
  50993. * @param falloff The falloff for the gravitational field event
  50994. */
  50995. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50996. /**
  50997. * Returns the data related to the gravitational field event (sphere).
  50998. * @returns A gravitational field event
  50999. */
  51000. getData(): PhysicsGravitationalFieldEventData;
  51001. /**
  51002. * Enables the gravitational field.
  51003. */
  51004. enable(): void;
  51005. /**
  51006. * Disables the gravitational field.
  51007. */
  51008. disable(): void;
  51009. /**
  51010. * Disposes the sphere.
  51011. * @param force The force to dispose from the gravitational field event
  51012. */
  51013. dispose(force?: boolean): void;
  51014. private _tick;
  51015. }
  51016. /**
  51017. * Represents a physics updraft event
  51018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51019. */
  51020. export class PhysicsUpdraftEvent {
  51021. private _scene;
  51022. private _origin;
  51023. private _radius;
  51024. private _strength;
  51025. private _height;
  51026. private _updraftMode;
  51027. private _physicsEngine;
  51028. private _originTop;
  51029. private _originDirection;
  51030. private _tickCallback;
  51031. private _cylinder;
  51032. private _cylinderPosition;
  51033. private _dataFetched;
  51034. /**
  51035. * Initializes the physics updraft event
  51036. * @param _scene BabylonJS scene
  51037. * @param _origin The origin position of the updraft
  51038. * @param _radius The radius of the updraft
  51039. * @param _strength The strength of the updraft
  51040. * @param _height The height of the updraft
  51041. * @param _updraftMode The mode of the updraft
  51042. */
  51043. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51044. /**
  51045. * Returns the data related to the updraft event (cylinder).
  51046. * @returns A physics updraft event
  51047. */
  51048. getData(): PhysicsUpdraftEventData;
  51049. /**
  51050. * Enables the updraft.
  51051. */
  51052. enable(): void;
  51053. /**
  51054. * Disables the cortex.
  51055. */
  51056. disable(): void;
  51057. /**
  51058. * Disposes the sphere.
  51059. * @param force Specifies if the updraft should be disposed by force
  51060. */
  51061. dispose(force?: boolean): void;
  51062. private getImpostorForceAndContactPoint;
  51063. private _tick;
  51064. /*** Helpers ***/
  51065. private _prepareCylinder;
  51066. private _intersectsWithCylinder;
  51067. }
  51068. /**
  51069. * Represents a physics vortex event
  51070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51071. */
  51072. export class PhysicsVortexEvent {
  51073. private _scene;
  51074. private _origin;
  51075. private _radius;
  51076. private _strength;
  51077. private _height;
  51078. private _physicsEngine;
  51079. private _originTop;
  51080. private _centripetalForceThreshold;
  51081. private _updraftMultiplier;
  51082. private _tickCallback;
  51083. private _cylinder;
  51084. private _cylinderPosition;
  51085. private _dataFetched;
  51086. /**
  51087. * Initializes the physics vortex event
  51088. * @param _scene The BabylonJS scene
  51089. * @param _origin The origin position of the vortex
  51090. * @param _radius The radius of the vortex
  51091. * @param _strength The strength of the vortex
  51092. * @param _height The height of the vortex
  51093. */
  51094. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51095. /**
  51096. * Returns the data related to the vortex event (cylinder).
  51097. * @returns The physics vortex event data
  51098. */
  51099. getData(): PhysicsVortexEventData;
  51100. /**
  51101. * Enables the vortex.
  51102. */
  51103. enable(): void;
  51104. /**
  51105. * Disables the cortex.
  51106. */
  51107. disable(): void;
  51108. /**
  51109. * Disposes the sphere.
  51110. * @param force
  51111. */
  51112. dispose(force?: boolean): void;
  51113. private getImpostorForceAndContactPoint;
  51114. private _tick;
  51115. /*** Helpers ***/
  51116. private _prepareCylinder;
  51117. private _intersectsWithCylinder;
  51118. }
  51119. /**
  51120. * The strenght of the force in correspondence to the distance of the affected object
  51121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51122. */
  51123. export enum PhysicsRadialImpulseFalloff {
  51124. /** Defines that impulse is constant in strength across it's whole radius */
  51125. Constant = 0,
  51126. /** DEfines that impulse gets weaker if it's further from the origin */
  51127. Linear = 1
  51128. }
  51129. /**
  51130. * The strength of the force in correspondence to the distance of the affected object
  51131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51132. */
  51133. export enum PhysicsUpdraftMode {
  51134. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51135. Center = 0,
  51136. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51137. Perpendicular = 1
  51138. }
  51139. /**
  51140. * Interface for a physics force and contact point
  51141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51142. */
  51143. export interface PhysicsForceAndContactPoint {
  51144. /**
  51145. * The force applied at the contact point
  51146. */
  51147. force: Vector3;
  51148. /**
  51149. * The contact point
  51150. */
  51151. contactPoint: Vector3;
  51152. }
  51153. /**
  51154. * Interface for radial explosion event data
  51155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51156. */
  51157. export interface PhysicsRadialExplosionEventData {
  51158. /**
  51159. * A sphere used for the radial explosion event
  51160. */
  51161. sphere: Mesh;
  51162. /**
  51163. * An array of rays for the radial explosion event
  51164. */
  51165. rays: Array<Ray>;
  51166. }
  51167. /**
  51168. * Interface for gravitational field event data
  51169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51170. */
  51171. export interface PhysicsGravitationalFieldEventData {
  51172. /**
  51173. * A sphere mesh used for the gravitational field event
  51174. */
  51175. sphere: Mesh;
  51176. }
  51177. /**
  51178. * Interface for updraft event data
  51179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51180. */
  51181. export interface PhysicsUpdraftEventData {
  51182. /**
  51183. * A cylinder used for the updraft event
  51184. */
  51185. cylinder: Mesh;
  51186. }
  51187. /**
  51188. * Interface for vortex event data
  51189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51190. */
  51191. export interface PhysicsVortexEventData {
  51192. /**
  51193. * A cylinder used for the vortex event
  51194. */
  51195. cylinder: Mesh;
  51196. }
  51197. }
  51198. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51199. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51200. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51201. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51202. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51203. import { Nullable } from "babylonjs/types";
  51204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51205. /**
  51206. * AmmoJS Physics plugin
  51207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51208. * @see https://github.com/kripken/ammo.js/
  51209. */
  51210. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51211. private _useDeltaForWorldStep;
  51212. /**
  51213. * Reference to the Ammo library
  51214. */
  51215. bjsAMMO: any;
  51216. /**
  51217. * Created ammoJS world which physics bodies are added to
  51218. */
  51219. world: any;
  51220. /**
  51221. * Name of the plugin
  51222. */
  51223. name: string;
  51224. private _timeStep;
  51225. private _fixedTimeStep;
  51226. private _maxSteps;
  51227. private _tmpQuaternion;
  51228. private _tmpAmmoTransform;
  51229. private _tmpAmmoQuaternion;
  51230. private _tmpAmmoConcreteContactResultCallback;
  51231. private _collisionConfiguration;
  51232. private _dispatcher;
  51233. private _overlappingPairCache;
  51234. private _solver;
  51235. private _tmpAmmoVectorA;
  51236. private _tmpAmmoVectorB;
  51237. private _tmpAmmoVectorC;
  51238. private _tmpContactCallbackResult;
  51239. private static readonly DISABLE_COLLISION_FLAG;
  51240. private static readonly KINEMATIC_FLAG;
  51241. private static readonly DISABLE_DEACTIVATION_FLAG;
  51242. /**
  51243. * Initializes the ammoJS plugin
  51244. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51245. * @param ammoInjection can be used to inject your own ammo reference
  51246. */
  51247. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51248. /**
  51249. * Sets the gravity of the physics world (m/(s^2))
  51250. * @param gravity Gravity to set
  51251. */
  51252. setGravity(gravity: Vector3): void;
  51253. /**
  51254. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51255. * @param timeStep timestep to use in seconds
  51256. */
  51257. setTimeStep(timeStep: number): void;
  51258. /**
  51259. * 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)
  51260. * @param fixedTimeStep fixedTimeStep to use in seconds
  51261. */
  51262. setFixedTimeStep(fixedTimeStep: number): void;
  51263. /**
  51264. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51265. * @param maxSteps the maximum number of steps by the physics engine per frame
  51266. */
  51267. setMaxSteps(maxSteps: number): void;
  51268. /**
  51269. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51270. * @returns the current timestep in seconds
  51271. */
  51272. getTimeStep(): number;
  51273. private _isImpostorInContact;
  51274. private _isImpostorPairInContact;
  51275. private _stepSimulation;
  51276. /**
  51277. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51278. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51279. * After the step the babylon meshes are set to the position of the physics imposters
  51280. * @param delta amount of time to step forward
  51281. * @param impostors array of imposters to update before/after the step
  51282. */
  51283. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51284. private _tmpVector;
  51285. private _tmpMatrix;
  51286. /**
  51287. * Applies an implulse on the imposter
  51288. * @param impostor imposter to apply impulse
  51289. * @param force amount of force to be applied to the imposter
  51290. * @param contactPoint the location to apply the impulse on the imposter
  51291. */
  51292. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51293. /**
  51294. * Applies a force on the imposter
  51295. * @param impostor imposter to apply force
  51296. * @param force amount of force to be applied to the imposter
  51297. * @param contactPoint the location to apply the force on the imposter
  51298. */
  51299. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51300. /**
  51301. * Creates a physics body using the plugin
  51302. * @param impostor the imposter to create the physics body on
  51303. */
  51304. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51305. /**
  51306. * Removes the physics body from the imposter and disposes of the body's memory
  51307. * @param impostor imposter to remove the physics body from
  51308. */
  51309. removePhysicsBody(impostor: PhysicsImpostor): void;
  51310. /**
  51311. * Generates a joint
  51312. * @param impostorJoint the imposter joint to create the joint with
  51313. */
  51314. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51315. /**
  51316. * Removes a joint
  51317. * @param impostorJoint the imposter joint to remove the joint from
  51318. */
  51319. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51320. private _addMeshVerts;
  51321. private _createShape;
  51322. /**
  51323. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51324. * @param impostor imposter containing the physics body and babylon object
  51325. */
  51326. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51327. /**
  51328. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51329. * @param impostor imposter containing the physics body and babylon object
  51330. * @param newPosition new position
  51331. * @param newRotation new rotation
  51332. */
  51333. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51334. /**
  51335. * If this plugin is supported
  51336. * @returns true if its supported
  51337. */
  51338. isSupported(): boolean;
  51339. /**
  51340. * Sets the linear velocity of the physics body
  51341. * @param impostor imposter to set the velocity on
  51342. * @param velocity velocity to set
  51343. */
  51344. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51345. /**
  51346. * Sets the angular velocity of the physics body
  51347. * @param impostor imposter to set the velocity on
  51348. * @param velocity velocity to set
  51349. */
  51350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51351. /**
  51352. * gets the linear velocity
  51353. * @param impostor imposter to get linear velocity from
  51354. * @returns linear velocity
  51355. */
  51356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51357. /**
  51358. * gets the angular velocity
  51359. * @param impostor imposter to get angular velocity from
  51360. * @returns angular velocity
  51361. */
  51362. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51363. /**
  51364. * Sets the mass of physics body
  51365. * @param impostor imposter to set the mass on
  51366. * @param mass mass to set
  51367. */
  51368. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51369. /**
  51370. * Gets the mass of the physics body
  51371. * @param impostor imposter to get the mass from
  51372. * @returns mass
  51373. */
  51374. getBodyMass(impostor: PhysicsImpostor): number;
  51375. /**
  51376. * Gets friction of the impostor
  51377. * @param impostor impostor to get friction from
  51378. * @returns friction value
  51379. */
  51380. getBodyFriction(impostor: PhysicsImpostor): number;
  51381. /**
  51382. * Sets friction of the impostor
  51383. * @param impostor impostor to set friction on
  51384. * @param friction friction value
  51385. */
  51386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51387. /**
  51388. * Gets restitution of the impostor
  51389. * @param impostor impostor to get restitution from
  51390. * @returns restitution value
  51391. */
  51392. getBodyRestitution(impostor: PhysicsImpostor): number;
  51393. /**
  51394. * Sets resitution of the impostor
  51395. * @param impostor impostor to set resitution on
  51396. * @param restitution resitution value
  51397. */
  51398. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51399. /**
  51400. * Sleeps the physics body and stops it from being active
  51401. * @param impostor impostor to sleep
  51402. */
  51403. sleepBody(impostor: PhysicsImpostor): void;
  51404. /**
  51405. * Activates the physics body
  51406. * @param impostor impostor to activate
  51407. */
  51408. wakeUpBody(impostor: PhysicsImpostor): void;
  51409. /**
  51410. * Updates the distance parameters of the joint
  51411. * @param joint joint to update
  51412. * @param maxDistance maximum distance of the joint
  51413. * @param minDistance minimum distance of the joint
  51414. */
  51415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51416. /**
  51417. * Sets a motor on the joint
  51418. * @param joint joint to set motor on
  51419. * @param speed speed of the motor
  51420. * @param maxForce maximum force of the motor
  51421. * @param motorIndex index of the motor
  51422. */
  51423. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51424. /**
  51425. * Sets the motors limit
  51426. * @param joint joint to set limit on
  51427. * @param upperLimit upper limit
  51428. * @param lowerLimit lower limit
  51429. */
  51430. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51431. /**
  51432. * Syncs the position and rotation of a mesh with the impostor
  51433. * @param mesh mesh to sync
  51434. * @param impostor impostor to update the mesh with
  51435. */
  51436. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51437. /**
  51438. * Gets the radius of the impostor
  51439. * @param impostor impostor to get radius from
  51440. * @returns the radius
  51441. */
  51442. getRadius(impostor: PhysicsImpostor): number;
  51443. /**
  51444. * Gets the box size of the impostor
  51445. * @param impostor impostor to get box size from
  51446. * @param result the resulting box size
  51447. */
  51448. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51449. /**
  51450. * Disposes of the impostor
  51451. */
  51452. dispose(): void;
  51453. }
  51454. }
  51455. declare module "babylonjs/Physics/Plugins/index" {
  51456. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51457. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51458. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51459. }
  51460. declare module "babylonjs/Physics/index" {
  51461. export * from "babylonjs/Physics/IPhysicsEngine";
  51462. export * from "babylonjs/Physics/physicsEngine";
  51463. export * from "babylonjs/Physics/physicsEngineComponent";
  51464. export * from "babylonjs/Physics/physicsHelper";
  51465. export * from "babylonjs/Physics/physicsImpostor";
  51466. export * from "babylonjs/Physics/physicsJoint";
  51467. export * from "babylonjs/Physics/Plugins/index";
  51468. }
  51469. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51470. /** @hidden */
  51471. export var blackAndWhitePixelShader: {
  51472. name: string;
  51473. shader: string;
  51474. };
  51475. }
  51476. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51478. import { Camera } from "babylonjs/Cameras/camera";
  51479. import { Engine } from "babylonjs/Engines/engine";
  51480. import "babylonjs/Shaders/blackAndWhite.fragment";
  51481. /**
  51482. * Post process used to render in black and white
  51483. */
  51484. export class BlackAndWhitePostProcess extends PostProcess {
  51485. /**
  51486. * Linear about to convert he result to black and white (default: 1)
  51487. */
  51488. degree: number;
  51489. /**
  51490. * Creates a black and white post process
  51491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51492. * @param name The name of the effect.
  51493. * @param options The required width/height ratio to downsize to before computing the render pass.
  51494. * @param camera The camera to apply the render pass to.
  51495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51496. * @param engine The engine which the post process will be applied. (default: current engine)
  51497. * @param reusable If the post process can be reused on the same frame. (default: false)
  51498. */
  51499. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51500. }
  51501. }
  51502. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51503. import { Nullable } from "babylonjs/types";
  51504. import { Camera } from "babylonjs/Cameras/camera";
  51505. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51506. import { Engine } from "babylonjs/Engines/engine";
  51507. /**
  51508. * This represents a set of one or more post processes in Babylon.
  51509. * A post process can be used to apply a shader to a texture after it is rendered.
  51510. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51511. */
  51512. export class PostProcessRenderEffect {
  51513. private _postProcesses;
  51514. private _getPostProcesses;
  51515. private _singleInstance;
  51516. private _cameras;
  51517. private _indicesForCamera;
  51518. /**
  51519. * Name of the effect
  51520. * @hidden
  51521. */
  51522. _name: string;
  51523. /**
  51524. * Instantiates a post process render effect.
  51525. * A post process can be used to apply a shader to a texture after it is rendered.
  51526. * @param engine The engine the effect is tied to
  51527. * @param name The name of the effect
  51528. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51529. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51530. */
  51531. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51532. /**
  51533. * Checks if all the post processes in the effect are supported.
  51534. */
  51535. readonly isSupported: boolean;
  51536. /**
  51537. * Updates the current state of the effect
  51538. * @hidden
  51539. */
  51540. _update(): void;
  51541. /**
  51542. * Attaches the effect on cameras
  51543. * @param cameras The camera to attach to.
  51544. * @hidden
  51545. */
  51546. _attachCameras(cameras: Camera): void;
  51547. /**
  51548. * Attaches the effect on cameras
  51549. * @param cameras The camera to attach to.
  51550. * @hidden
  51551. */
  51552. _attachCameras(cameras: Camera[]): void;
  51553. /**
  51554. * Detatches the effect on cameras
  51555. * @param cameras The camera to detatch from.
  51556. * @hidden
  51557. */
  51558. _detachCameras(cameras: Camera): void;
  51559. /**
  51560. * Detatches the effect on cameras
  51561. * @param cameras The camera to detatch from.
  51562. * @hidden
  51563. */
  51564. _detachCameras(cameras: Camera[]): void;
  51565. /**
  51566. * Enables the effect on given cameras
  51567. * @param cameras The camera to enable.
  51568. * @hidden
  51569. */
  51570. _enable(cameras: Camera): void;
  51571. /**
  51572. * Enables the effect on given cameras
  51573. * @param cameras The camera to enable.
  51574. * @hidden
  51575. */
  51576. _enable(cameras: Nullable<Camera[]>): void;
  51577. /**
  51578. * Disables the effect on the given cameras
  51579. * @param cameras The camera to disable.
  51580. * @hidden
  51581. */
  51582. _disable(cameras: Camera): void;
  51583. /**
  51584. * Disables the effect on the given cameras
  51585. * @param cameras The camera to disable.
  51586. * @hidden
  51587. */
  51588. _disable(cameras: Nullable<Camera[]>): void;
  51589. /**
  51590. * Gets a list of the post processes contained in the effect.
  51591. * @param camera The camera to get the post processes on.
  51592. * @returns The list of the post processes in the effect.
  51593. */
  51594. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51595. }
  51596. }
  51597. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51598. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51599. /** @hidden */
  51600. export var extractHighlightsPixelShader: {
  51601. name: string;
  51602. shader: string;
  51603. };
  51604. }
  51605. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51606. import { Nullable } from "babylonjs/types";
  51607. import { Camera } from "babylonjs/Cameras/camera";
  51608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51609. import { Engine } from "babylonjs/Engines/engine";
  51610. import "babylonjs/Shaders/extractHighlights.fragment";
  51611. /**
  51612. * 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.
  51613. */
  51614. export class ExtractHighlightsPostProcess extends PostProcess {
  51615. /**
  51616. * The luminance threshold, pixels below this value will be set to black.
  51617. */
  51618. threshold: number;
  51619. /** @hidden */
  51620. _exposure: number;
  51621. /**
  51622. * Post process which has the input texture to be used when performing highlight extraction
  51623. * @hidden
  51624. */
  51625. _inputPostProcess: Nullable<PostProcess>;
  51626. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51627. }
  51628. }
  51629. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51630. /** @hidden */
  51631. export var bloomMergePixelShader: {
  51632. name: string;
  51633. shader: string;
  51634. };
  51635. }
  51636. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51637. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51638. import { Nullable } from "babylonjs/types";
  51639. import { Engine } from "babylonjs/Engines/engine";
  51640. import { Camera } from "babylonjs/Cameras/camera";
  51641. import "babylonjs/Shaders/bloomMerge.fragment";
  51642. /**
  51643. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51644. */
  51645. export class BloomMergePostProcess extends PostProcess {
  51646. /** Weight of the bloom to be added to the original input. */
  51647. weight: number;
  51648. /**
  51649. * Creates a new instance of @see BloomMergePostProcess
  51650. * @param name The name of the effect.
  51651. * @param originalFromInput Post process which's input will be used for the merge.
  51652. * @param blurred Blurred highlights post process which's output will be used.
  51653. * @param weight Weight of the bloom to be added to the original input.
  51654. * @param options The required width/height ratio to downsize to before computing the render pass.
  51655. * @param camera The camera to apply the render pass to.
  51656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51657. * @param engine The engine which the post process will be applied. (default: current engine)
  51658. * @param reusable If the post process can be reused on the same frame. (default: false)
  51659. * @param textureType Type of textures used when performing the post process. (default: 0)
  51660. * @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)
  51661. */
  51662. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51663. /** Weight of the bloom to be added to the original input. */
  51664. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51665. }
  51666. }
  51667. declare module "babylonjs/PostProcesses/bloomEffect" {
  51668. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51669. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51670. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51671. import { Camera } from "babylonjs/Cameras/camera";
  51672. import { Scene } from "babylonjs/scene";
  51673. /**
  51674. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51675. */
  51676. export class BloomEffect extends PostProcessRenderEffect {
  51677. private bloomScale;
  51678. /**
  51679. * @hidden Internal
  51680. */
  51681. _effects: Array<PostProcess>;
  51682. /**
  51683. * @hidden Internal
  51684. */
  51685. _downscale: ExtractHighlightsPostProcess;
  51686. private _blurX;
  51687. private _blurY;
  51688. private _merge;
  51689. /**
  51690. * The luminance threshold to find bright areas of the image to bloom.
  51691. */
  51692. threshold: number;
  51693. /**
  51694. * The strength of the bloom.
  51695. */
  51696. weight: number;
  51697. /**
  51698. * Specifies the size of the bloom blur kernel, relative to the final output size
  51699. */
  51700. kernel: number;
  51701. /**
  51702. * Creates a new instance of @see BloomEffect
  51703. * @param scene The scene the effect belongs to.
  51704. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51705. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51706. * @param bloomWeight The the strength of bloom.
  51707. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51708. * @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)
  51709. */
  51710. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51711. /**
  51712. * Disposes each of the internal effects for a given camera.
  51713. * @param camera The camera to dispose the effect on.
  51714. */
  51715. disposeEffects(camera: Camera): void;
  51716. /**
  51717. * @hidden Internal
  51718. */
  51719. _updateEffects(): void;
  51720. /**
  51721. * Internal
  51722. * @returns if all the contained post processes are ready.
  51723. * @hidden
  51724. */
  51725. _isReady(): boolean;
  51726. }
  51727. }
  51728. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51729. /** @hidden */
  51730. export var chromaticAberrationPixelShader: {
  51731. name: string;
  51732. shader: string;
  51733. };
  51734. }
  51735. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51736. import { Vector2 } from "babylonjs/Maths/math";
  51737. import { Nullable } from "babylonjs/types";
  51738. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51739. import { Camera } from "babylonjs/Cameras/camera";
  51740. import { Engine } from "babylonjs/Engines/engine";
  51741. import "babylonjs/Shaders/chromaticAberration.fragment";
  51742. /**
  51743. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51744. */
  51745. export class ChromaticAberrationPostProcess extends PostProcess {
  51746. /**
  51747. * The amount of seperation of rgb channels (default: 30)
  51748. */
  51749. aberrationAmount: number;
  51750. /**
  51751. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51752. */
  51753. radialIntensity: number;
  51754. /**
  51755. * 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))
  51756. */
  51757. direction: Vector2;
  51758. /**
  51759. * 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))
  51760. */
  51761. centerPosition: Vector2;
  51762. /**
  51763. * Creates a new instance ChromaticAberrationPostProcess
  51764. * @param name The name of the effect.
  51765. * @param screenWidth The width of the screen to apply the effect on.
  51766. * @param screenHeight The height of the screen to apply the effect on.
  51767. * @param options The required width/height ratio to downsize to before computing the render pass.
  51768. * @param camera The camera to apply the render pass to.
  51769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51770. * @param engine The engine which the post process will be applied. (default: current engine)
  51771. * @param reusable If the post process can be reused on the same frame. (default: false)
  51772. * @param textureType Type of textures used when performing the post process. (default: 0)
  51773. * @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)
  51774. */
  51775. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51776. }
  51777. }
  51778. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51779. /** @hidden */
  51780. export var circleOfConfusionPixelShader: {
  51781. name: string;
  51782. shader: string;
  51783. };
  51784. }
  51785. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51786. import { Nullable } from "babylonjs/types";
  51787. import { Engine } from "babylonjs/Engines/engine";
  51788. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51790. import { Camera } from "babylonjs/Cameras/camera";
  51791. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51792. /**
  51793. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51794. */
  51795. export class CircleOfConfusionPostProcess extends PostProcess {
  51796. /**
  51797. * 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.
  51798. */
  51799. lensSize: number;
  51800. /**
  51801. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51802. */
  51803. fStop: number;
  51804. /**
  51805. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51806. */
  51807. focusDistance: number;
  51808. /**
  51809. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51810. */
  51811. focalLength: number;
  51812. private _depthTexture;
  51813. /**
  51814. * Creates a new instance CircleOfConfusionPostProcess
  51815. * @param name The name of the effect.
  51816. * @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.
  51817. * @param options The required width/height ratio to downsize to before computing the render pass.
  51818. * @param camera The camera to apply the render pass to.
  51819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51820. * @param engine The engine which the post process will be applied. (default: current engine)
  51821. * @param reusable If the post process can be reused on the same frame. (default: false)
  51822. * @param textureType Type of textures used when performing the post process. (default: 0)
  51823. * @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)
  51824. */
  51825. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51826. /**
  51827. * 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.
  51828. */
  51829. depthTexture: RenderTargetTexture;
  51830. }
  51831. }
  51832. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51833. /** @hidden */
  51834. export var colorCorrectionPixelShader: {
  51835. name: string;
  51836. shader: string;
  51837. };
  51838. }
  51839. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51840. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51841. import { Engine } from "babylonjs/Engines/engine";
  51842. import { Camera } from "babylonjs/Cameras/camera";
  51843. import "babylonjs/Shaders/colorCorrection.fragment";
  51844. /**
  51845. *
  51846. * This post-process allows the modification of rendered colors by using
  51847. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51848. *
  51849. * The object needs to be provided an url to a texture containing the color
  51850. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51851. * Use an image editing software to tweak the LUT to match your needs.
  51852. *
  51853. * For an example of a color LUT, see here:
  51854. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51855. * For explanations on color grading, see here:
  51856. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51857. *
  51858. */
  51859. export class ColorCorrectionPostProcess extends PostProcess {
  51860. private _colorTableTexture;
  51861. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51862. }
  51863. }
  51864. declare module "babylonjs/Shaders/convolution.fragment" {
  51865. /** @hidden */
  51866. export var convolutionPixelShader: {
  51867. name: string;
  51868. shader: string;
  51869. };
  51870. }
  51871. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51872. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51873. import { Nullable } from "babylonjs/types";
  51874. import { Camera } from "babylonjs/Cameras/camera";
  51875. import { Engine } from "babylonjs/Engines/engine";
  51876. import "babylonjs/Shaders/convolution.fragment";
  51877. /**
  51878. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51879. * input texture to perform effects such as edge detection or sharpening
  51880. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51881. */
  51882. export class ConvolutionPostProcess extends PostProcess {
  51883. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51884. kernel: number[];
  51885. /**
  51886. * Creates a new instance ConvolutionPostProcess
  51887. * @param name The name of the effect.
  51888. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51889. * @param options The required width/height ratio to downsize to before computing the render pass.
  51890. * @param camera The camera to apply the render pass to.
  51891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51892. * @param engine The engine which the post process will be applied. (default: current engine)
  51893. * @param reusable If the post process can be reused on the same frame. (default: false)
  51894. * @param textureType Type of textures used when performing the post process. (default: 0)
  51895. */
  51896. constructor(name: string,
  51897. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51898. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51899. /**
  51900. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51901. */
  51902. static EdgeDetect0Kernel: number[];
  51903. /**
  51904. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51905. */
  51906. static EdgeDetect1Kernel: number[];
  51907. /**
  51908. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51909. */
  51910. static EdgeDetect2Kernel: number[];
  51911. /**
  51912. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51913. */
  51914. static SharpenKernel: number[];
  51915. /**
  51916. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51917. */
  51918. static EmbossKernel: number[];
  51919. /**
  51920. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51921. */
  51922. static GaussianKernel: number[];
  51923. }
  51924. }
  51925. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51926. import { Nullable } from "babylonjs/types";
  51927. import { Vector2 } from "babylonjs/Maths/math";
  51928. import { Camera } from "babylonjs/Cameras/camera";
  51929. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51930. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51931. import { Engine } from "babylonjs/Engines/engine";
  51932. import { Scene } from "babylonjs/scene";
  51933. /**
  51934. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51935. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51936. * based on samples that have a large difference in distance than the center pixel.
  51937. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51938. */
  51939. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51940. direction: Vector2;
  51941. /**
  51942. * Creates a new instance CircleOfConfusionPostProcess
  51943. * @param name The name of the effect.
  51944. * @param scene The scene the effect belongs to.
  51945. * @param direction The direction the blur should be applied.
  51946. * @param kernel The size of the kernel used to blur.
  51947. * @param options The required width/height ratio to downsize to before computing the render pass.
  51948. * @param camera The camera to apply the render pass to.
  51949. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51950. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51952. * @param engine The engine which the post process will be applied. (default: current engine)
  51953. * @param reusable If the post process can be reused on the same frame. (default: false)
  51954. * @param textureType Type of textures used when performing the post process. (default: 0)
  51955. * @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)
  51956. */
  51957. 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);
  51958. }
  51959. }
  51960. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51961. /** @hidden */
  51962. export var depthOfFieldMergePixelShader: {
  51963. name: string;
  51964. shader: string;
  51965. };
  51966. }
  51967. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51968. import { Nullable } from "babylonjs/types";
  51969. import { Camera } from "babylonjs/Cameras/camera";
  51970. import { Effect } from "babylonjs/Materials/effect";
  51971. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51972. import { Engine } from "babylonjs/Engines/engine";
  51973. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51974. /**
  51975. * Options to be set when merging outputs from the default pipeline.
  51976. */
  51977. export class DepthOfFieldMergePostProcessOptions {
  51978. /**
  51979. * The original image to merge on top of
  51980. */
  51981. originalFromInput: PostProcess;
  51982. /**
  51983. * Parameters to perform the merge of the depth of field effect
  51984. */
  51985. depthOfField?: {
  51986. circleOfConfusion: PostProcess;
  51987. blurSteps: Array<PostProcess>;
  51988. };
  51989. /**
  51990. * Parameters to perform the merge of bloom effect
  51991. */
  51992. bloom?: {
  51993. blurred: PostProcess;
  51994. weight: number;
  51995. };
  51996. }
  51997. /**
  51998. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51999. */
  52000. export class DepthOfFieldMergePostProcess extends PostProcess {
  52001. private blurSteps;
  52002. /**
  52003. * Creates a new instance of DepthOfFieldMergePostProcess
  52004. * @param name The name of the effect.
  52005. * @param originalFromInput Post process which's input will be used for the merge.
  52006. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52007. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52008. * @param options The required width/height ratio to downsize to before computing the render pass.
  52009. * @param camera The camera to apply the render pass to.
  52010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52011. * @param engine The engine which the post process will be applied. (default: current engine)
  52012. * @param reusable If the post process can be reused on the same frame. (default: false)
  52013. * @param textureType Type of textures used when performing the post process. (default: 0)
  52014. * @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)
  52015. */
  52016. 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);
  52017. /**
  52018. * Updates the effect with the current post process compile time values and recompiles the shader.
  52019. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52020. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52021. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52022. * @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
  52023. * @param onCompiled Called when the shader has been compiled.
  52024. * @param onError Called if there is an error when compiling a shader.
  52025. */
  52026. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52027. }
  52028. }
  52029. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52030. import { Nullable } from "babylonjs/types";
  52031. import { Camera } from "babylonjs/Cameras/camera";
  52032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52033. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52034. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52035. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52036. import { Scene } from "babylonjs/scene";
  52037. /**
  52038. * Specifies the level of max blur that should be applied when using the depth of field effect
  52039. */
  52040. export enum DepthOfFieldEffectBlurLevel {
  52041. /**
  52042. * Subtle blur
  52043. */
  52044. Low = 0,
  52045. /**
  52046. * Medium blur
  52047. */
  52048. Medium = 1,
  52049. /**
  52050. * Large blur
  52051. */
  52052. High = 2
  52053. }
  52054. /**
  52055. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52056. */
  52057. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52058. private _circleOfConfusion;
  52059. /**
  52060. * @hidden Internal, blurs from high to low
  52061. */
  52062. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52063. private _depthOfFieldBlurY;
  52064. private _dofMerge;
  52065. /**
  52066. * @hidden Internal post processes in depth of field effect
  52067. */
  52068. _effects: Array<PostProcess>;
  52069. /**
  52070. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52071. */
  52072. focalLength: number;
  52073. /**
  52074. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52075. */
  52076. fStop: number;
  52077. /**
  52078. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52079. */
  52080. focusDistance: number;
  52081. /**
  52082. * 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.
  52083. */
  52084. lensSize: number;
  52085. /**
  52086. * Creates a new instance DepthOfFieldEffect
  52087. * @param scene The scene the effect belongs to.
  52088. * @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.
  52089. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52090. * @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)
  52091. */
  52092. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52093. /**
  52094. * 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.
  52095. */
  52096. depthTexture: RenderTargetTexture;
  52097. /**
  52098. * Disposes each of the internal effects for a given camera.
  52099. * @param camera The camera to dispose the effect on.
  52100. */
  52101. disposeEffects(camera: Camera): void;
  52102. /**
  52103. * @hidden Internal
  52104. */
  52105. _updateEffects(): void;
  52106. /**
  52107. * Internal
  52108. * @returns if all the contained post processes are ready.
  52109. * @hidden
  52110. */
  52111. _isReady(): boolean;
  52112. }
  52113. }
  52114. declare module "babylonjs/Shaders/displayPass.fragment" {
  52115. /** @hidden */
  52116. export var displayPassPixelShader: {
  52117. name: string;
  52118. shader: string;
  52119. };
  52120. }
  52121. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52122. import { Nullable } from "babylonjs/types";
  52123. import { Camera } from "babylonjs/Cameras/camera";
  52124. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52125. import { Engine } from "babylonjs/Engines/engine";
  52126. import "babylonjs/Shaders/displayPass.fragment";
  52127. /**
  52128. * DisplayPassPostProcess which produces an output the same as it's input
  52129. */
  52130. export class DisplayPassPostProcess extends PostProcess {
  52131. /**
  52132. * Creates the DisplayPassPostProcess
  52133. * @param name The name of the effect.
  52134. * @param options The required width/height ratio to downsize to before computing the render pass.
  52135. * @param camera The camera to apply the render pass to.
  52136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52137. * @param engine The engine which the post process will be applied. (default: current engine)
  52138. * @param reusable If the post process can be reused on the same frame. (default: false)
  52139. */
  52140. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52141. }
  52142. }
  52143. declare module "babylonjs/Shaders/filter.fragment" {
  52144. /** @hidden */
  52145. export var filterPixelShader: {
  52146. name: string;
  52147. shader: string;
  52148. };
  52149. }
  52150. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52151. import { Nullable } from "babylonjs/types";
  52152. import { Matrix } from "babylonjs/Maths/math";
  52153. import { Camera } from "babylonjs/Cameras/camera";
  52154. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52155. import { Engine } from "babylonjs/Engines/engine";
  52156. import "babylonjs/Shaders/filter.fragment";
  52157. /**
  52158. * Applies a kernel filter to the image
  52159. */
  52160. export class FilterPostProcess extends PostProcess {
  52161. /** The matrix to be applied to the image */
  52162. kernelMatrix: Matrix;
  52163. /**
  52164. *
  52165. * @param name The name of the effect.
  52166. * @param kernelMatrix The matrix to be applied to the image
  52167. * @param options The required width/height ratio to downsize to before computing the render pass.
  52168. * @param camera The camera to apply the render pass to.
  52169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52170. * @param engine The engine which the post process will be applied. (default: current engine)
  52171. * @param reusable If the post process can be reused on the same frame. (default: false)
  52172. */
  52173. constructor(name: string,
  52174. /** The matrix to be applied to the image */
  52175. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52176. }
  52177. }
  52178. declare module "babylonjs/Shaders/fxaa.fragment" {
  52179. /** @hidden */
  52180. export var fxaaPixelShader: {
  52181. name: string;
  52182. shader: string;
  52183. };
  52184. }
  52185. declare module "babylonjs/Shaders/fxaa.vertex" {
  52186. /** @hidden */
  52187. export var fxaaVertexShader: {
  52188. name: string;
  52189. shader: string;
  52190. };
  52191. }
  52192. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52193. import { Nullable } from "babylonjs/types";
  52194. import { Camera } from "babylonjs/Cameras/camera";
  52195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52196. import { Engine } from "babylonjs/Engines/engine";
  52197. import "babylonjs/Shaders/fxaa.fragment";
  52198. import "babylonjs/Shaders/fxaa.vertex";
  52199. /**
  52200. * Fxaa post process
  52201. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52202. */
  52203. export class FxaaPostProcess extends PostProcess {
  52204. /** @hidden */
  52205. texelWidth: number;
  52206. /** @hidden */
  52207. texelHeight: number;
  52208. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52209. private _getDefines;
  52210. }
  52211. }
  52212. declare module "babylonjs/Shaders/grain.fragment" {
  52213. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52214. /** @hidden */
  52215. export var grainPixelShader: {
  52216. name: string;
  52217. shader: string;
  52218. };
  52219. }
  52220. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52221. import { Nullable } from "babylonjs/types";
  52222. import { Camera } from "babylonjs/Cameras/camera";
  52223. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52224. import { Engine } from "babylonjs/Engines/engine";
  52225. import "babylonjs/Shaders/grain.fragment";
  52226. /**
  52227. * The GrainPostProcess adds noise to the image at mid luminance levels
  52228. */
  52229. export class GrainPostProcess extends PostProcess {
  52230. /**
  52231. * The intensity of the grain added (default: 30)
  52232. */
  52233. intensity: number;
  52234. /**
  52235. * If the grain should be randomized on every frame
  52236. */
  52237. animated: boolean;
  52238. /**
  52239. * Creates a new instance of @see GrainPostProcess
  52240. * @param name The name of the effect.
  52241. * @param options The required width/height ratio to downsize to before computing the render pass.
  52242. * @param camera The camera to apply the render pass to.
  52243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52244. * @param engine The engine which the post process will be applied. (default: current engine)
  52245. * @param reusable If the post process can be reused on the same frame. (default: false)
  52246. * @param textureType Type of textures used when performing the post process. (default: 0)
  52247. * @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)
  52248. */
  52249. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52250. }
  52251. }
  52252. declare module "babylonjs/Shaders/highlights.fragment" {
  52253. /** @hidden */
  52254. export var highlightsPixelShader: {
  52255. name: string;
  52256. shader: string;
  52257. };
  52258. }
  52259. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52260. import { Nullable } from "babylonjs/types";
  52261. import { Camera } from "babylonjs/Cameras/camera";
  52262. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52263. import { Engine } from "babylonjs/Engines/engine";
  52264. import "babylonjs/Shaders/highlights.fragment";
  52265. /**
  52266. * Extracts highlights from the image
  52267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52268. */
  52269. export class HighlightsPostProcess extends PostProcess {
  52270. /**
  52271. * Extracts highlights from the image
  52272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52273. * @param name The name of the effect.
  52274. * @param options The required width/height ratio to downsize to before computing the render pass.
  52275. * @param camera The camera to apply the render pass to.
  52276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52277. * @param engine The engine which the post process will be applied. (default: current engine)
  52278. * @param reusable If the post process can be reused on the same frame. (default: false)
  52279. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52280. */
  52281. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52282. }
  52283. }
  52284. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52285. /** @hidden */
  52286. export var mrtFragmentDeclaration: {
  52287. name: string;
  52288. shader: string;
  52289. };
  52290. }
  52291. declare module "babylonjs/Shaders/geometry.fragment" {
  52292. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52293. /** @hidden */
  52294. export var geometryPixelShader: {
  52295. name: string;
  52296. shader: string;
  52297. };
  52298. }
  52299. declare module "babylonjs/Shaders/geometry.vertex" {
  52300. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52301. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52302. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52303. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52304. /** @hidden */
  52305. export var geometryVertexShader: {
  52306. name: string;
  52307. shader: string;
  52308. };
  52309. }
  52310. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52311. import { Matrix } from "babylonjs/Maths/math";
  52312. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52313. import { Mesh } from "babylonjs/Meshes/mesh";
  52314. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52315. import { Effect } from "babylonjs/Materials/effect";
  52316. import { Scene } from "babylonjs/scene";
  52317. import "babylonjs/Shaders/geometry.fragment";
  52318. import "babylonjs/Shaders/geometry.vertex";
  52319. /**
  52320. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52321. */
  52322. export class GeometryBufferRenderer {
  52323. /**
  52324. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52325. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52326. */
  52327. static readonly POSITION_TEXTURE_TYPE: number;
  52328. /**
  52329. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52330. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52331. */
  52332. static readonly VELOCITY_TEXTURE_TYPE: number;
  52333. /**
  52334. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52335. * in order to compute objects velocities when enableVelocity is set to "true"
  52336. * @hidden
  52337. */
  52338. _previousTransformationMatrices: {
  52339. [index: number]: Matrix;
  52340. };
  52341. private _scene;
  52342. private _multiRenderTarget;
  52343. private _ratio;
  52344. private _enablePosition;
  52345. private _enableVelocity;
  52346. private _positionIndex;
  52347. private _velocityIndex;
  52348. protected _effect: Effect;
  52349. protected _cachedDefines: string;
  52350. /**
  52351. * Set the render list (meshes to be rendered) used in the G buffer.
  52352. */
  52353. renderList: Mesh[];
  52354. /**
  52355. * Gets wether or not G buffer are supported by the running hardware.
  52356. * This requires draw buffer supports
  52357. */
  52358. readonly isSupported: boolean;
  52359. /**
  52360. * Returns the index of the given texture type in the G-Buffer textures array
  52361. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52362. * @returns the index of the given texture type in the G-Buffer textures array
  52363. */
  52364. getTextureIndex(textureType: number): number;
  52365. /**
  52366. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52367. */
  52368. /**
  52369. * Sets whether or not objects positions are enabled for the G buffer.
  52370. */
  52371. enablePosition: boolean;
  52372. /**
  52373. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52374. */
  52375. /**
  52376. * Sets wether or not objects velocities are enabled for the G buffer.
  52377. */
  52378. enableVelocity: boolean;
  52379. /**
  52380. * Gets the scene associated with the buffer.
  52381. */
  52382. readonly scene: Scene;
  52383. /**
  52384. * Gets the ratio used by the buffer during its creation.
  52385. * How big is the buffer related to the main canvas.
  52386. */
  52387. readonly ratio: number;
  52388. /** @hidden */
  52389. static _SceneComponentInitialization: (scene: Scene) => void;
  52390. /**
  52391. * Creates a new G Buffer for the scene
  52392. * @param scene The scene the buffer belongs to
  52393. * @param ratio How big is the buffer related to the main canvas.
  52394. */
  52395. constructor(scene: Scene, ratio?: number);
  52396. /**
  52397. * Checks wether everything is ready to render a submesh to the G buffer.
  52398. * @param subMesh the submesh to check readiness for
  52399. * @param useInstances is the mesh drawn using instance or not
  52400. * @returns true if ready otherwise false
  52401. */
  52402. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52403. /**
  52404. * Gets the current underlying G Buffer.
  52405. * @returns the buffer
  52406. */
  52407. getGBuffer(): MultiRenderTarget;
  52408. /**
  52409. * Gets the number of samples used to render the buffer (anti aliasing).
  52410. */
  52411. /**
  52412. * Sets the number of samples used to render the buffer (anti aliasing).
  52413. */
  52414. samples: number;
  52415. /**
  52416. * Disposes the renderer and frees up associated resources.
  52417. */
  52418. dispose(): void;
  52419. protected _createRenderTargets(): void;
  52420. }
  52421. }
  52422. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52423. /** @hidden */
  52424. export var motionBlurPixelShader: {
  52425. name: string;
  52426. shader: string;
  52427. };
  52428. }
  52429. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52430. import { Nullable } from "babylonjs/types";
  52431. import { Camera } from "babylonjs/Cameras/camera";
  52432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52433. import { Scene } from "babylonjs/scene";
  52434. import "babylonjs/Shaders/motionBlur.fragment";
  52435. import { Engine } from "babylonjs/Engines/engine";
  52436. /**
  52437. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52438. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52439. * As an example, all you have to do is to create the post-process:
  52440. * var mb = new BABYLON.MotionBlurPostProcess(
  52441. * 'mb', // The name of the effect.
  52442. * scene, // The scene containing the objects to blur according to their velocity.
  52443. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52444. * camera // The camera to apply the render pass to.
  52445. * );
  52446. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52447. */
  52448. export class MotionBlurPostProcess extends PostProcess {
  52449. /**
  52450. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52451. */
  52452. motionStrength: number;
  52453. /**
  52454. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52455. */
  52456. /**
  52457. * Sets the number of iterations to be used for motion blur quality
  52458. */
  52459. motionBlurSamples: number;
  52460. private _motionBlurSamples;
  52461. private _geometryBufferRenderer;
  52462. /**
  52463. * Creates a new instance MotionBlurPostProcess
  52464. * @param name The name of the effect.
  52465. * @param scene The scene containing the objects to blur according to their velocity.
  52466. * @param options The required width/height ratio to downsize to before computing the render pass.
  52467. * @param camera The camera to apply the render pass to.
  52468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52469. * @param engine The engine which the post process will be applied. (default: current engine)
  52470. * @param reusable If the post process can be reused on the same frame. (default: false)
  52471. * @param textureType Type of textures used when performing the post process. (default: 0)
  52472. * @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)
  52473. */
  52474. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52475. /**
  52476. * Disposes the post process.
  52477. * @param camera The camera to dispose the post process on.
  52478. */
  52479. dispose(camera?: Camera): void;
  52480. }
  52481. }
  52482. declare module "babylonjs/Shaders/refraction.fragment" {
  52483. /** @hidden */
  52484. export var refractionPixelShader: {
  52485. name: string;
  52486. shader: string;
  52487. };
  52488. }
  52489. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52490. import { Color3 } from "babylonjs/Maths/math";
  52491. import { Camera } from "babylonjs/Cameras/camera";
  52492. import { Texture } from "babylonjs/Materials/Textures/texture";
  52493. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52494. import { Engine } from "babylonjs/Engines/engine";
  52495. import "babylonjs/Shaders/refraction.fragment";
  52496. /**
  52497. * Post process which applies a refractin texture
  52498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52499. */
  52500. export class RefractionPostProcess extends PostProcess {
  52501. /** the base color of the refraction (used to taint the rendering) */
  52502. color: Color3;
  52503. /** simulated refraction depth */
  52504. depth: number;
  52505. /** the coefficient of the base color (0 to remove base color tainting) */
  52506. colorLevel: number;
  52507. private _refTexture;
  52508. private _ownRefractionTexture;
  52509. /**
  52510. * Gets or sets the refraction texture
  52511. * Please note that you are responsible for disposing the texture if you set it manually
  52512. */
  52513. refractionTexture: Texture;
  52514. /**
  52515. * Initializes the RefractionPostProcess
  52516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52517. * @param name The name of the effect.
  52518. * @param refractionTextureUrl Url of the refraction texture to use
  52519. * @param color the base color of the refraction (used to taint the rendering)
  52520. * @param depth simulated refraction depth
  52521. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52522. * @param camera The camera to apply the render pass to.
  52523. * @param options The required width/height ratio to downsize to before computing the render pass.
  52524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52525. * @param engine The engine which the post process will be applied. (default: current engine)
  52526. * @param reusable If the post process can be reused on the same frame. (default: false)
  52527. */
  52528. constructor(name: string, refractionTextureUrl: string,
  52529. /** the base color of the refraction (used to taint the rendering) */
  52530. color: Color3,
  52531. /** simulated refraction depth */
  52532. depth: number,
  52533. /** the coefficient of the base color (0 to remove base color tainting) */
  52534. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52535. /**
  52536. * Disposes of the post process
  52537. * @param camera Camera to dispose post process on
  52538. */
  52539. dispose(camera: Camera): void;
  52540. }
  52541. }
  52542. declare module "babylonjs/Shaders/sharpen.fragment" {
  52543. /** @hidden */
  52544. export var sharpenPixelShader: {
  52545. name: string;
  52546. shader: string;
  52547. };
  52548. }
  52549. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52550. import { Nullable } from "babylonjs/types";
  52551. import { Camera } from "babylonjs/Cameras/camera";
  52552. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52553. import "babylonjs/Shaders/sharpen.fragment";
  52554. import { Engine } from "babylonjs/Engines/engine";
  52555. /**
  52556. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52557. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52558. */
  52559. export class SharpenPostProcess extends PostProcess {
  52560. /**
  52561. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52562. */
  52563. colorAmount: number;
  52564. /**
  52565. * How much sharpness should be applied (default: 0.3)
  52566. */
  52567. edgeAmount: number;
  52568. /**
  52569. * Creates a new instance ConvolutionPostProcess
  52570. * @param name The name of the effect.
  52571. * @param options The required width/height ratio to downsize to before computing the render pass.
  52572. * @param camera The camera to apply the render pass to.
  52573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52574. * @param engine The engine which the post process will be applied. (default: current engine)
  52575. * @param reusable If the post process can be reused on the same frame. (default: false)
  52576. * @param textureType Type of textures used when performing the post process. (default: 0)
  52577. * @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)
  52578. */
  52579. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52580. }
  52581. }
  52582. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52583. import { Nullable } from "babylonjs/types";
  52584. import { Camera } from "babylonjs/Cameras/camera";
  52585. import { Engine } from "babylonjs/Engines/engine";
  52586. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52587. /**
  52588. * PostProcessRenderPipeline
  52589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52590. */
  52591. export class PostProcessRenderPipeline {
  52592. private engine;
  52593. private _renderEffects;
  52594. private _renderEffectsForIsolatedPass;
  52595. /**
  52596. * @hidden
  52597. */
  52598. protected _cameras: Camera[];
  52599. /** @hidden */
  52600. _name: string;
  52601. /**
  52602. * Initializes a PostProcessRenderPipeline
  52603. * @param engine engine to add the pipeline to
  52604. * @param name name of the pipeline
  52605. */
  52606. constructor(engine: Engine, name: string);
  52607. /**
  52608. * "PostProcessRenderPipeline"
  52609. * @returns "PostProcessRenderPipeline"
  52610. */
  52611. getClassName(): string;
  52612. /**
  52613. * If all the render effects in the pipeline are support
  52614. */
  52615. readonly isSupported: boolean;
  52616. /**
  52617. * Adds an effect to the pipeline
  52618. * @param renderEffect the effect to add
  52619. */
  52620. addEffect(renderEffect: PostProcessRenderEffect): void;
  52621. /** @hidden */
  52622. _rebuild(): void;
  52623. /** @hidden */
  52624. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52625. /** @hidden */
  52626. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52627. /** @hidden */
  52628. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52629. /** @hidden */
  52630. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52631. /** @hidden */
  52632. _attachCameras(cameras: Camera, unique: boolean): void;
  52633. /** @hidden */
  52634. _attachCameras(cameras: Camera[], unique: boolean): void;
  52635. /** @hidden */
  52636. _detachCameras(cameras: Camera): void;
  52637. /** @hidden */
  52638. _detachCameras(cameras: Nullable<Camera[]>): void;
  52639. /** @hidden */
  52640. _update(): void;
  52641. /** @hidden */
  52642. _reset(): void;
  52643. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52644. /**
  52645. * Disposes of the pipeline
  52646. */
  52647. dispose(): void;
  52648. }
  52649. }
  52650. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52651. import { IAnimatable } from "babylonjs/Misc/tools";
  52652. import { Camera } from "babylonjs/Cameras/camera";
  52653. import { IDisposable } from "babylonjs/scene";
  52654. import { Scene } from "babylonjs/scene";
  52655. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52656. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52657. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52658. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52659. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52660. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52661. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52662. import { Animation } from "babylonjs/Animations/animation";
  52663. /**
  52664. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52665. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52666. */
  52667. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52668. private _scene;
  52669. private _camerasToBeAttached;
  52670. /**
  52671. * ID of the sharpen post process,
  52672. */
  52673. private readonly SharpenPostProcessId;
  52674. /**
  52675. * @ignore
  52676. * ID of the image processing post process;
  52677. */
  52678. readonly ImageProcessingPostProcessId: string;
  52679. /**
  52680. * @ignore
  52681. * ID of the Fast Approximate Anti-Aliasing post process;
  52682. */
  52683. readonly FxaaPostProcessId: string;
  52684. /**
  52685. * ID of the chromatic aberration post process,
  52686. */
  52687. private readonly ChromaticAberrationPostProcessId;
  52688. /**
  52689. * ID of the grain post process
  52690. */
  52691. private readonly GrainPostProcessId;
  52692. /**
  52693. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52694. */
  52695. sharpen: SharpenPostProcess;
  52696. private _sharpenEffect;
  52697. private bloom;
  52698. /**
  52699. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52700. */
  52701. depthOfField: DepthOfFieldEffect;
  52702. /**
  52703. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52704. */
  52705. fxaa: FxaaPostProcess;
  52706. /**
  52707. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52708. */
  52709. imageProcessing: ImageProcessingPostProcess;
  52710. /**
  52711. * Chromatic aberration post process which will shift rgb colors in the image
  52712. */
  52713. chromaticAberration: ChromaticAberrationPostProcess;
  52714. private _chromaticAberrationEffect;
  52715. /**
  52716. * Grain post process which add noise to the image
  52717. */
  52718. grain: GrainPostProcess;
  52719. private _grainEffect;
  52720. /**
  52721. * Glow post process which adds a glow to emmisive areas of the image
  52722. */
  52723. private _glowLayer;
  52724. /**
  52725. * Animations which can be used to tweak settings over a period of time
  52726. */
  52727. animations: Animation[];
  52728. private _imageProcessingConfigurationObserver;
  52729. private _sharpenEnabled;
  52730. private _bloomEnabled;
  52731. private _depthOfFieldEnabled;
  52732. private _depthOfFieldBlurLevel;
  52733. private _fxaaEnabled;
  52734. private _imageProcessingEnabled;
  52735. private _defaultPipelineTextureType;
  52736. private _bloomScale;
  52737. private _chromaticAberrationEnabled;
  52738. private _grainEnabled;
  52739. private _buildAllowed;
  52740. /**
  52741. * Enable or disable the sharpen process from the pipeline
  52742. */
  52743. sharpenEnabled: boolean;
  52744. private _resizeObserver;
  52745. private _hardwareScaleLevel;
  52746. private _bloomKernel;
  52747. /**
  52748. * Specifies the size of the bloom blur kernel, relative to the final output size
  52749. */
  52750. bloomKernel: number;
  52751. /**
  52752. * Specifies the weight of the bloom in the final rendering
  52753. */
  52754. private _bloomWeight;
  52755. /**
  52756. * Specifies the luma threshold for the area that will be blurred by the bloom
  52757. */
  52758. private _bloomThreshold;
  52759. private _hdr;
  52760. /**
  52761. * The strength of the bloom.
  52762. */
  52763. bloomWeight: number;
  52764. /**
  52765. * The strength of the bloom.
  52766. */
  52767. bloomThreshold: number;
  52768. /**
  52769. * The scale of the bloom, lower value will provide better performance.
  52770. */
  52771. bloomScale: number;
  52772. /**
  52773. * Enable or disable the bloom from the pipeline
  52774. */
  52775. bloomEnabled: boolean;
  52776. private _rebuildBloom;
  52777. /**
  52778. * If the depth of field is enabled.
  52779. */
  52780. depthOfFieldEnabled: boolean;
  52781. /**
  52782. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52783. */
  52784. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52785. /**
  52786. * If the anti aliasing is enabled.
  52787. */
  52788. fxaaEnabled: boolean;
  52789. private _samples;
  52790. /**
  52791. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52792. */
  52793. samples: number;
  52794. /**
  52795. * If image processing is enabled.
  52796. */
  52797. imageProcessingEnabled: boolean;
  52798. /**
  52799. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52800. */
  52801. glowLayerEnabled: boolean;
  52802. /**
  52803. * Enable or disable the chromaticAberration process from the pipeline
  52804. */
  52805. chromaticAberrationEnabled: boolean;
  52806. /**
  52807. * Enable or disable the grain process from the pipeline
  52808. */
  52809. grainEnabled: boolean;
  52810. /**
  52811. * @constructor
  52812. * @param name - The rendering pipeline name (default: "")
  52813. * @param hdr - If high dynamic range textures should be used (default: true)
  52814. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52815. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52816. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52817. */
  52818. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52819. /**
  52820. * Force the compilation of the entire pipeline.
  52821. */
  52822. prepare(): void;
  52823. private _hasCleared;
  52824. private _prevPostProcess;
  52825. private _prevPrevPostProcess;
  52826. private _setAutoClearAndTextureSharing;
  52827. private _depthOfFieldSceneObserver;
  52828. private _buildPipeline;
  52829. private _disposePostProcesses;
  52830. /**
  52831. * Adds a camera to the pipeline
  52832. * @param camera the camera to be added
  52833. */
  52834. addCamera(camera: Camera): void;
  52835. /**
  52836. * Removes a camera from the pipeline
  52837. * @param camera the camera to remove
  52838. */
  52839. removeCamera(camera: Camera): void;
  52840. /**
  52841. * Dispose of the pipeline and stop all post processes
  52842. */
  52843. dispose(): void;
  52844. /**
  52845. * Serialize the rendering pipeline (Used when exporting)
  52846. * @returns the serialized object
  52847. */
  52848. serialize(): any;
  52849. /**
  52850. * Parse the serialized pipeline
  52851. * @param source Source pipeline.
  52852. * @param scene The scene to load the pipeline to.
  52853. * @param rootUrl The URL of the serialized pipeline.
  52854. * @returns An instantiated pipeline from the serialized object.
  52855. */
  52856. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52857. }
  52858. }
  52859. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52860. /** @hidden */
  52861. export var lensHighlightsPixelShader: {
  52862. name: string;
  52863. shader: string;
  52864. };
  52865. }
  52866. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52867. /** @hidden */
  52868. export var depthOfFieldPixelShader: {
  52869. name: string;
  52870. shader: string;
  52871. };
  52872. }
  52873. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52874. import { Camera } from "babylonjs/Cameras/camera";
  52875. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52876. import { Scene } from "babylonjs/scene";
  52877. import "babylonjs/Shaders/chromaticAberration.fragment";
  52878. import "babylonjs/Shaders/lensHighlights.fragment";
  52879. import "babylonjs/Shaders/depthOfField.fragment";
  52880. /**
  52881. * BABYLON.JS Chromatic Aberration GLSL Shader
  52882. * Author: Olivier Guyot
  52883. * Separates very slightly R, G and B colors on the edges of the screen
  52884. * Inspired by Francois Tarlier & Martins Upitis
  52885. */
  52886. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52887. /**
  52888. * @ignore
  52889. * The chromatic aberration PostProcess id in the pipeline
  52890. */
  52891. LensChromaticAberrationEffect: string;
  52892. /**
  52893. * @ignore
  52894. * The highlights enhancing PostProcess id in the pipeline
  52895. */
  52896. HighlightsEnhancingEffect: string;
  52897. /**
  52898. * @ignore
  52899. * The depth-of-field PostProcess id in the pipeline
  52900. */
  52901. LensDepthOfFieldEffect: string;
  52902. private _scene;
  52903. private _depthTexture;
  52904. private _grainTexture;
  52905. private _chromaticAberrationPostProcess;
  52906. private _highlightsPostProcess;
  52907. private _depthOfFieldPostProcess;
  52908. private _edgeBlur;
  52909. private _grainAmount;
  52910. private _chromaticAberration;
  52911. private _distortion;
  52912. private _highlightsGain;
  52913. private _highlightsThreshold;
  52914. private _dofDistance;
  52915. private _dofAperture;
  52916. private _dofDarken;
  52917. private _dofPentagon;
  52918. private _blurNoise;
  52919. /**
  52920. * @constructor
  52921. *
  52922. * Effect parameters are as follow:
  52923. * {
  52924. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52925. * edge_blur: number; // from 0 to x (1 for realism)
  52926. * distortion: number; // from 0 to x (1 for realism)
  52927. * grain_amount: number; // from 0 to 1
  52928. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52929. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52930. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52931. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52932. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52933. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52934. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52935. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52936. * }
  52937. * Note: if an effect parameter is unset, effect is disabled
  52938. *
  52939. * @param name The rendering pipeline name
  52940. * @param parameters - An object containing all parameters (see above)
  52941. * @param scene The scene linked to this pipeline
  52942. * @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)
  52943. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52944. */
  52945. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52946. /**
  52947. * Sets the amount of blur at the edges
  52948. * @param amount blur amount
  52949. */
  52950. setEdgeBlur(amount: number): void;
  52951. /**
  52952. * Sets edge blur to 0
  52953. */
  52954. disableEdgeBlur(): void;
  52955. /**
  52956. * Sets the amout of grain
  52957. * @param amount Amount of grain
  52958. */
  52959. setGrainAmount(amount: number): void;
  52960. /**
  52961. * Set grain amount to 0
  52962. */
  52963. disableGrain(): void;
  52964. /**
  52965. * Sets the chromatic aberration amount
  52966. * @param amount amount of chromatic aberration
  52967. */
  52968. setChromaticAberration(amount: number): void;
  52969. /**
  52970. * Sets chromatic aberration amount to 0
  52971. */
  52972. disableChromaticAberration(): void;
  52973. /**
  52974. * Sets the EdgeDistortion amount
  52975. * @param amount amount of EdgeDistortion
  52976. */
  52977. setEdgeDistortion(amount: number): void;
  52978. /**
  52979. * Sets edge distortion to 0
  52980. */
  52981. disableEdgeDistortion(): void;
  52982. /**
  52983. * Sets the FocusDistance amount
  52984. * @param amount amount of FocusDistance
  52985. */
  52986. setFocusDistance(amount: number): void;
  52987. /**
  52988. * Disables depth of field
  52989. */
  52990. disableDepthOfField(): void;
  52991. /**
  52992. * Sets the Aperture amount
  52993. * @param amount amount of Aperture
  52994. */
  52995. setAperture(amount: number): void;
  52996. /**
  52997. * Sets the DarkenOutOfFocus amount
  52998. * @param amount amount of DarkenOutOfFocus
  52999. */
  53000. setDarkenOutOfFocus(amount: number): void;
  53001. /**
  53002. * Creates a pentagon bokeh effect
  53003. */
  53004. enablePentagonBokeh(): void;
  53005. /**
  53006. * Disables the pentagon bokeh effect
  53007. */
  53008. disablePentagonBokeh(): void;
  53009. /**
  53010. * Enables noise blur
  53011. */
  53012. enableNoiseBlur(): void;
  53013. /**
  53014. * Disables noise blur
  53015. */
  53016. disableNoiseBlur(): void;
  53017. /**
  53018. * Sets the HighlightsGain amount
  53019. * @param amount amount of HighlightsGain
  53020. */
  53021. setHighlightsGain(amount: number): void;
  53022. /**
  53023. * Sets the HighlightsThreshold amount
  53024. * @param amount amount of HighlightsThreshold
  53025. */
  53026. setHighlightsThreshold(amount: number): void;
  53027. /**
  53028. * Disables highlights
  53029. */
  53030. disableHighlights(): void;
  53031. /**
  53032. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53033. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53034. */
  53035. dispose(disableDepthRender?: boolean): void;
  53036. private _createChromaticAberrationPostProcess;
  53037. private _createHighlightsPostProcess;
  53038. private _createDepthOfFieldPostProcess;
  53039. private _createGrainTexture;
  53040. }
  53041. }
  53042. declare module "babylonjs/Shaders/ssao2.fragment" {
  53043. /** @hidden */
  53044. export var ssao2PixelShader: {
  53045. name: string;
  53046. shader: string;
  53047. };
  53048. }
  53049. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53050. /** @hidden */
  53051. export var ssaoCombinePixelShader: {
  53052. name: string;
  53053. shader: string;
  53054. };
  53055. }
  53056. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53057. import { Camera } from "babylonjs/Cameras/camera";
  53058. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53059. import { Scene } from "babylonjs/scene";
  53060. import "babylonjs/Shaders/ssao2.fragment";
  53061. import "babylonjs/Shaders/ssaoCombine.fragment";
  53062. /**
  53063. * Render pipeline to produce ssao effect
  53064. */
  53065. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53066. /**
  53067. * @ignore
  53068. * The PassPostProcess id in the pipeline that contains the original scene color
  53069. */
  53070. SSAOOriginalSceneColorEffect: string;
  53071. /**
  53072. * @ignore
  53073. * The SSAO PostProcess id in the pipeline
  53074. */
  53075. SSAORenderEffect: string;
  53076. /**
  53077. * @ignore
  53078. * The horizontal blur PostProcess id in the pipeline
  53079. */
  53080. SSAOBlurHRenderEffect: string;
  53081. /**
  53082. * @ignore
  53083. * The vertical blur PostProcess id in the pipeline
  53084. */
  53085. SSAOBlurVRenderEffect: string;
  53086. /**
  53087. * @ignore
  53088. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53089. */
  53090. SSAOCombineRenderEffect: string;
  53091. /**
  53092. * The output strength of the SSAO post-process. Default value is 1.0.
  53093. */
  53094. totalStrength: number;
  53095. /**
  53096. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53097. */
  53098. maxZ: number;
  53099. /**
  53100. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53101. */
  53102. minZAspect: number;
  53103. private _samples;
  53104. /**
  53105. * Number of samples used for the SSAO calculations. Default value is 8
  53106. */
  53107. samples: number;
  53108. private _textureSamples;
  53109. /**
  53110. * Number of samples to use for antialiasing
  53111. */
  53112. textureSamples: number;
  53113. /**
  53114. * Ratio object used for SSAO ratio and blur ratio
  53115. */
  53116. private _ratio;
  53117. /**
  53118. * Dynamically generated sphere sampler.
  53119. */
  53120. private _sampleSphere;
  53121. /**
  53122. * Blur filter offsets
  53123. */
  53124. private _samplerOffsets;
  53125. private _expensiveBlur;
  53126. /**
  53127. * If bilateral blur should be used
  53128. */
  53129. expensiveBlur: boolean;
  53130. /**
  53131. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53132. */
  53133. radius: number;
  53134. /**
  53135. * The base color of the SSAO post-process
  53136. * The final result is "base + ssao" between [0, 1]
  53137. */
  53138. base: number;
  53139. /**
  53140. * Support test.
  53141. */
  53142. static readonly IsSupported: boolean;
  53143. private _scene;
  53144. private _depthTexture;
  53145. private _normalTexture;
  53146. private _randomTexture;
  53147. private _originalColorPostProcess;
  53148. private _ssaoPostProcess;
  53149. private _blurHPostProcess;
  53150. private _blurVPostProcess;
  53151. private _ssaoCombinePostProcess;
  53152. private _firstUpdate;
  53153. /**
  53154. * @constructor
  53155. * @param name The rendering pipeline name
  53156. * @param scene The scene linked to this pipeline
  53157. * @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 }
  53158. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53159. */
  53160. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53161. /**
  53162. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53163. */
  53164. dispose(disableGeometryBufferRenderer?: boolean): void;
  53165. private _createBlurPostProcess;
  53166. /** @hidden */
  53167. _rebuild(): void;
  53168. private _bits;
  53169. private _radicalInverse_VdC;
  53170. private _hammersley;
  53171. private _hemisphereSample_uniform;
  53172. private _generateHemisphere;
  53173. private _createSSAOPostProcess;
  53174. private _createSSAOCombinePostProcess;
  53175. private _createRandomTexture;
  53176. /**
  53177. * Serialize the rendering pipeline (Used when exporting)
  53178. * @returns the serialized object
  53179. */
  53180. serialize(): any;
  53181. /**
  53182. * Parse the serialized pipeline
  53183. * @param source Source pipeline.
  53184. * @param scene The scene to load the pipeline to.
  53185. * @param rootUrl The URL of the serialized pipeline.
  53186. * @returns An instantiated pipeline from the serialized object.
  53187. */
  53188. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53189. }
  53190. }
  53191. declare module "babylonjs/Shaders/ssao.fragment" {
  53192. /** @hidden */
  53193. export var ssaoPixelShader: {
  53194. name: string;
  53195. shader: string;
  53196. };
  53197. }
  53198. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53199. import { Camera } from "babylonjs/Cameras/camera";
  53200. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53201. import { Scene } from "babylonjs/scene";
  53202. import "babylonjs/Shaders/ssao.fragment";
  53203. import "babylonjs/Shaders/ssaoCombine.fragment";
  53204. /**
  53205. * Render pipeline to produce ssao effect
  53206. */
  53207. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53208. /**
  53209. * @ignore
  53210. * The PassPostProcess id in the pipeline that contains the original scene color
  53211. */
  53212. SSAOOriginalSceneColorEffect: string;
  53213. /**
  53214. * @ignore
  53215. * The SSAO PostProcess id in the pipeline
  53216. */
  53217. SSAORenderEffect: string;
  53218. /**
  53219. * @ignore
  53220. * The horizontal blur PostProcess id in the pipeline
  53221. */
  53222. SSAOBlurHRenderEffect: string;
  53223. /**
  53224. * @ignore
  53225. * The vertical blur PostProcess id in the pipeline
  53226. */
  53227. SSAOBlurVRenderEffect: string;
  53228. /**
  53229. * @ignore
  53230. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53231. */
  53232. SSAOCombineRenderEffect: string;
  53233. /**
  53234. * The output strength of the SSAO post-process. Default value is 1.0.
  53235. */
  53236. totalStrength: number;
  53237. /**
  53238. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53239. */
  53240. radius: number;
  53241. /**
  53242. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53243. * Must not be equal to fallOff and superior to fallOff.
  53244. * Default value is 0.975
  53245. */
  53246. area: number;
  53247. /**
  53248. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53249. * Must not be equal to area and inferior to area.
  53250. * Default value is 0.0
  53251. */
  53252. fallOff: number;
  53253. /**
  53254. * The base color of the SSAO post-process
  53255. * The final result is "base + ssao" between [0, 1]
  53256. */
  53257. base: number;
  53258. private _scene;
  53259. private _depthTexture;
  53260. private _randomTexture;
  53261. private _originalColorPostProcess;
  53262. private _ssaoPostProcess;
  53263. private _blurHPostProcess;
  53264. private _blurVPostProcess;
  53265. private _ssaoCombinePostProcess;
  53266. private _firstUpdate;
  53267. /**
  53268. * @constructor
  53269. * @param name - The rendering pipeline name
  53270. * @param scene - The scene linked to this pipeline
  53271. * @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 }
  53272. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53273. */
  53274. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53275. /**
  53276. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53277. */
  53278. dispose(disableDepthRender?: boolean): void;
  53279. private _createBlurPostProcess;
  53280. /** @hidden */
  53281. _rebuild(): void;
  53282. private _createSSAOPostProcess;
  53283. private _createSSAOCombinePostProcess;
  53284. private _createRandomTexture;
  53285. }
  53286. }
  53287. declare module "babylonjs/Shaders/standard.fragment" {
  53288. /** @hidden */
  53289. export var standardPixelShader: {
  53290. name: string;
  53291. shader: string;
  53292. };
  53293. }
  53294. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53295. import { Nullable } from "babylonjs/types";
  53296. import { IAnimatable } from "babylonjs/Misc/tools";
  53297. import { Camera } from "babylonjs/Cameras/camera";
  53298. import { Texture } from "babylonjs/Materials/Textures/texture";
  53299. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53300. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53301. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53302. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53303. import { IDisposable } from "babylonjs/scene";
  53304. import { SpotLight } from "babylonjs/Lights/spotLight";
  53305. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53306. import { Scene } from "babylonjs/scene";
  53307. import { Animation } from "babylonjs/Animations/animation";
  53308. import "babylonjs/Shaders/standard.fragment";
  53309. /**
  53310. * Standard rendering pipeline
  53311. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53312. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53313. */
  53314. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53315. /**
  53316. * Public members
  53317. */
  53318. /**
  53319. * Post-process which contains the original scene color before the pipeline applies all the effects
  53320. */
  53321. originalPostProcess: Nullable<PostProcess>;
  53322. /**
  53323. * Post-process used to down scale an image x4
  53324. */
  53325. downSampleX4PostProcess: Nullable<PostProcess>;
  53326. /**
  53327. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53328. */
  53329. brightPassPostProcess: Nullable<PostProcess>;
  53330. /**
  53331. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53332. */
  53333. blurHPostProcesses: PostProcess[];
  53334. /**
  53335. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53336. */
  53337. blurVPostProcesses: PostProcess[];
  53338. /**
  53339. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53340. */
  53341. textureAdderPostProcess: Nullable<PostProcess>;
  53342. /**
  53343. * Post-process used to create volumetric lighting effect
  53344. */
  53345. volumetricLightPostProcess: Nullable<PostProcess>;
  53346. /**
  53347. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53348. */
  53349. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53350. /**
  53351. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53352. */
  53353. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53354. /**
  53355. * Post-process used to merge the volumetric light effect and the real scene color
  53356. */
  53357. volumetricLightMergePostProces: Nullable<PostProcess>;
  53358. /**
  53359. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53360. */
  53361. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53362. /**
  53363. * Base post-process used to calculate the average luminance of the final image for HDR
  53364. */
  53365. luminancePostProcess: Nullable<PostProcess>;
  53366. /**
  53367. * Post-processes used to create down sample post-processes in order to get
  53368. * the average luminance of the final image for HDR
  53369. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53370. */
  53371. luminanceDownSamplePostProcesses: PostProcess[];
  53372. /**
  53373. * Post-process used to create a HDR effect (light adaptation)
  53374. */
  53375. hdrPostProcess: Nullable<PostProcess>;
  53376. /**
  53377. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53378. */
  53379. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53380. /**
  53381. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53382. */
  53383. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53384. /**
  53385. * Post-process used to merge the final HDR post-process and the real scene color
  53386. */
  53387. hdrFinalPostProcess: Nullable<PostProcess>;
  53388. /**
  53389. * Post-process used to create a lens flare effect
  53390. */
  53391. lensFlarePostProcess: Nullable<PostProcess>;
  53392. /**
  53393. * Post-process that merges the result of the lens flare post-process and the real scene color
  53394. */
  53395. lensFlareComposePostProcess: Nullable<PostProcess>;
  53396. /**
  53397. * Post-process used to create a motion blur effect
  53398. */
  53399. motionBlurPostProcess: Nullable<PostProcess>;
  53400. /**
  53401. * Post-process used to create a depth of field effect
  53402. */
  53403. depthOfFieldPostProcess: Nullable<PostProcess>;
  53404. /**
  53405. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53406. */
  53407. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53408. /**
  53409. * Represents the brightness threshold in order to configure the illuminated surfaces
  53410. */
  53411. brightThreshold: number;
  53412. /**
  53413. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53414. */
  53415. blurWidth: number;
  53416. /**
  53417. * Sets if the blur for highlighted surfaces must be only horizontal
  53418. */
  53419. horizontalBlur: boolean;
  53420. /**
  53421. * Sets the overall exposure used by the pipeline
  53422. */
  53423. exposure: number;
  53424. /**
  53425. * Texture used typically to simulate "dirty" on camera lens
  53426. */
  53427. lensTexture: Nullable<Texture>;
  53428. /**
  53429. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53430. */
  53431. volumetricLightCoefficient: number;
  53432. /**
  53433. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53434. */
  53435. volumetricLightPower: number;
  53436. /**
  53437. * Used the set the blur intensity to smooth the volumetric lights
  53438. */
  53439. volumetricLightBlurScale: number;
  53440. /**
  53441. * Light (spot or directional) used to generate the volumetric lights rays
  53442. * The source light must have a shadow generate so the pipeline can get its
  53443. * depth map
  53444. */
  53445. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53446. /**
  53447. * For eye adaptation, represents the minimum luminance the eye can see
  53448. */
  53449. hdrMinimumLuminance: number;
  53450. /**
  53451. * For eye adaptation, represents the decrease luminance speed
  53452. */
  53453. hdrDecreaseRate: number;
  53454. /**
  53455. * For eye adaptation, represents the increase luminance speed
  53456. */
  53457. hdrIncreaseRate: number;
  53458. /**
  53459. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53460. */
  53461. lensColorTexture: Nullable<Texture>;
  53462. /**
  53463. * The overall strengh for the lens flare effect
  53464. */
  53465. lensFlareStrength: number;
  53466. /**
  53467. * Dispersion coefficient for lens flare ghosts
  53468. */
  53469. lensFlareGhostDispersal: number;
  53470. /**
  53471. * Main lens flare halo width
  53472. */
  53473. lensFlareHaloWidth: number;
  53474. /**
  53475. * Based on the lens distortion effect, defines how much the lens flare result
  53476. * is distorted
  53477. */
  53478. lensFlareDistortionStrength: number;
  53479. /**
  53480. * Lens star texture must be used to simulate rays on the flares and is available
  53481. * in the documentation
  53482. */
  53483. lensStarTexture: Nullable<Texture>;
  53484. /**
  53485. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53486. * flare effect by taking account of the dirt texture
  53487. */
  53488. lensFlareDirtTexture: Nullable<Texture>;
  53489. /**
  53490. * Represents the focal length for the depth of field effect
  53491. */
  53492. depthOfFieldDistance: number;
  53493. /**
  53494. * Represents the blur intensity for the blurred part of the depth of field effect
  53495. */
  53496. depthOfFieldBlurWidth: number;
  53497. /**
  53498. * For motion blur, defines how much the image is blurred by the movement
  53499. */
  53500. motionStrength: number;
  53501. /**
  53502. * List of animations for the pipeline (IAnimatable implementation)
  53503. */
  53504. animations: Animation[];
  53505. /**
  53506. * Private members
  53507. */
  53508. private _scene;
  53509. private _currentDepthOfFieldSource;
  53510. private _basePostProcess;
  53511. private _hdrCurrentLuminance;
  53512. private _floatTextureType;
  53513. private _ratio;
  53514. private _bloomEnabled;
  53515. private _depthOfFieldEnabled;
  53516. private _vlsEnabled;
  53517. private _lensFlareEnabled;
  53518. private _hdrEnabled;
  53519. private _motionBlurEnabled;
  53520. private _fxaaEnabled;
  53521. private _motionBlurSamples;
  53522. private _volumetricLightStepsCount;
  53523. private _samples;
  53524. /**
  53525. * @ignore
  53526. * Specifies if the bloom pipeline is enabled
  53527. */
  53528. BloomEnabled: boolean;
  53529. /**
  53530. * @ignore
  53531. * Specifies if the depth of field pipeline is enabed
  53532. */
  53533. DepthOfFieldEnabled: boolean;
  53534. /**
  53535. * @ignore
  53536. * Specifies if the lens flare pipeline is enabed
  53537. */
  53538. LensFlareEnabled: boolean;
  53539. /**
  53540. * @ignore
  53541. * Specifies if the HDR pipeline is enabled
  53542. */
  53543. HDREnabled: boolean;
  53544. /**
  53545. * @ignore
  53546. * Specifies if the volumetric lights scattering effect is enabled
  53547. */
  53548. VLSEnabled: boolean;
  53549. /**
  53550. * @ignore
  53551. * Specifies if the motion blur effect is enabled
  53552. */
  53553. MotionBlurEnabled: boolean;
  53554. /**
  53555. * Specifies if anti-aliasing is enabled
  53556. */
  53557. fxaaEnabled: boolean;
  53558. /**
  53559. * Specifies the number of steps used to calculate the volumetric lights
  53560. * Typically in interval [50, 200]
  53561. */
  53562. volumetricLightStepsCount: number;
  53563. /**
  53564. * Specifies the number of samples used for the motion blur effect
  53565. * Typically in interval [16, 64]
  53566. */
  53567. motionBlurSamples: number;
  53568. /**
  53569. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53570. */
  53571. samples: number;
  53572. /**
  53573. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53574. * @constructor
  53575. * @param name The rendering pipeline name
  53576. * @param scene The scene linked to this pipeline
  53577. * @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)
  53578. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53579. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53580. */
  53581. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53582. private _buildPipeline;
  53583. private _createDownSampleX4PostProcess;
  53584. private _createBrightPassPostProcess;
  53585. private _createBlurPostProcesses;
  53586. private _createTextureAdderPostProcess;
  53587. private _createVolumetricLightPostProcess;
  53588. private _createLuminancePostProcesses;
  53589. private _createHdrPostProcess;
  53590. private _createLensFlarePostProcess;
  53591. private _createDepthOfFieldPostProcess;
  53592. private _createMotionBlurPostProcess;
  53593. private _getDepthTexture;
  53594. private _disposePostProcesses;
  53595. /**
  53596. * Dispose of the pipeline and stop all post processes
  53597. */
  53598. dispose(): void;
  53599. /**
  53600. * Serialize the rendering pipeline (Used when exporting)
  53601. * @returns the serialized object
  53602. */
  53603. serialize(): any;
  53604. /**
  53605. * Parse the serialized pipeline
  53606. * @param source Source pipeline.
  53607. * @param scene The scene to load the pipeline to.
  53608. * @param rootUrl The URL of the serialized pipeline.
  53609. * @returns An instantiated pipeline from the serialized object.
  53610. */
  53611. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53612. /**
  53613. * Luminance steps
  53614. */
  53615. static LuminanceSteps: number;
  53616. }
  53617. }
  53618. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53619. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53620. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53621. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53622. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53623. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53624. }
  53625. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53626. import { Camera } from "babylonjs/Cameras/camera";
  53627. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53628. /**
  53629. * PostProcessRenderPipelineManager class
  53630. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53631. */
  53632. export class PostProcessRenderPipelineManager {
  53633. private _renderPipelines;
  53634. /**
  53635. * Initializes a PostProcessRenderPipelineManager
  53636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53637. */
  53638. constructor();
  53639. /**
  53640. * Adds a pipeline to the manager
  53641. * @param renderPipeline The pipeline to add
  53642. */
  53643. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53644. /**
  53645. * Attaches a camera to the pipeline
  53646. * @param renderPipelineName The name of the pipeline to attach to
  53647. * @param cameras the camera to attach
  53648. * @param unique if the camera can be attached multiple times to the pipeline
  53649. */
  53650. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53651. /**
  53652. * Detaches a camera from the pipeline
  53653. * @param renderPipelineName The name of the pipeline to detach from
  53654. * @param cameras the camera to detach
  53655. */
  53656. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53657. /**
  53658. * Enables an effect by name on a pipeline
  53659. * @param renderPipelineName the name of the pipeline to enable the effect in
  53660. * @param renderEffectName the name of the effect to enable
  53661. * @param cameras the cameras that the effect should be enabled on
  53662. */
  53663. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53664. /**
  53665. * Disables an effect by name on a pipeline
  53666. * @param renderPipelineName the name of the pipeline to disable the effect in
  53667. * @param renderEffectName the name of the effect to disable
  53668. * @param cameras the cameras that the effect should be disabled on
  53669. */
  53670. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53671. /**
  53672. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53673. */
  53674. update(): void;
  53675. /** @hidden */
  53676. _rebuild(): void;
  53677. /**
  53678. * Disposes of the manager and pipelines
  53679. */
  53680. dispose(): void;
  53681. }
  53682. }
  53683. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53684. import { ISceneComponent } from "babylonjs/sceneComponent";
  53685. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53686. import { Scene } from "babylonjs/scene";
  53687. module "babylonjs/scene" {
  53688. interface Scene {
  53689. /** @hidden (Backing field) */
  53690. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53691. /**
  53692. * Gets the postprocess render pipeline manager
  53693. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53694. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53695. */
  53696. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53697. }
  53698. }
  53699. /**
  53700. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53701. */
  53702. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53703. /**
  53704. * The component name helpfull to identify the component in the list of scene components.
  53705. */
  53706. readonly name: string;
  53707. /**
  53708. * The scene the component belongs to.
  53709. */
  53710. scene: Scene;
  53711. /**
  53712. * Creates a new instance of the component for the given scene
  53713. * @param scene Defines the scene to register the component in
  53714. */
  53715. constructor(scene: Scene);
  53716. /**
  53717. * Registers the component in a given scene
  53718. */
  53719. register(): void;
  53720. /**
  53721. * Rebuilds the elements related to this component in case of
  53722. * context lost for instance.
  53723. */
  53724. rebuild(): void;
  53725. /**
  53726. * Disposes the component and the associated ressources
  53727. */
  53728. dispose(): void;
  53729. private _gatherRenderTargets;
  53730. }
  53731. }
  53732. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53733. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53734. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53735. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53736. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53737. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53738. }
  53739. declare module "babylonjs/Shaders/tonemap.fragment" {
  53740. /** @hidden */
  53741. export var tonemapPixelShader: {
  53742. name: string;
  53743. shader: string;
  53744. };
  53745. }
  53746. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53747. import { Camera } from "babylonjs/Cameras/camera";
  53748. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53749. import "babylonjs/Shaders/tonemap.fragment";
  53750. import { Engine } from "babylonjs/Engines/engine";
  53751. /** Defines operator used for tonemapping */
  53752. export enum TonemappingOperator {
  53753. /** Hable */
  53754. Hable = 0,
  53755. /** Reinhard */
  53756. Reinhard = 1,
  53757. /** HejiDawson */
  53758. HejiDawson = 2,
  53759. /** Photographic */
  53760. Photographic = 3
  53761. }
  53762. /**
  53763. * Defines a post process to apply tone mapping
  53764. */
  53765. export class TonemapPostProcess extends PostProcess {
  53766. private _operator;
  53767. /** Defines the required exposure adjustement */
  53768. exposureAdjustment: number;
  53769. /**
  53770. * Creates a new TonemapPostProcess
  53771. * @param name defines the name of the postprocess
  53772. * @param _operator defines the operator to use
  53773. * @param exposureAdjustment defines the required exposure adjustement
  53774. * @param camera defines the camera to use (can be null)
  53775. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53776. * @param engine defines the hosting engine (can be ignore if camera is set)
  53777. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53778. */
  53779. constructor(name: string, _operator: TonemappingOperator,
  53780. /** Defines the required exposure adjustement */
  53781. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53782. }
  53783. }
  53784. declare module "babylonjs/Shaders/depth.vertex" {
  53785. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53786. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53787. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53788. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53789. /** @hidden */
  53790. export var depthVertexShader: {
  53791. name: string;
  53792. shader: string;
  53793. };
  53794. }
  53795. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53796. /** @hidden */
  53797. export var volumetricLightScatteringPixelShader: {
  53798. name: string;
  53799. shader: string;
  53800. };
  53801. }
  53802. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53803. /** @hidden */
  53804. export var volumetricLightScatteringPassPixelShader: {
  53805. name: string;
  53806. shader: string;
  53807. };
  53808. }
  53809. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53810. import { Vector3 } from "babylonjs/Maths/math";
  53811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53812. import { Mesh } from "babylonjs/Meshes/mesh";
  53813. import { Camera } from "babylonjs/Cameras/camera";
  53814. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53815. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53816. import { Scene } from "babylonjs/scene";
  53817. import "babylonjs/Meshes/Builders/planeBuilder";
  53818. import "babylonjs/Shaders/depth.vertex";
  53819. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53820. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53821. import { Engine } from "babylonjs/Engines/engine";
  53822. /**
  53823. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53824. */
  53825. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53826. private _volumetricLightScatteringPass;
  53827. private _volumetricLightScatteringRTT;
  53828. private _viewPort;
  53829. private _screenCoordinates;
  53830. private _cachedDefines;
  53831. /**
  53832. * If not undefined, the mesh position is computed from the attached node position
  53833. */
  53834. attachedNode: {
  53835. position: Vector3;
  53836. };
  53837. /**
  53838. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53839. */
  53840. customMeshPosition: Vector3;
  53841. /**
  53842. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53843. */
  53844. useCustomMeshPosition: boolean;
  53845. /**
  53846. * If the post-process should inverse the light scattering direction
  53847. */
  53848. invert: boolean;
  53849. /**
  53850. * The internal mesh used by the post-process
  53851. */
  53852. mesh: Mesh;
  53853. /**
  53854. * @hidden
  53855. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53856. */
  53857. useDiffuseColor: boolean;
  53858. /**
  53859. * Array containing the excluded meshes not rendered in the internal pass
  53860. */
  53861. excludedMeshes: AbstractMesh[];
  53862. /**
  53863. * Controls the overall intensity of the post-process
  53864. */
  53865. exposure: number;
  53866. /**
  53867. * Dissipates each sample's contribution in range [0, 1]
  53868. */
  53869. decay: number;
  53870. /**
  53871. * Controls the overall intensity of each sample
  53872. */
  53873. weight: number;
  53874. /**
  53875. * Controls the density of each sample
  53876. */
  53877. density: number;
  53878. /**
  53879. * @constructor
  53880. * @param name The post-process name
  53881. * @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)
  53882. * @param camera The camera that the post-process will be attached to
  53883. * @param mesh The mesh used to create the light scattering
  53884. * @param samples The post-process quality, default 100
  53885. * @param samplingModeThe post-process filtering mode
  53886. * @param engine The babylon engine
  53887. * @param reusable If the post-process is reusable
  53888. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53889. */
  53890. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53891. /**
  53892. * Returns the string "VolumetricLightScatteringPostProcess"
  53893. * @returns "VolumetricLightScatteringPostProcess"
  53894. */
  53895. getClassName(): string;
  53896. private _isReady;
  53897. /**
  53898. * Sets the new light position for light scattering effect
  53899. * @param position The new custom light position
  53900. */
  53901. setCustomMeshPosition(position: Vector3): void;
  53902. /**
  53903. * Returns the light position for light scattering effect
  53904. * @return Vector3 The custom light position
  53905. */
  53906. getCustomMeshPosition(): Vector3;
  53907. /**
  53908. * Disposes the internal assets and detaches the post-process from the camera
  53909. */
  53910. dispose(camera: Camera): void;
  53911. /**
  53912. * Returns the render target texture used by the post-process
  53913. * @return the render target texture used by the post-process
  53914. */
  53915. getPass(): RenderTargetTexture;
  53916. private _meshExcluded;
  53917. private _createPass;
  53918. private _updateMeshScreenCoordinates;
  53919. /**
  53920. * Creates a default mesh for the Volumeric Light Scattering post-process
  53921. * @param name The mesh name
  53922. * @param scene The scene where to create the mesh
  53923. * @return the default mesh
  53924. */
  53925. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53926. }
  53927. }
  53928. declare module "babylonjs/PostProcesses/index" {
  53929. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53930. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53931. export * from "babylonjs/PostProcesses/bloomEffect";
  53932. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53933. export * from "babylonjs/PostProcesses/blurPostProcess";
  53934. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53935. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53936. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53937. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53938. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53939. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53940. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53941. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53942. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53943. export * from "babylonjs/PostProcesses/filterPostProcess";
  53944. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53945. export * from "babylonjs/PostProcesses/grainPostProcess";
  53946. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53947. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53948. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53949. export * from "babylonjs/PostProcesses/passPostProcess";
  53950. export * from "babylonjs/PostProcesses/postProcess";
  53951. export * from "babylonjs/PostProcesses/postProcessManager";
  53952. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53953. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53954. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53955. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53956. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53957. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53958. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53959. }
  53960. declare module "babylonjs/Probes/index" {
  53961. export * from "babylonjs/Probes/reflectionProbe";
  53962. }
  53963. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53964. import { Scene } from "babylonjs/scene";
  53965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53966. import { Color3 } from "babylonjs/Maths/math";
  53967. import { SmartArray } from "babylonjs/Misc/smartArray";
  53968. import { ISceneComponent } from "babylonjs/sceneComponent";
  53969. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53970. import "babylonjs/Meshes/Builders/boxBuilder";
  53971. import "babylonjs/Shaders/color.fragment";
  53972. import "babylonjs/Shaders/color.vertex";
  53973. module "babylonjs/scene" {
  53974. interface Scene {
  53975. /** @hidden (Backing field) */
  53976. _boundingBoxRenderer: BoundingBoxRenderer;
  53977. /** @hidden (Backing field) */
  53978. _forceShowBoundingBoxes: boolean;
  53979. /**
  53980. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53981. */
  53982. forceShowBoundingBoxes: boolean;
  53983. /**
  53984. * Gets the bounding box renderer associated with the scene
  53985. * @returns a BoundingBoxRenderer
  53986. */
  53987. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53988. }
  53989. }
  53990. module "babylonjs/Meshes/abstractMesh" {
  53991. interface AbstractMesh {
  53992. /** @hidden (Backing field) */
  53993. _showBoundingBox: boolean;
  53994. /**
  53995. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53996. */
  53997. showBoundingBox: boolean;
  53998. }
  53999. }
  54000. /**
  54001. * Component responsible of rendering the bounding box of the meshes in a scene.
  54002. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54003. */
  54004. export class BoundingBoxRenderer implements ISceneComponent {
  54005. /**
  54006. * The component name helpfull to identify the component in the list of scene components.
  54007. */
  54008. readonly name: string;
  54009. /**
  54010. * The scene the component belongs to.
  54011. */
  54012. scene: Scene;
  54013. /**
  54014. * Color of the bounding box lines placed in front of an object
  54015. */
  54016. frontColor: Color3;
  54017. /**
  54018. * Color of the bounding box lines placed behind an object
  54019. */
  54020. backColor: Color3;
  54021. /**
  54022. * Defines if the renderer should show the back lines or not
  54023. */
  54024. showBackLines: boolean;
  54025. /**
  54026. * @hidden
  54027. */
  54028. renderList: SmartArray<BoundingBox>;
  54029. private _colorShader;
  54030. private _vertexBuffers;
  54031. private _indexBuffer;
  54032. /**
  54033. * Instantiates a new bounding box renderer in a scene.
  54034. * @param scene the scene the renderer renders in
  54035. */
  54036. constructor(scene: Scene);
  54037. /**
  54038. * Registers the component in a given scene
  54039. */
  54040. register(): void;
  54041. private _evaluateSubMesh;
  54042. private _activeMesh;
  54043. private _prepareRessources;
  54044. private _createIndexBuffer;
  54045. /**
  54046. * Rebuilds the elements related to this component in case of
  54047. * context lost for instance.
  54048. */
  54049. rebuild(): void;
  54050. /**
  54051. * @hidden
  54052. */
  54053. reset(): void;
  54054. /**
  54055. * Render the bounding boxes of a specific rendering group
  54056. * @param renderingGroupId defines the rendering group to render
  54057. */
  54058. render(renderingGroupId: number): void;
  54059. /**
  54060. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54061. * @param mesh Define the mesh to render the occlusion bounding box for
  54062. */
  54063. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54064. /**
  54065. * Dispose and release the resources attached to this renderer.
  54066. */
  54067. dispose(): void;
  54068. }
  54069. }
  54070. declare module "babylonjs/Shaders/depth.fragment" {
  54071. /** @hidden */
  54072. export var depthPixelShader: {
  54073. name: string;
  54074. shader: string;
  54075. };
  54076. }
  54077. declare module "babylonjs/Rendering/depthRenderer" {
  54078. import { Nullable } from "babylonjs/types";
  54079. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54080. import { Scene } from "babylonjs/scene";
  54081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54082. import { Camera } from "babylonjs/Cameras/camera";
  54083. import "babylonjs/Shaders/depth.fragment";
  54084. import "babylonjs/Shaders/depth.vertex";
  54085. /**
  54086. * This represents a depth renderer in Babylon.
  54087. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54088. */
  54089. export class DepthRenderer {
  54090. private _scene;
  54091. private _depthMap;
  54092. private _effect;
  54093. private _cachedDefines;
  54094. private _camera;
  54095. /**
  54096. * Specifiess that the depth renderer will only be used within
  54097. * the camera it is created for.
  54098. * This can help forcing its rendering during the camera processing.
  54099. */
  54100. useOnlyInActiveCamera: boolean;
  54101. /** @hidden */
  54102. static _SceneComponentInitialization: (scene: Scene) => void;
  54103. /**
  54104. * Instantiates a depth renderer
  54105. * @param scene The scene the renderer belongs to
  54106. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54107. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54108. */
  54109. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54110. /**
  54111. * Creates the depth rendering effect and checks if the effect is ready.
  54112. * @param subMesh The submesh to be used to render the depth map of
  54113. * @param useInstances If multiple world instances should be used
  54114. * @returns if the depth renderer is ready to render the depth map
  54115. */
  54116. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54117. /**
  54118. * Gets the texture which the depth map will be written to.
  54119. * @returns The depth map texture
  54120. */
  54121. getDepthMap(): RenderTargetTexture;
  54122. /**
  54123. * Disposes of the depth renderer.
  54124. */
  54125. dispose(): void;
  54126. }
  54127. }
  54128. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54129. import { Nullable } from "babylonjs/types";
  54130. import { Scene } from "babylonjs/scene";
  54131. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54132. import { Camera } from "babylonjs/Cameras/camera";
  54133. import { ISceneComponent } from "babylonjs/sceneComponent";
  54134. module "babylonjs/scene" {
  54135. interface Scene {
  54136. /** @hidden (Backing field) */
  54137. _depthRenderer: {
  54138. [id: string]: DepthRenderer;
  54139. };
  54140. /**
  54141. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54142. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54143. * @returns the created depth renderer
  54144. */
  54145. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54146. /**
  54147. * Disables a depth renderer for a given camera
  54148. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54149. */
  54150. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54151. }
  54152. }
  54153. /**
  54154. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54155. * in several rendering techniques.
  54156. */
  54157. export class DepthRendererSceneComponent implements ISceneComponent {
  54158. /**
  54159. * The component name helpfull to identify the component in the list of scene components.
  54160. */
  54161. readonly name: string;
  54162. /**
  54163. * The scene the component belongs to.
  54164. */
  54165. scene: Scene;
  54166. /**
  54167. * Creates a new instance of the component for the given scene
  54168. * @param scene Defines the scene to register the component in
  54169. */
  54170. constructor(scene: Scene);
  54171. /**
  54172. * Registers the component in a given scene
  54173. */
  54174. register(): void;
  54175. /**
  54176. * Rebuilds the elements related to this component in case of
  54177. * context lost for instance.
  54178. */
  54179. rebuild(): void;
  54180. /**
  54181. * Disposes the component and the associated ressources
  54182. */
  54183. dispose(): void;
  54184. private _gatherRenderTargets;
  54185. private _gatherActiveCameraRenderTargets;
  54186. }
  54187. }
  54188. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54189. import { Nullable } from "babylonjs/types";
  54190. import { Scene } from "babylonjs/scene";
  54191. import { ISceneComponent } from "babylonjs/sceneComponent";
  54192. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54193. module "babylonjs/scene" {
  54194. interface Scene {
  54195. /** @hidden (Backing field) */
  54196. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54197. /**
  54198. * Gets or Sets the current geometry buffer associated to the scene.
  54199. */
  54200. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54201. /**
  54202. * Enables a GeometryBufferRender and associates it with the scene
  54203. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54204. * @returns the GeometryBufferRenderer
  54205. */
  54206. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54207. /**
  54208. * Disables the GeometryBufferRender associated with the scene
  54209. */
  54210. disableGeometryBufferRenderer(): void;
  54211. }
  54212. }
  54213. /**
  54214. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54215. * in several rendering techniques.
  54216. */
  54217. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54218. /**
  54219. * The component name helpful to identify the component in the list of scene components.
  54220. */
  54221. readonly name: string;
  54222. /**
  54223. * The scene the component belongs to.
  54224. */
  54225. scene: Scene;
  54226. /**
  54227. * Creates a new instance of the component for the given scene
  54228. * @param scene Defines the scene to register the component in
  54229. */
  54230. constructor(scene: Scene);
  54231. /**
  54232. * Registers the component in a given scene
  54233. */
  54234. register(): void;
  54235. /**
  54236. * Rebuilds the elements related to this component in case of
  54237. * context lost for instance.
  54238. */
  54239. rebuild(): void;
  54240. /**
  54241. * Disposes the component and the associated ressources
  54242. */
  54243. dispose(): void;
  54244. private _gatherRenderTargets;
  54245. }
  54246. }
  54247. declare module "babylonjs/Shaders/outline.fragment" {
  54248. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54249. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54250. /** @hidden */
  54251. export var outlinePixelShader: {
  54252. name: string;
  54253. shader: string;
  54254. };
  54255. }
  54256. declare module "babylonjs/Shaders/outline.vertex" {
  54257. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54258. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54259. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54260. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54261. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54262. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54263. /** @hidden */
  54264. export var outlineVertexShader: {
  54265. name: string;
  54266. shader: string;
  54267. };
  54268. }
  54269. declare module "babylonjs/Rendering/outlineRenderer" {
  54270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54271. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54272. import { Scene } from "babylonjs/scene";
  54273. import { ISceneComponent } from "babylonjs/sceneComponent";
  54274. import "babylonjs/Shaders/outline.fragment";
  54275. import "babylonjs/Shaders/outline.vertex";
  54276. module "babylonjs/scene" {
  54277. interface Scene {
  54278. /** @hidden */
  54279. _outlineRenderer: OutlineRenderer;
  54280. /**
  54281. * Gets the outline renderer associated with the scene
  54282. * @returns a OutlineRenderer
  54283. */
  54284. getOutlineRenderer(): OutlineRenderer;
  54285. }
  54286. }
  54287. module "babylonjs/Meshes/abstractMesh" {
  54288. interface AbstractMesh {
  54289. /** @hidden (Backing field) */
  54290. _renderOutline: boolean;
  54291. /**
  54292. * Gets or sets a boolean indicating if the outline must be rendered as well
  54293. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54294. */
  54295. renderOutline: boolean;
  54296. /** @hidden (Backing field) */
  54297. _renderOverlay: boolean;
  54298. /**
  54299. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54300. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54301. */
  54302. renderOverlay: boolean;
  54303. }
  54304. }
  54305. /**
  54306. * This class is responsible to draw bothe outline/overlay of meshes.
  54307. * It should not be used directly but through the available method on mesh.
  54308. */
  54309. export class OutlineRenderer implements ISceneComponent {
  54310. /**
  54311. * The name of the component. Each component must have a unique name.
  54312. */
  54313. name: string;
  54314. /**
  54315. * The scene the component belongs to.
  54316. */
  54317. scene: Scene;
  54318. /**
  54319. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54320. */
  54321. zOffset: number;
  54322. private _engine;
  54323. private _effect;
  54324. private _cachedDefines;
  54325. private _savedDepthWrite;
  54326. /**
  54327. * Instantiates a new outline renderer. (There could be only one per scene).
  54328. * @param scene Defines the scene it belongs to
  54329. */
  54330. constructor(scene: Scene);
  54331. /**
  54332. * Register the component to one instance of a scene.
  54333. */
  54334. register(): void;
  54335. /**
  54336. * Rebuilds the elements related to this component in case of
  54337. * context lost for instance.
  54338. */
  54339. rebuild(): void;
  54340. /**
  54341. * Disposes the component and the associated ressources.
  54342. */
  54343. dispose(): void;
  54344. /**
  54345. * Renders the outline in the canvas.
  54346. * @param subMesh Defines the sumesh to render
  54347. * @param batch Defines the batch of meshes in case of instances
  54348. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54349. */
  54350. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54351. /**
  54352. * Returns whether or not the outline renderer is ready for a given submesh.
  54353. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54354. * @param subMesh Defines the submesh to check readyness for
  54355. * @param useInstances Defines wheter wee are trying to render instances or not
  54356. * @returns true if ready otherwise false
  54357. */
  54358. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54359. private _beforeRenderingMesh;
  54360. private _afterRenderingMesh;
  54361. }
  54362. }
  54363. declare module "babylonjs/Rendering/index" {
  54364. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54365. export * from "babylonjs/Rendering/depthRenderer";
  54366. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54367. export * from "babylonjs/Rendering/edgesRenderer";
  54368. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54369. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54370. export * from "babylonjs/Rendering/outlineRenderer";
  54371. export * from "babylonjs/Rendering/renderingGroup";
  54372. export * from "babylonjs/Rendering/renderingManager";
  54373. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54374. }
  54375. declare module "babylonjs/Sprites/index" {
  54376. export * from "babylonjs/Sprites/sprite";
  54377. export * from "babylonjs/Sprites/spriteManager";
  54378. export * from "babylonjs/Sprites/spriteSceneComponent";
  54379. }
  54380. declare module "babylonjs/Misc/assetsManager" {
  54381. import { Scene } from "babylonjs/scene";
  54382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54384. import { Skeleton } from "babylonjs/Bones/skeleton";
  54385. import { Observable } from "babylonjs/Misc/observable";
  54386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54387. import { Texture } from "babylonjs/Materials/Textures/texture";
  54388. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54389. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54390. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54391. /**
  54392. * Defines the list of states available for a task inside a AssetsManager
  54393. */
  54394. export enum AssetTaskState {
  54395. /**
  54396. * Initialization
  54397. */
  54398. INIT = 0,
  54399. /**
  54400. * Running
  54401. */
  54402. RUNNING = 1,
  54403. /**
  54404. * Done
  54405. */
  54406. DONE = 2,
  54407. /**
  54408. * Error
  54409. */
  54410. ERROR = 3
  54411. }
  54412. /**
  54413. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54414. */
  54415. export abstract class AbstractAssetTask {
  54416. /**
  54417. * Task name
  54418. */ name: string;
  54419. /**
  54420. * Callback called when the task is successful
  54421. */
  54422. onSuccess: (task: any) => void;
  54423. /**
  54424. * Callback called when the task is not successful
  54425. */
  54426. onError: (task: any, message?: string, exception?: any) => void;
  54427. /**
  54428. * Creates a new AssetsManager
  54429. * @param name defines the name of the task
  54430. */
  54431. constructor(
  54432. /**
  54433. * Task name
  54434. */ name: string);
  54435. private _isCompleted;
  54436. private _taskState;
  54437. private _errorObject;
  54438. /**
  54439. * Get if the task is completed
  54440. */
  54441. readonly isCompleted: boolean;
  54442. /**
  54443. * Gets the current state of the task
  54444. */
  54445. readonly taskState: AssetTaskState;
  54446. /**
  54447. * Gets the current error object (if task is in error)
  54448. */
  54449. readonly errorObject: {
  54450. message?: string;
  54451. exception?: any;
  54452. };
  54453. /**
  54454. * Internal only
  54455. * @hidden
  54456. */
  54457. _setErrorObject(message?: string, exception?: any): void;
  54458. /**
  54459. * Execute the current task
  54460. * @param scene defines the scene where you want your assets to be loaded
  54461. * @param onSuccess is a callback called when the task is successfully executed
  54462. * @param onError is a callback called if an error occurs
  54463. */
  54464. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54465. /**
  54466. * Execute the current task
  54467. * @param scene defines the scene where you want your assets to be loaded
  54468. * @param onSuccess is a callback called when the task is successfully executed
  54469. * @param onError is a callback called if an error occurs
  54470. */
  54471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54472. /**
  54473. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54474. * This can be used with failed tasks that have the reason for failure fixed.
  54475. */
  54476. reset(): void;
  54477. private onErrorCallback;
  54478. private onDoneCallback;
  54479. }
  54480. /**
  54481. * Define the interface used by progress events raised during assets loading
  54482. */
  54483. export interface IAssetsProgressEvent {
  54484. /**
  54485. * Defines the number of remaining tasks to process
  54486. */
  54487. remainingCount: number;
  54488. /**
  54489. * Defines the total number of tasks
  54490. */
  54491. totalCount: number;
  54492. /**
  54493. * Defines the task that was just processed
  54494. */
  54495. task: AbstractAssetTask;
  54496. }
  54497. /**
  54498. * Class used to share progress information about assets loading
  54499. */
  54500. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54501. /**
  54502. * Defines the number of remaining tasks to process
  54503. */
  54504. remainingCount: number;
  54505. /**
  54506. * Defines the total number of tasks
  54507. */
  54508. totalCount: number;
  54509. /**
  54510. * Defines the task that was just processed
  54511. */
  54512. task: AbstractAssetTask;
  54513. /**
  54514. * Creates a AssetsProgressEvent
  54515. * @param remainingCount defines the number of remaining tasks to process
  54516. * @param totalCount defines the total number of tasks
  54517. * @param task defines the task that was just processed
  54518. */
  54519. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54520. }
  54521. /**
  54522. * Define a task used by AssetsManager to load meshes
  54523. */
  54524. export class MeshAssetTask extends AbstractAssetTask {
  54525. /**
  54526. * Defines the name of the task
  54527. */
  54528. name: string;
  54529. /**
  54530. * Defines the list of mesh's names you want to load
  54531. */
  54532. meshesNames: any;
  54533. /**
  54534. * Defines the root url to use as a base to load your meshes and associated resources
  54535. */
  54536. rootUrl: string;
  54537. /**
  54538. * Defines the filename of the scene to load from
  54539. */
  54540. sceneFilename: string;
  54541. /**
  54542. * Gets the list of loaded meshes
  54543. */
  54544. loadedMeshes: Array<AbstractMesh>;
  54545. /**
  54546. * Gets the list of loaded particle systems
  54547. */
  54548. loadedParticleSystems: Array<IParticleSystem>;
  54549. /**
  54550. * Gets the list of loaded skeletons
  54551. */
  54552. loadedSkeletons: Array<Skeleton>;
  54553. /**
  54554. * Gets the list of loaded animation groups
  54555. */
  54556. loadedAnimationGroups: Array<AnimationGroup>;
  54557. /**
  54558. * Callback called when the task is successful
  54559. */
  54560. onSuccess: (task: MeshAssetTask) => void;
  54561. /**
  54562. * Callback called when the task is successful
  54563. */
  54564. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54565. /**
  54566. * Creates a new MeshAssetTask
  54567. * @param name defines the name of the task
  54568. * @param meshesNames defines the list of mesh's names you want to load
  54569. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54570. * @param sceneFilename defines the filename of the scene to load from
  54571. */
  54572. constructor(
  54573. /**
  54574. * Defines the name of the task
  54575. */
  54576. name: string,
  54577. /**
  54578. * Defines the list of mesh's names you want to load
  54579. */
  54580. meshesNames: any,
  54581. /**
  54582. * Defines the root url to use as a base to load your meshes and associated resources
  54583. */
  54584. rootUrl: string,
  54585. /**
  54586. * Defines the filename of the scene to load from
  54587. */
  54588. sceneFilename: string);
  54589. /**
  54590. * Execute the current task
  54591. * @param scene defines the scene where you want your assets to be loaded
  54592. * @param onSuccess is a callback called when the task is successfully executed
  54593. * @param onError is a callback called if an error occurs
  54594. */
  54595. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54596. }
  54597. /**
  54598. * Define a task used by AssetsManager to load text content
  54599. */
  54600. export class TextFileAssetTask extends AbstractAssetTask {
  54601. /**
  54602. * Defines the name of the task
  54603. */
  54604. name: string;
  54605. /**
  54606. * Defines the location of the file to load
  54607. */
  54608. url: string;
  54609. /**
  54610. * Gets the loaded text string
  54611. */
  54612. text: string;
  54613. /**
  54614. * Callback called when the task is successful
  54615. */
  54616. onSuccess: (task: TextFileAssetTask) => void;
  54617. /**
  54618. * Callback called when the task is successful
  54619. */
  54620. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54621. /**
  54622. * Creates a new TextFileAssetTask object
  54623. * @param name defines the name of the task
  54624. * @param url defines the location of the file to load
  54625. */
  54626. constructor(
  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. * Execute the current task
  54637. * @param scene defines the scene where you want your assets to be loaded
  54638. * @param onSuccess is a callback called when the task is successfully executed
  54639. * @param onError is a callback called if an error occurs
  54640. */
  54641. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54642. }
  54643. /**
  54644. * Define a task used by AssetsManager to load binary data
  54645. */
  54646. export class BinaryFileAssetTask extends AbstractAssetTask {
  54647. /**
  54648. * Defines the name of the task
  54649. */
  54650. name: string;
  54651. /**
  54652. * Defines the location of the file to load
  54653. */
  54654. url: string;
  54655. /**
  54656. * Gets the lodaded data (as an array buffer)
  54657. */
  54658. data: ArrayBuffer;
  54659. /**
  54660. * Callback called when the task is successful
  54661. */
  54662. onSuccess: (task: BinaryFileAssetTask) => void;
  54663. /**
  54664. * Callback called when the task is successful
  54665. */
  54666. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54667. /**
  54668. * Creates a new BinaryFileAssetTask object
  54669. * @param name defines the name of the new task
  54670. * @param url defines the location of the file to load
  54671. */
  54672. constructor(
  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. * Execute the current task
  54683. * @param scene defines the scene where you want your assets to be loaded
  54684. * @param onSuccess is a callback called when the task is successfully executed
  54685. * @param onError is a callback called if an error occurs
  54686. */
  54687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54688. }
  54689. /**
  54690. * Define a task used by AssetsManager to load images
  54691. */
  54692. export class ImageAssetTask extends AbstractAssetTask {
  54693. /**
  54694. * Defines the name of the task
  54695. */
  54696. name: string;
  54697. /**
  54698. * Defines the location of the image to load
  54699. */
  54700. url: string;
  54701. /**
  54702. * Gets the loaded images
  54703. */
  54704. image: HTMLImageElement;
  54705. /**
  54706. * Callback called when the task is successful
  54707. */
  54708. onSuccess: (task: ImageAssetTask) => void;
  54709. /**
  54710. * Callback called when the task is successful
  54711. */
  54712. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54713. /**
  54714. * Creates a new ImageAssetTask
  54715. * @param name defines the name of the task
  54716. * @param url defines the location of the image to load
  54717. */
  54718. constructor(
  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. * Execute the current task
  54729. * @param scene defines the scene where you want your assets to be loaded
  54730. * @param onSuccess is a callback called when the task is successfully executed
  54731. * @param onError is a callback called if an error occurs
  54732. */
  54733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54734. }
  54735. /**
  54736. * Defines the interface used by texture loading tasks
  54737. */
  54738. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54739. /**
  54740. * Gets the loaded texture
  54741. */
  54742. texture: TEX;
  54743. }
  54744. /**
  54745. * Define a task used by AssetsManager to load 2D textures
  54746. */
  54747. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54748. /**
  54749. * Defines the name of the task
  54750. */
  54751. name: string;
  54752. /**
  54753. * Defines the location of the file to load
  54754. */
  54755. url: string;
  54756. /**
  54757. * Defines if mipmap should not be generated (default is false)
  54758. */
  54759. noMipmap?: boolean | undefined;
  54760. /**
  54761. * Defines if texture must be inverted on Y axis (default is false)
  54762. */
  54763. invertY?: boolean | undefined;
  54764. /**
  54765. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54766. */
  54767. samplingMode: number;
  54768. /**
  54769. * Gets the loaded texture
  54770. */
  54771. texture: Texture;
  54772. /**
  54773. * Callback called when the task is successful
  54774. */
  54775. onSuccess: (task: TextureAssetTask) => void;
  54776. /**
  54777. * Callback called when the task is successful
  54778. */
  54779. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54780. /**
  54781. * Creates a new TextureAssetTask object
  54782. * @param name defines the name of the task
  54783. * @param url defines the location of the file to load
  54784. * @param noMipmap defines if mipmap should not be generated (default is false)
  54785. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54786. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54787. */
  54788. constructor(
  54789. /**
  54790. * Defines the name of the task
  54791. */
  54792. name: string,
  54793. /**
  54794. * Defines the location of the file to load
  54795. */
  54796. url: string,
  54797. /**
  54798. * Defines if mipmap should not be generated (default is false)
  54799. */
  54800. noMipmap?: boolean | undefined,
  54801. /**
  54802. * Defines if texture must be inverted on Y axis (default is false)
  54803. */
  54804. invertY?: boolean | undefined,
  54805. /**
  54806. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54807. */
  54808. samplingMode?: number);
  54809. /**
  54810. * Execute the current task
  54811. * @param scene defines the scene where you want your assets to be loaded
  54812. * @param onSuccess is a callback called when the task is successfully executed
  54813. * @param onError is a callback called if an error occurs
  54814. */
  54815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54816. }
  54817. /**
  54818. * Define a task used by AssetsManager to load cube textures
  54819. */
  54820. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54821. /**
  54822. * Defines the name of the task
  54823. */
  54824. name: string;
  54825. /**
  54826. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54827. */
  54828. url: string;
  54829. /**
  54830. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54831. */
  54832. extensions?: string[] | undefined;
  54833. /**
  54834. * Defines if mipmaps should not be generated (default is false)
  54835. */
  54836. noMipmap?: boolean | undefined;
  54837. /**
  54838. * Defines the explicit list of files (undefined by default)
  54839. */
  54840. files?: string[] | undefined;
  54841. /**
  54842. * Gets the loaded texture
  54843. */
  54844. texture: CubeTexture;
  54845. /**
  54846. * Callback called when the task is successful
  54847. */
  54848. onSuccess: (task: CubeTextureAssetTask) => void;
  54849. /**
  54850. * Callback called when the task is successful
  54851. */
  54852. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54853. /**
  54854. * Creates a new CubeTextureAssetTask
  54855. * @param name defines the name of the task
  54856. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54857. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54858. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54859. * @param files defines the explicit list of files (undefined by default)
  54860. */
  54861. constructor(
  54862. /**
  54863. * Defines the name of the task
  54864. */
  54865. name: string,
  54866. /**
  54867. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54868. */
  54869. url: string,
  54870. /**
  54871. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54872. */
  54873. extensions?: string[] | undefined,
  54874. /**
  54875. * Defines if mipmaps should not be generated (default is false)
  54876. */
  54877. noMipmap?: boolean | undefined,
  54878. /**
  54879. * Defines the explicit list of files (undefined by default)
  54880. */
  54881. files?: string[] | undefined);
  54882. /**
  54883. * Execute the current task
  54884. * @param scene defines the scene where you want your assets to be loaded
  54885. * @param onSuccess is a callback called when the task is successfully executed
  54886. * @param onError is a callback called if an error occurs
  54887. */
  54888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54889. }
  54890. /**
  54891. * Define a task used by AssetsManager to load HDR cube textures
  54892. */
  54893. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54894. /**
  54895. * Defines the name of the task
  54896. */
  54897. name: string;
  54898. /**
  54899. * Defines the location of the file to load
  54900. */
  54901. url: string;
  54902. /**
  54903. * Defines the desired size (the more it increases the longer the generation will be)
  54904. */
  54905. size: number;
  54906. /**
  54907. * Defines if mipmaps should not be generated (default is false)
  54908. */
  54909. noMipmap: boolean;
  54910. /**
  54911. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54912. */
  54913. generateHarmonics: boolean;
  54914. /**
  54915. * 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)
  54916. */
  54917. gammaSpace: boolean;
  54918. /**
  54919. * Internal Use Only
  54920. */
  54921. reserved: boolean;
  54922. /**
  54923. * Gets the loaded texture
  54924. */
  54925. texture: HDRCubeTexture;
  54926. /**
  54927. * Callback called when the task is successful
  54928. */
  54929. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54930. /**
  54931. * Callback called when the task is successful
  54932. */
  54933. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54934. /**
  54935. * Creates a new HDRCubeTextureAssetTask object
  54936. * @param name defines the name of the task
  54937. * @param url defines the location of the file to load
  54938. * @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.
  54939. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54940. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54941. * @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)
  54942. * @param reserved Internal use only
  54943. */
  54944. constructor(
  54945. /**
  54946. * Defines the name of the task
  54947. */
  54948. name: string,
  54949. /**
  54950. * Defines the location of the file to load
  54951. */
  54952. url: string,
  54953. /**
  54954. * Defines the desired size (the more it increases the longer the generation will be)
  54955. */
  54956. size: number,
  54957. /**
  54958. * Defines if mipmaps should not be generated (default is false)
  54959. */
  54960. noMipmap?: boolean,
  54961. /**
  54962. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54963. */
  54964. generateHarmonics?: boolean,
  54965. /**
  54966. * 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)
  54967. */
  54968. gammaSpace?: boolean,
  54969. /**
  54970. * Internal Use Only
  54971. */
  54972. reserved?: boolean);
  54973. /**
  54974. * Execute the current task
  54975. * @param scene defines the scene where you want your assets to be loaded
  54976. * @param onSuccess is a callback called when the task is successfully executed
  54977. * @param onError is a callback called if an error occurs
  54978. */
  54979. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54980. }
  54981. /**
  54982. * This class can be used to easily import assets into a scene
  54983. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54984. */
  54985. export class AssetsManager {
  54986. private _scene;
  54987. private _isLoading;
  54988. protected _tasks: AbstractAssetTask[];
  54989. protected _waitingTasksCount: number;
  54990. protected _totalTasksCount: number;
  54991. /**
  54992. * Callback called when all tasks are processed
  54993. */
  54994. onFinish: (tasks: AbstractAssetTask[]) => void;
  54995. /**
  54996. * Callback called when a task is successful
  54997. */
  54998. onTaskSuccess: (task: AbstractAssetTask) => void;
  54999. /**
  55000. * Callback called when a task had an error
  55001. */
  55002. onTaskError: (task: AbstractAssetTask) => void;
  55003. /**
  55004. * Callback called when a task is done (whatever the result is)
  55005. */
  55006. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55007. /**
  55008. * Observable called when all tasks are processed
  55009. */
  55010. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55011. /**
  55012. * Observable called when a task had an error
  55013. */
  55014. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55015. /**
  55016. * Observable called when a task is successful
  55017. */
  55018. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55019. /**
  55020. * Observable called when a task is done (whatever the result is)
  55021. */
  55022. onProgressObservable: Observable<IAssetsProgressEvent>;
  55023. /**
  55024. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55025. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55026. */
  55027. useDefaultLoadingScreen: boolean;
  55028. /**
  55029. * Creates a new AssetsManager
  55030. * @param scene defines the scene to work on
  55031. */
  55032. constructor(scene: Scene);
  55033. /**
  55034. * Add a MeshAssetTask to the list of active tasks
  55035. * @param taskName defines the name of the new task
  55036. * @param meshesNames defines the name of meshes to load
  55037. * @param rootUrl defines the root url to use to locate files
  55038. * @param sceneFilename defines the filename of the scene file
  55039. * @returns a new MeshAssetTask object
  55040. */
  55041. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55042. /**
  55043. * Add a TextFileAssetTask to the list of active tasks
  55044. * @param taskName defines the name of the new task
  55045. * @param url defines the url of the file to load
  55046. * @returns a new TextFileAssetTask object
  55047. */
  55048. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55049. /**
  55050. * Add a BinaryFileAssetTask to the list of active tasks
  55051. * @param taskName defines the name of the new task
  55052. * @param url defines the url of the file to load
  55053. * @returns a new BinaryFileAssetTask object
  55054. */
  55055. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55056. /**
  55057. * Add a ImageAssetTask to the list of active tasks
  55058. * @param taskName defines the name of the new task
  55059. * @param url defines the url of the file to load
  55060. * @returns a new ImageAssetTask object
  55061. */
  55062. addImageTask(taskName: string, url: string): ImageAssetTask;
  55063. /**
  55064. * Add a TextureAssetTask to the list of active tasks
  55065. * @param taskName defines the name of the new task
  55066. * @param url defines the url of the file to load
  55067. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55068. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55069. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55070. * @returns a new TextureAssetTask object
  55071. */
  55072. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55073. /**
  55074. * Add a CubeTextureAssetTask to the list of active tasks
  55075. * @param taskName defines the name of the new task
  55076. * @param url defines the url of the file to load
  55077. * @param extensions defines the extension to use to load the cube map (can be null)
  55078. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55079. * @param files defines the list of files to load (can be null)
  55080. * @returns a new CubeTextureAssetTask object
  55081. */
  55082. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55083. /**
  55084. *
  55085. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55086. * @param taskName defines the name of the new task
  55087. * @param url defines the url of the file to load
  55088. * @param size defines the size you want for the cubemap (can be null)
  55089. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55090. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55091. * @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)
  55092. * @param reserved Internal use only
  55093. * @returns a new HDRCubeTextureAssetTask object
  55094. */
  55095. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55096. /**
  55097. * Remove a task from the assets manager.
  55098. * @param task the task to remove
  55099. */
  55100. removeTask(task: AbstractAssetTask): void;
  55101. private _decreaseWaitingTasksCount;
  55102. private _runTask;
  55103. /**
  55104. * Reset the AssetsManager and remove all tasks
  55105. * @return the current instance of the AssetsManager
  55106. */
  55107. reset(): AssetsManager;
  55108. /**
  55109. * Start the loading process
  55110. * @return the current instance of the AssetsManager
  55111. */
  55112. load(): AssetsManager;
  55113. }
  55114. }
  55115. declare module "babylonjs/Misc/deferred" {
  55116. /**
  55117. * Wrapper class for promise with external resolve and reject.
  55118. */
  55119. export class Deferred<T> {
  55120. /**
  55121. * The promise associated with this deferred object.
  55122. */
  55123. readonly promise: Promise<T>;
  55124. private _resolve;
  55125. private _reject;
  55126. /**
  55127. * The resolve method of the promise associated with this deferred object.
  55128. */
  55129. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55130. /**
  55131. * The reject method of the promise associated with this deferred object.
  55132. */
  55133. readonly reject: (reason?: any) => void;
  55134. /**
  55135. * Constructor for this deferred object.
  55136. */
  55137. constructor();
  55138. }
  55139. }
  55140. declare module "babylonjs/Misc/filesInput" {
  55141. import { Engine } from "babylonjs/Engines/engine";
  55142. import { Scene } from "babylonjs/scene";
  55143. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55144. /**
  55145. * Class used to help managing file picking and drag'n'drop
  55146. */
  55147. export class FilesInput {
  55148. /**
  55149. * List of files ready to be loaded
  55150. */
  55151. static readonly FilesToLoad: {
  55152. [key: string]: File;
  55153. };
  55154. /**
  55155. * Callback called when a file is processed
  55156. */
  55157. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55158. private _engine;
  55159. private _currentScene;
  55160. private _sceneLoadedCallback;
  55161. private _progressCallback;
  55162. private _additionalRenderLoopLogicCallback;
  55163. private _textureLoadingCallback;
  55164. private _startingProcessingFilesCallback;
  55165. private _onReloadCallback;
  55166. private _errorCallback;
  55167. private _elementToMonitor;
  55168. private _sceneFileToLoad;
  55169. private _filesToLoad;
  55170. /**
  55171. * Creates a new FilesInput
  55172. * @param engine defines the rendering engine
  55173. * @param scene defines the hosting scene
  55174. * @param sceneLoadedCallback callback called when scene is loaded
  55175. * @param progressCallback callback called to track progress
  55176. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55177. * @param textureLoadingCallback callback called when a texture is loading
  55178. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55179. * @param onReloadCallback callback called when a reload is requested
  55180. * @param errorCallback callback call if an error occurs
  55181. */
  55182. 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);
  55183. private _dragEnterHandler;
  55184. private _dragOverHandler;
  55185. private _dropHandler;
  55186. /**
  55187. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55188. * @param elementToMonitor defines the DOM element to track
  55189. */
  55190. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55191. /**
  55192. * Release all associated resources
  55193. */
  55194. dispose(): void;
  55195. private renderFunction;
  55196. private drag;
  55197. private drop;
  55198. private _traverseFolder;
  55199. private _processFiles;
  55200. /**
  55201. * Load files from a drop event
  55202. * @param event defines the drop event to use as source
  55203. */
  55204. loadFiles(event: any): void;
  55205. private _processReload;
  55206. /**
  55207. * Reload the current scene from the loaded files
  55208. */
  55209. reload(): void;
  55210. }
  55211. }
  55212. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55213. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55214. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55215. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55216. }
  55217. declare module "babylonjs/Misc/sceneOptimizer" {
  55218. import { Scene, IDisposable } from "babylonjs/scene";
  55219. import { Observable } from "babylonjs/Misc/observable";
  55220. /**
  55221. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55223. */
  55224. export class SceneOptimization {
  55225. /**
  55226. * Defines the priority of this optimization (0 by default which means first in the list)
  55227. */
  55228. priority: number;
  55229. /**
  55230. * Gets a string describing the action executed by the current optimization
  55231. * @returns description string
  55232. */
  55233. getDescription(): string;
  55234. /**
  55235. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55236. * @param scene defines the current scene where to apply this optimization
  55237. * @param optimizer defines the current optimizer
  55238. * @returns true if everything that can be done was applied
  55239. */
  55240. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55241. /**
  55242. * Creates the SceneOptimization object
  55243. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55244. * @param desc defines the description associated with the optimization
  55245. */
  55246. constructor(
  55247. /**
  55248. * Defines the priority of this optimization (0 by default which means first in the list)
  55249. */
  55250. priority?: number);
  55251. }
  55252. /**
  55253. * Defines an optimization used to reduce the size of render target textures
  55254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55255. */
  55256. export class TextureOptimization extends SceneOptimization {
  55257. /**
  55258. * Defines the priority of this optimization (0 by default which means first in the list)
  55259. */
  55260. priority: number;
  55261. /**
  55262. * 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
  55263. */
  55264. maximumSize: number;
  55265. /**
  55266. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55267. */
  55268. step: number;
  55269. /**
  55270. * Gets a string describing the action executed by the current optimization
  55271. * @returns description string
  55272. */
  55273. getDescription(): string;
  55274. /**
  55275. * Creates the TextureOptimization object
  55276. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55277. * @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
  55278. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55279. */
  55280. constructor(
  55281. /**
  55282. * Defines the priority of this optimization (0 by default which means first in the list)
  55283. */
  55284. priority?: number,
  55285. /**
  55286. * 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
  55287. */
  55288. maximumSize?: number,
  55289. /**
  55290. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55291. */
  55292. step?: number);
  55293. /**
  55294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55295. * @param scene defines the current scene where to apply this optimization
  55296. * @param optimizer defines the current optimizer
  55297. * @returns true if everything that can be done was applied
  55298. */
  55299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55300. }
  55301. /**
  55302. * Defines an optimization used to increase or decrease the rendering resolution
  55303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55304. */
  55305. export class HardwareScalingOptimization extends SceneOptimization {
  55306. /**
  55307. * Defines the priority of this optimization (0 by default which means first in the list)
  55308. */
  55309. priority: number;
  55310. /**
  55311. * Defines the maximum scale to use (2 by default)
  55312. */
  55313. maximumScale: number;
  55314. /**
  55315. * Defines the step to use between two passes (0.5 by default)
  55316. */
  55317. step: number;
  55318. private _currentScale;
  55319. private _directionOffset;
  55320. /**
  55321. * Gets a string describing the action executed by the current optimization
  55322. * @return description string
  55323. */
  55324. getDescription(): string;
  55325. /**
  55326. * Creates the HardwareScalingOptimization object
  55327. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55328. * @param maximumScale defines the maximum scale to use (2 by default)
  55329. * @param step defines the step to use between two passes (0.5 by default)
  55330. */
  55331. constructor(
  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. /**
  55345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55346. * @param scene defines the current scene where to apply this optimization
  55347. * @param optimizer defines the current optimizer
  55348. * @returns true if everything that can be done was applied
  55349. */
  55350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55351. }
  55352. /**
  55353. * Defines an optimization used to remove shadows
  55354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55355. */
  55356. export class ShadowsOptimization extends SceneOptimization {
  55357. /**
  55358. * Gets a string describing the action executed by the current optimization
  55359. * @return description string
  55360. */
  55361. getDescription(): string;
  55362. /**
  55363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55364. * @param scene defines the current scene where to apply this optimization
  55365. * @param optimizer defines the current optimizer
  55366. * @returns true if everything that can be done was applied
  55367. */
  55368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55369. }
  55370. /**
  55371. * Defines an optimization used to turn post-processes off
  55372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55373. */
  55374. export class PostProcessesOptimization extends SceneOptimization {
  55375. /**
  55376. * Gets a string describing the action executed by the current optimization
  55377. * @return description string
  55378. */
  55379. getDescription(): string;
  55380. /**
  55381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55382. * @param scene defines the current scene where to apply this optimization
  55383. * @param optimizer defines the current optimizer
  55384. * @returns true if everything that can be done was applied
  55385. */
  55386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55387. }
  55388. /**
  55389. * Defines an optimization used to turn lens flares off
  55390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55391. */
  55392. export class LensFlaresOptimization extends SceneOptimization {
  55393. /**
  55394. * Gets a string describing the action executed by the current optimization
  55395. * @return description string
  55396. */
  55397. getDescription(): string;
  55398. /**
  55399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55400. * @param scene defines the current scene where to apply this optimization
  55401. * @param optimizer defines the current optimizer
  55402. * @returns true if everything that can be done was applied
  55403. */
  55404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55405. }
  55406. /**
  55407. * Defines an optimization based on user defined callback.
  55408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55409. */
  55410. export class CustomOptimization extends SceneOptimization {
  55411. /**
  55412. * Callback called to apply the custom optimization.
  55413. */
  55414. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55415. /**
  55416. * Callback called to get custom description
  55417. */
  55418. onGetDescription: () => string;
  55419. /**
  55420. * Gets a string describing the action executed by the current optimization
  55421. * @returns 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 used to turn particles off
  55434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55435. */
  55436. export class ParticlesOptimization extends SceneOptimization {
  55437. /**
  55438. * Gets a string describing the action executed by the current optimization
  55439. * @return description string
  55440. */
  55441. getDescription(): string;
  55442. /**
  55443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55444. * @param scene defines the current scene where to apply this optimization
  55445. * @param optimizer defines the current optimizer
  55446. * @returns true if everything that can be done was applied
  55447. */
  55448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55449. }
  55450. /**
  55451. * Defines an optimization used to turn render targets off
  55452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55453. */
  55454. export class RenderTargetsOptimization extends SceneOptimization {
  55455. /**
  55456. * Gets a string describing the action executed by the current optimization
  55457. * @return description string
  55458. */
  55459. getDescription(): string;
  55460. /**
  55461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55462. * @param scene defines the current scene where to apply this optimization
  55463. * @param optimizer defines the current optimizer
  55464. * @returns true if everything that can be done was applied
  55465. */
  55466. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55467. }
  55468. /**
  55469. * Defines an optimization used to merge meshes with compatible materials
  55470. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55471. */
  55472. export class MergeMeshesOptimization extends SceneOptimization {
  55473. private static _UpdateSelectionTree;
  55474. /**
  55475. * Gets or sets a boolean which defines if optimization octree has to be updated
  55476. */
  55477. /**
  55478. * Gets or sets a boolean which defines if optimization octree has to be updated
  55479. */
  55480. static UpdateSelectionTree: boolean;
  55481. /**
  55482. * Gets a string describing the action executed by the current optimization
  55483. * @return description string
  55484. */
  55485. getDescription(): string;
  55486. private _canBeMerged;
  55487. /**
  55488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55489. * @param scene defines the current scene where to apply this optimization
  55490. * @param optimizer defines the current optimizer
  55491. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55492. * @returns true if everything that can be done was applied
  55493. */
  55494. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55495. }
  55496. /**
  55497. * Defines a list of options used by SceneOptimizer
  55498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55499. */
  55500. export class SceneOptimizerOptions {
  55501. /**
  55502. * Defines the target frame rate to reach (60 by default)
  55503. */
  55504. targetFrameRate: number;
  55505. /**
  55506. * Defines the interval between two checkes (2000ms by default)
  55507. */
  55508. trackerDuration: number;
  55509. /**
  55510. * Gets the list of optimizations to apply
  55511. */
  55512. optimizations: SceneOptimization[];
  55513. /**
  55514. * Creates a new list of options used by SceneOptimizer
  55515. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55516. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55517. */
  55518. constructor(
  55519. /**
  55520. * Defines the target frame rate to reach (60 by default)
  55521. */
  55522. targetFrameRate?: number,
  55523. /**
  55524. * Defines the interval between two checkes (2000ms by default)
  55525. */
  55526. trackerDuration?: number);
  55527. /**
  55528. * Add a new optimization
  55529. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55530. * @returns the current SceneOptimizerOptions
  55531. */
  55532. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55533. /**
  55534. * Add a new custom optimization
  55535. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55536. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55537. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55538. * @returns the current SceneOptimizerOptions
  55539. */
  55540. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55541. /**
  55542. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55543. * @param targetFrameRate defines the target frame rate (60 by default)
  55544. * @returns a SceneOptimizerOptions object
  55545. */
  55546. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55547. /**
  55548. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55549. * @param targetFrameRate defines the target frame rate (60 by default)
  55550. * @returns a SceneOptimizerOptions object
  55551. */
  55552. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55553. /**
  55554. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55555. * @param targetFrameRate defines the target frame rate (60 by default)
  55556. * @returns a SceneOptimizerOptions object
  55557. */
  55558. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55559. }
  55560. /**
  55561. * Class used to run optimizations in order to reach a target frame rate
  55562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55563. */
  55564. export class SceneOptimizer implements IDisposable {
  55565. private _isRunning;
  55566. private _options;
  55567. private _scene;
  55568. private _currentPriorityLevel;
  55569. private _targetFrameRate;
  55570. private _trackerDuration;
  55571. private _currentFrameRate;
  55572. private _sceneDisposeObserver;
  55573. private _improvementMode;
  55574. /**
  55575. * Defines an observable called when the optimizer reaches the target frame rate
  55576. */
  55577. onSuccessObservable: Observable<SceneOptimizer>;
  55578. /**
  55579. * Defines an observable called when the optimizer enables an optimization
  55580. */
  55581. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55582. /**
  55583. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55584. */
  55585. onFailureObservable: Observable<SceneOptimizer>;
  55586. /**
  55587. * Gets a boolean indicating if the optimizer is in improvement mode
  55588. */
  55589. readonly isInImprovementMode: boolean;
  55590. /**
  55591. * Gets the current priority level (0 at start)
  55592. */
  55593. readonly currentPriorityLevel: number;
  55594. /**
  55595. * Gets the current frame rate checked by the SceneOptimizer
  55596. */
  55597. readonly currentFrameRate: number;
  55598. /**
  55599. * Gets or sets the current target frame rate (60 by default)
  55600. */
  55601. /**
  55602. * Gets or sets the current target frame rate (60 by default)
  55603. */
  55604. targetFrameRate: number;
  55605. /**
  55606. * Gets or sets the current interval between two checks (every 2000ms by default)
  55607. */
  55608. /**
  55609. * Gets or sets the current interval between two checks (every 2000ms by default)
  55610. */
  55611. trackerDuration: number;
  55612. /**
  55613. * Gets the list of active optimizations
  55614. */
  55615. readonly optimizations: SceneOptimization[];
  55616. /**
  55617. * Creates a new SceneOptimizer
  55618. * @param scene defines the scene to work on
  55619. * @param options defines the options to use with the SceneOptimizer
  55620. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55621. * @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)
  55622. */
  55623. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55624. /**
  55625. * Stops the current optimizer
  55626. */
  55627. stop(): void;
  55628. /**
  55629. * Reset the optimizer to initial step (current priority level = 0)
  55630. */
  55631. reset(): void;
  55632. /**
  55633. * Start the optimizer. By default it will try to reach a specific framerate
  55634. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55635. */
  55636. start(): void;
  55637. private _checkCurrentState;
  55638. /**
  55639. * Release all resources
  55640. */
  55641. dispose(): void;
  55642. /**
  55643. * Helper function to create a SceneOptimizer with one single line of code
  55644. * @param scene defines the scene to work on
  55645. * @param options defines the options to use with the SceneOptimizer
  55646. * @param onSuccess defines a callback to call on success
  55647. * @param onFailure defines a callback to call on failure
  55648. * @returns the new SceneOptimizer object
  55649. */
  55650. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55651. }
  55652. }
  55653. declare module "babylonjs/Misc/sceneSerializer" {
  55654. import { Scene } from "babylonjs/scene";
  55655. /**
  55656. * Class used to serialize a scene into a string
  55657. */
  55658. export class SceneSerializer {
  55659. /**
  55660. * Clear cache used by a previous serialization
  55661. */
  55662. static ClearCache(): void;
  55663. /**
  55664. * Serialize a scene into a JSON compatible object
  55665. * @param scene defines the scene to serialize
  55666. * @returns a JSON compatible object
  55667. */
  55668. static Serialize(scene: Scene): any;
  55669. /**
  55670. * Serialize a mesh into a JSON compatible object
  55671. * @param toSerialize defines the mesh to serialize
  55672. * @param withParents defines if parents must be serialized as well
  55673. * @param withChildren defines if children must be serialized as well
  55674. * @returns a JSON compatible object
  55675. */
  55676. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55677. }
  55678. }
  55679. declare module "babylonjs/Misc/videoRecorder" {
  55680. import { Nullable } from "babylonjs/types";
  55681. import { Engine } from "babylonjs/Engines/engine";
  55682. /**
  55683. * This represents the different options avilable for the video capture.
  55684. */
  55685. export interface VideoRecorderOptions {
  55686. /** Defines the mime type of the video */
  55687. mimeType: string;
  55688. /** Defines the video the video should be recorded at */
  55689. fps: number;
  55690. /** Defines the chunk size for the recording data */
  55691. recordChunckSize: number;
  55692. }
  55693. /**
  55694. * This can helps recording videos from BabylonJS.
  55695. * This is based on the available WebRTC functionalities of the browser.
  55696. *
  55697. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55698. */
  55699. export class VideoRecorder {
  55700. private static readonly _defaultOptions;
  55701. /**
  55702. * Returns wehther or not the VideoRecorder is available in your browser.
  55703. * @param engine Defines the Babylon Engine to check the support for
  55704. * @returns true if supported otherwise false
  55705. */
  55706. static IsSupported(engine: Engine): boolean;
  55707. private readonly _options;
  55708. private _canvas;
  55709. private _mediaRecorder;
  55710. private _recordedChunks;
  55711. private _fileName;
  55712. private _resolve;
  55713. private _reject;
  55714. /**
  55715. * True wether a recording is already in progress.
  55716. */
  55717. readonly isRecording: boolean;
  55718. /**
  55719. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55720. * a video file.
  55721. * @param engine Defines the BabylonJS Engine you wish to record
  55722. * @param options Defines options that can be used to customized the capture
  55723. */
  55724. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55725. /**
  55726. * Stops the current recording before the default capture timeout passed in the startRecording
  55727. * functions.
  55728. */
  55729. stopRecording(): void;
  55730. /**
  55731. * Starts recording the canvas for a max duration specified in parameters.
  55732. * @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.
  55733. * @param maxDuration Defines the maximum recording time in seconds.
  55734. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55735. * @return a promise callback at the end of the recording with the video data in Blob.
  55736. */
  55737. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55738. /**
  55739. * Releases internal resources used during the recording.
  55740. */
  55741. dispose(): void;
  55742. private _handleDataAvailable;
  55743. private _handleError;
  55744. private _handleStop;
  55745. }
  55746. }
  55747. declare module "babylonjs/Misc/workerPool" {
  55748. import { IDisposable } from "babylonjs/scene";
  55749. /**
  55750. * Helper class to push actions to a pool of workers.
  55751. */
  55752. export class WorkerPool implements IDisposable {
  55753. private _workerInfos;
  55754. private _pendingActions;
  55755. /**
  55756. * Constructor
  55757. * @param workers Array of workers to use for actions
  55758. */
  55759. constructor(workers: Array<Worker>);
  55760. /**
  55761. * Terminates all workers and clears any pending actions.
  55762. */
  55763. dispose(): void;
  55764. /**
  55765. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55766. * pended until a worker has completed its action.
  55767. * @param action The action to perform. Call onComplete when the action is complete.
  55768. */
  55769. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55770. private _execute;
  55771. }
  55772. }
  55773. declare module "babylonjs/Misc/screenshotTools" {
  55774. import { Camera } from "babylonjs/Cameras/camera";
  55775. import { Engine } from "babylonjs/Engines/engine";
  55776. /**
  55777. * Class containing a set of static utilities functions for screenshots
  55778. */
  55779. export class ScreenshotTools {
  55780. /**
  55781. * Captures a screenshot of the current rendering
  55782. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55783. * @param engine defines the rendering engine
  55784. * @param camera defines the source camera
  55785. * @param size This parameter can be set to a single number or to an object with the
  55786. * following (optional) properties: precision, width, height. If a single number is passed,
  55787. * it will be used for both width and height. If an object is passed, the screenshot size
  55788. * will be derived from the parameters. The precision property is a multiplier allowing
  55789. * rendering at a higher or lower resolution
  55790. * @param successCallback defines the callback receives a single parameter which contains the
  55791. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55792. * src parameter of an <img> to display it
  55793. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55794. * Check your browser for supported MIME types
  55795. */
  55796. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55797. /**
  55798. * Generates an image screenshot from the specified camera.
  55799. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55800. * @param engine The engine to use for rendering
  55801. * @param camera The camera to use for rendering
  55802. * @param size This parameter can be set to a single number or to an object with the
  55803. * following (optional) properties: precision, width, height. If a single number is passed,
  55804. * it will be used for both width and height. If an object is passed, the screenshot size
  55805. * will be derived from the parameters. The precision property is a multiplier allowing
  55806. * rendering at a higher or lower resolution
  55807. * @param successCallback The callback receives a single parameter which contains the
  55808. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55809. * src parameter of an <img> to display it
  55810. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55811. * Check your browser for supported MIME types
  55812. * @param samples Texture samples (default: 1)
  55813. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55814. * @param fileName A name for for the downloaded file.
  55815. */
  55816. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55817. }
  55818. }
  55819. declare module "babylonjs/Misc/index" {
  55820. export * from "babylonjs/Misc/andOrNotEvaluator";
  55821. export * from "babylonjs/Misc/assetsManager";
  55822. export * from "babylonjs/Misc/dds";
  55823. export * from "babylonjs/Misc/decorators";
  55824. export * from "babylonjs/Misc/deferred";
  55825. export * from "babylonjs/Misc/environmentTextureTools";
  55826. export * from "babylonjs/Misc/filesInput";
  55827. export * from "babylonjs/Misc/HighDynamicRange/index";
  55828. export * from "babylonjs/Misc/khronosTextureContainer";
  55829. export * from "babylonjs/Misc/observable";
  55830. export * from "babylonjs/Misc/performanceMonitor";
  55831. export * from "babylonjs/Misc/promise";
  55832. export * from "babylonjs/Misc/sceneOptimizer";
  55833. export * from "babylonjs/Misc/sceneSerializer";
  55834. export * from "babylonjs/Misc/smartArray";
  55835. export * from "babylonjs/Misc/stringDictionary";
  55836. export * from "babylonjs/Misc/tags";
  55837. export * from "babylonjs/Misc/textureTools";
  55838. export * from "babylonjs/Misc/tga";
  55839. export * from "babylonjs/Misc/tools";
  55840. export * from "babylonjs/Misc/videoRecorder";
  55841. export * from "babylonjs/Misc/virtualJoystick";
  55842. export * from "babylonjs/Misc/workerPool";
  55843. export * from "babylonjs/Misc/logger";
  55844. export * from "babylonjs/Misc/typeStore";
  55845. export * from "babylonjs/Misc/filesInputStore";
  55846. export * from "babylonjs/Misc/deepCopier";
  55847. export * from "babylonjs/Misc/pivotTools";
  55848. export * from "babylonjs/Misc/precisionDate";
  55849. export * from "babylonjs/Misc/screenshotTools";
  55850. export * from "babylonjs/Misc/typeStore";
  55851. }
  55852. declare module "babylonjs/index" {
  55853. export * from "babylonjs/abstractScene";
  55854. export * from "babylonjs/Actions/index";
  55855. export * from "babylonjs/Animations/index";
  55856. export * from "babylonjs/assetContainer";
  55857. export * from "babylonjs/Audio/index";
  55858. export * from "babylonjs/Behaviors/index";
  55859. export * from "babylonjs/Bones/index";
  55860. export * from "babylonjs/Cameras/index";
  55861. export * from "babylonjs/Collisions/index";
  55862. export * from "babylonjs/Culling/index";
  55863. export * from "babylonjs/Debug/index";
  55864. export * from "babylonjs/Engines/index";
  55865. export * from "babylonjs/Events/index";
  55866. export * from "babylonjs/Gamepads/index";
  55867. export * from "babylonjs/Gizmos/index";
  55868. export * from "babylonjs/Helpers/index";
  55869. export * from "babylonjs/Instrumentation/index";
  55870. export * from "babylonjs/Layers/index";
  55871. export * from "babylonjs/LensFlares/index";
  55872. export * from "babylonjs/Lights/index";
  55873. export * from "babylonjs/Loading/index";
  55874. export * from "babylonjs/Materials/index";
  55875. export * from "babylonjs/Maths/index";
  55876. export * from "babylonjs/Meshes/index";
  55877. export * from "babylonjs/Morph/index";
  55878. export * from "babylonjs/node";
  55879. export * from "babylonjs/Offline/index";
  55880. export * from "babylonjs/Particles/index";
  55881. export * from "babylonjs/Physics/index";
  55882. export * from "babylonjs/PostProcesses/index";
  55883. export * from "babylonjs/Probes/index";
  55884. export * from "babylonjs/Rendering/index";
  55885. export * from "babylonjs/scene";
  55886. export * from "babylonjs/sceneComponent";
  55887. export * from "babylonjs/Sprites/index";
  55888. export * from "babylonjs/States/index";
  55889. export * from "babylonjs/Misc/index";
  55890. export * from "babylonjs/types";
  55891. }
  55892. declare module "babylonjs/Animations/pathCursor" {
  55893. import { Path2, Vector3 } from "babylonjs/Maths/math";
  55894. /**
  55895. * A cursor which tracks a point on a path
  55896. */
  55897. export class PathCursor {
  55898. private path;
  55899. /**
  55900. * Stores path cursor callbacks for when an onchange event is triggered
  55901. */
  55902. private _onchange;
  55903. /**
  55904. * The value of the path cursor
  55905. */
  55906. value: number;
  55907. /**
  55908. * The animation array of the path cursor
  55909. */
  55910. animations: Animation[];
  55911. /**
  55912. * Initializes the path cursor
  55913. * @param path The path to track
  55914. */
  55915. constructor(path: Path2);
  55916. /**
  55917. * Gets the cursor point on the path
  55918. * @returns A point on the path cursor at the cursor location
  55919. */
  55920. getPoint(): Vector3;
  55921. /**
  55922. * Moves the cursor ahead by the step amount
  55923. * @param step The amount to move the cursor forward
  55924. * @returns This path cursor
  55925. */
  55926. moveAhead(step?: number): PathCursor;
  55927. /**
  55928. * Moves the cursor behind by the step amount
  55929. * @param step The amount to move the cursor back
  55930. * @returns This path cursor
  55931. */
  55932. moveBack(step?: number): PathCursor;
  55933. /**
  55934. * Moves the cursor by the step amount
  55935. * If the step amount is greater than one, an exception is thrown
  55936. * @param step The amount to move the cursor
  55937. * @returns This path cursor
  55938. */
  55939. move(step: number): PathCursor;
  55940. /**
  55941. * Ensures that the value is limited between zero and one
  55942. * @returns This path cursor
  55943. */
  55944. private ensureLimits;
  55945. /**
  55946. * Runs onchange callbacks on change (used by the animation engine)
  55947. * @returns This path cursor
  55948. */
  55949. private raiseOnChange;
  55950. /**
  55951. * Executes a function on change
  55952. * @param f A path cursor onchange callback
  55953. * @returns This path cursor
  55954. */
  55955. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55956. }
  55957. }
  55958. declare module "babylonjs/Legacy/legacy" {
  55959. export * from "babylonjs/index";
  55960. }
  55961. declare module "babylonjs/Shaders/blur.fragment" {
  55962. /** @hidden */
  55963. export var blurPixelShader: {
  55964. name: string;
  55965. shader: string;
  55966. };
  55967. }
  55968. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55969. /** @hidden */
  55970. export var bones300Declaration: {
  55971. name: string;
  55972. shader: string;
  55973. };
  55974. }
  55975. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55976. /** @hidden */
  55977. export var instances300Declaration: {
  55978. name: string;
  55979. shader: string;
  55980. };
  55981. }
  55982. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55983. /** @hidden */
  55984. export var pointCloudVertexDeclaration: {
  55985. name: string;
  55986. shader: string;
  55987. };
  55988. }
  55989. // Mixins
  55990. interface Window {
  55991. mozIndexedDB: IDBFactory;
  55992. webkitIndexedDB: IDBFactory;
  55993. msIndexedDB: IDBFactory;
  55994. webkitURL: typeof URL;
  55995. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55996. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55997. WebGLRenderingContext: WebGLRenderingContext;
  55998. MSGesture: MSGesture;
  55999. CANNON: any;
  56000. AudioContext: AudioContext;
  56001. webkitAudioContext: AudioContext;
  56002. PointerEvent: any;
  56003. Math: Math;
  56004. Uint8Array: Uint8ArrayConstructor;
  56005. Float32Array: Float32ArrayConstructor;
  56006. mozURL: typeof URL;
  56007. msURL: typeof URL;
  56008. VRFrameData: any; // WebVR, from specs 1.1
  56009. DracoDecoderModule: any;
  56010. setImmediate(handler: (...args: any[]) => void): number;
  56011. }
  56012. interface Document {
  56013. mozCancelFullScreen(): void;
  56014. msCancelFullScreen(): void;
  56015. webkitCancelFullScreen(): void;
  56016. requestPointerLock(): void;
  56017. exitPointerLock(): void;
  56018. mozFullScreen: boolean;
  56019. msIsFullScreen: boolean;
  56020. readonly webkitIsFullScreen: boolean;
  56021. readonly pointerLockElement: Element;
  56022. mozPointerLockElement: HTMLElement;
  56023. msPointerLockElement: HTMLElement;
  56024. webkitPointerLockElement: HTMLElement;
  56025. }
  56026. interface HTMLCanvasElement {
  56027. requestPointerLock(): void;
  56028. msRequestPointerLock?(): void;
  56029. mozRequestPointerLock?(): void;
  56030. webkitRequestPointerLock?(): void;
  56031. /** Track wether a record is in progress */
  56032. isRecording: boolean;
  56033. /** Capture Stream method defined by some browsers */
  56034. captureStream(fps?: number): MediaStream;
  56035. }
  56036. interface CanvasRenderingContext2D {
  56037. msImageSmoothingEnabled: boolean;
  56038. }
  56039. interface MouseEvent {
  56040. mozMovementX: number;
  56041. mozMovementY: number;
  56042. webkitMovementX: number;
  56043. webkitMovementY: number;
  56044. msMovementX: number;
  56045. msMovementY: number;
  56046. }
  56047. interface Navigator {
  56048. mozGetVRDevices: (any: any) => any;
  56049. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56050. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56051. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56052. webkitGetGamepads(): Gamepad[];
  56053. msGetGamepads(): Gamepad[];
  56054. webkitGamepads(): Gamepad[];
  56055. }
  56056. interface HTMLVideoElement {
  56057. mozSrcObject: any;
  56058. }
  56059. interface Math {
  56060. fround(x: number): number;
  56061. imul(a: number, b: number): number;
  56062. }
  56063. interface WebGLProgram {
  56064. context?: WebGLRenderingContext;
  56065. vertexShader?: WebGLShader;
  56066. fragmentShader?: WebGLShader;
  56067. isParallelCompiled: boolean;
  56068. onCompiled?: () => void;
  56069. }
  56070. interface WebGLRenderingContext {
  56071. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56072. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56073. vertexAttribDivisor(index: number, divisor: number): void;
  56074. createVertexArray(): any;
  56075. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56076. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56077. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56078. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56079. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56080. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56081. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56082. // Queries
  56083. createQuery(): WebGLQuery;
  56084. deleteQuery(query: WebGLQuery): void;
  56085. beginQuery(target: number, query: WebGLQuery): void;
  56086. endQuery(target: number): void;
  56087. getQueryParameter(query: WebGLQuery, pname: number): any;
  56088. getQuery(target: number, pname: number): any;
  56089. MAX_SAMPLES: number;
  56090. RGBA8: number;
  56091. READ_FRAMEBUFFER: number;
  56092. DRAW_FRAMEBUFFER: number;
  56093. UNIFORM_BUFFER: number;
  56094. HALF_FLOAT_OES: number;
  56095. RGBA16F: number;
  56096. RGBA32F: number;
  56097. R32F: number;
  56098. RG32F: number;
  56099. RGB32F: number;
  56100. R16F: number;
  56101. RG16F: number;
  56102. RGB16F: number;
  56103. RED: number;
  56104. RG: number;
  56105. R8: number;
  56106. RG8: number;
  56107. UNSIGNED_INT_24_8: number;
  56108. DEPTH24_STENCIL8: number;
  56109. /* Multiple Render Targets */
  56110. drawBuffers(buffers: number[]): void;
  56111. readBuffer(src: number): void;
  56112. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56113. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56114. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56115. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56116. // Occlusion Query
  56117. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56118. ANY_SAMPLES_PASSED: number;
  56119. QUERY_RESULT_AVAILABLE: number;
  56120. QUERY_RESULT: number;
  56121. }
  56122. interface WebGLBuffer {
  56123. references: number;
  56124. capacity: number;
  56125. is32Bits: boolean;
  56126. }
  56127. interface WebGLProgram {
  56128. transformFeedback?: WebGLTransformFeedback | null;
  56129. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56130. }
  56131. interface EXT_disjoint_timer_query {
  56132. QUERY_COUNTER_BITS_EXT: number;
  56133. TIME_ELAPSED_EXT: number;
  56134. TIMESTAMP_EXT: number;
  56135. GPU_DISJOINT_EXT: number;
  56136. QUERY_RESULT_EXT: number;
  56137. QUERY_RESULT_AVAILABLE_EXT: number;
  56138. queryCounterEXT(query: WebGLQuery, target: number): void;
  56139. createQueryEXT(): WebGLQuery;
  56140. beginQueryEXT(target: number, query: WebGLQuery): void;
  56141. endQueryEXT(target: number): void;
  56142. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56143. deleteQueryEXT(query: WebGLQuery): void;
  56144. }
  56145. interface WebGLUniformLocation {
  56146. _currentState: any;
  56147. }
  56148. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56149. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56150. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56151. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56152. interface WebGLRenderingContext {
  56153. readonly RASTERIZER_DISCARD: number;
  56154. readonly DEPTH_COMPONENT24: number;
  56155. readonly TEXTURE_3D: number;
  56156. readonly TEXTURE_2D_ARRAY: number;
  56157. readonly TEXTURE_COMPARE_FUNC: number;
  56158. readonly TEXTURE_COMPARE_MODE: number;
  56159. readonly COMPARE_REF_TO_TEXTURE: number;
  56160. readonly TEXTURE_WRAP_R: number;
  56161. readonly HALF_FLOAT: number;
  56162. readonly RGB8: number;
  56163. readonly RED_INTEGER: number;
  56164. readonly RG_INTEGER: number;
  56165. readonly RGB_INTEGER: number;
  56166. readonly RGBA_INTEGER: number;
  56167. readonly R8_SNORM: number;
  56168. readonly RG8_SNORM: number;
  56169. readonly RGB8_SNORM: number;
  56170. readonly RGBA8_SNORM: number;
  56171. readonly R8I: number;
  56172. readonly RG8I: number;
  56173. readonly RGB8I: number;
  56174. readonly RGBA8I: number;
  56175. readonly R8UI: number;
  56176. readonly RG8UI: number;
  56177. readonly RGB8UI: number;
  56178. readonly RGBA8UI: number;
  56179. readonly R16I: number;
  56180. readonly RG16I: number;
  56181. readonly RGB16I: number;
  56182. readonly RGBA16I: number;
  56183. readonly R16UI: number;
  56184. readonly RG16UI: number;
  56185. readonly RGB16UI: number;
  56186. readonly RGBA16UI: number;
  56187. readonly R32I: number;
  56188. readonly RG32I: number;
  56189. readonly RGB32I: number;
  56190. readonly RGBA32I: number;
  56191. readonly R32UI: number;
  56192. readonly RG32UI: number;
  56193. readonly RGB32UI: number;
  56194. readonly RGBA32UI: number;
  56195. readonly RGB10_A2UI: number;
  56196. readonly R11F_G11F_B10F: number;
  56197. readonly RGB9_E5: number;
  56198. readonly RGB10_A2: number;
  56199. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56200. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56201. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56202. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56203. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56204. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56205. 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;
  56206. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56207. readonly TRANSFORM_FEEDBACK: number;
  56208. readonly INTERLEAVED_ATTRIBS: number;
  56209. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56210. createTransformFeedback(): WebGLTransformFeedback;
  56211. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56212. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56213. beginTransformFeedback(primitiveMode: number): void;
  56214. endTransformFeedback(): void;
  56215. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56216. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56217. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56218. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56219. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56220. }
  56221. interface ImageBitmap {
  56222. readonly width: number;
  56223. readonly height: number;
  56224. close(): void;
  56225. }
  56226. interface WebGLQuery extends WebGLObject {
  56227. }
  56228. declare var WebGLQuery: {
  56229. prototype: WebGLQuery;
  56230. new(): WebGLQuery;
  56231. };
  56232. interface WebGLSampler extends WebGLObject {
  56233. }
  56234. declare var WebGLSampler: {
  56235. prototype: WebGLSampler;
  56236. new(): WebGLSampler;
  56237. };
  56238. interface WebGLSync extends WebGLObject {
  56239. }
  56240. declare var WebGLSync: {
  56241. prototype: WebGLSync;
  56242. new(): WebGLSync;
  56243. };
  56244. interface WebGLTransformFeedback extends WebGLObject {
  56245. }
  56246. declare var WebGLTransformFeedback: {
  56247. prototype: WebGLTransformFeedback;
  56248. new(): WebGLTransformFeedback;
  56249. };
  56250. interface WebGLVertexArrayObject extends WebGLObject {
  56251. }
  56252. declare var WebGLVertexArrayObject: {
  56253. prototype: WebGLVertexArrayObject;
  56254. new(): WebGLVertexArrayObject;
  56255. };
  56256. // Type definitions for WebVR API
  56257. // Project: https://w3c.github.io/webvr/
  56258. // Definitions by: six a <https://github.com/lostfictions>
  56259. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56260. interface VRDisplay extends EventTarget {
  56261. /**
  56262. * Dictionary of capabilities describing the VRDisplay.
  56263. */
  56264. readonly capabilities: VRDisplayCapabilities;
  56265. /**
  56266. * z-depth defining the far plane of the eye view frustum
  56267. * enables mapping of values in the render target depth
  56268. * attachment to scene coordinates. Initially set to 10000.0.
  56269. */
  56270. depthFar: number;
  56271. /**
  56272. * z-depth defining the near plane of the eye view frustum
  56273. * enables mapping of values in the render target depth
  56274. * attachment to scene coordinates. Initially set to 0.01.
  56275. */
  56276. depthNear: number;
  56277. /**
  56278. * An identifier for this distinct VRDisplay. Used as an
  56279. * association point in the Gamepad API.
  56280. */
  56281. readonly displayId: number;
  56282. /**
  56283. * A display name, a user-readable name identifying it.
  56284. */
  56285. readonly displayName: string;
  56286. readonly isConnected: boolean;
  56287. readonly isPresenting: boolean;
  56288. /**
  56289. * If this VRDisplay supports room-scale experiences, the optional
  56290. * stage attribute contains details on the room-scale parameters.
  56291. */
  56292. readonly stageParameters: VRStageParameters | null;
  56293. /**
  56294. * Passing the value returned by `requestAnimationFrame` to
  56295. * `cancelAnimationFrame` will unregister the callback.
  56296. * @param handle Define the hanle of the request to cancel
  56297. */
  56298. cancelAnimationFrame(handle: number): void;
  56299. /**
  56300. * Stops presenting to the VRDisplay.
  56301. * @returns a promise to know when it stopped
  56302. */
  56303. exitPresent(): Promise<void>;
  56304. /**
  56305. * Return the current VREyeParameters for the given eye.
  56306. * @param whichEye Define the eye we want the parameter for
  56307. * @returns the eye parameters
  56308. */
  56309. getEyeParameters(whichEye: string): VREyeParameters;
  56310. /**
  56311. * Populates the passed VRFrameData with the information required to render
  56312. * the current frame.
  56313. * @param frameData Define the data structure to populate
  56314. * @returns true if ok otherwise false
  56315. */
  56316. getFrameData(frameData: VRFrameData): boolean;
  56317. /**
  56318. * Get the layers currently being presented.
  56319. * @returns the list of VR layers
  56320. */
  56321. getLayers(): VRLayer[];
  56322. /**
  56323. * Return a VRPose containing the future predicted pose of the VRDisplay
  56324. * when the current frame will be presented. The value returned will not
  56325. * change until JavaScript has returned control to the browser.
  56326. *
  56327. * The VRPose will contain the position, orientation, velocity,
  56328. * and acceleration of each of these properties.
  56329. * @returns the pose object
  56330. */
  56331. getPose(): VRPose;
  56332. /**
  56333. * Return the current instantaneous pose of the VRDisplay, with no
  56334. * prediction applied.
  56335. * @returns the current instantaneous pose
  56336. */
  56337. getImmediatePose(): VRPose;
  56338. /**
  56339. * The callback passed to `requestAnimationFrame` will be called
  56340. * any time a new frame should be rendered. When the VRDisplay is
  56341. * presenting the callback will be called at the native refresh
  56342. * rate of the HMD. When not presenting this function acts
  56343. * identically to how window.requestAnimationFrame acts. Content should
  56344. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56345. * asynchronously from other displays and at differing refresh rates.
  56346. * @param callback Define the eaction to run next frame
  56347. * @returns the request handle it
  56348. */
  56349. requestAnimationFrame(callback: FrameRequestCallback): number;
  56350. /**
  56351. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56352. * Repeat calls while already presenting will update the VRLayers being displayed.
  56353. * @param layers Define the list of layer to present
  56354. * @returns a promise to know when the request has been fulfilled
  56355. */
  56356. requestPresent(layers: VRLayer[]): Promise<void>;
  56357. /**
  56358. * Reset the pose for this display, treating its current position and
  56359. * orientation as the "origin/zero" values. VRPose.position,
  56360. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56361. * updated when calling resetPose(). This should be called in only
  56362. * sitting-space experiences.
  56363. */
  56364. resetPose(): void;
  56365. /**
  56366. * The VRLayer provided to the VRDisplay will be captured and presented
  56367. * in the HMD. Calling this function has the same effect on the source
  56368. * canvas as any other operation that uses its source image, and canvases
  56369. * created without preserveDrawingBuffer set to true will be cleared.
  56370. * @param pose Define the pose to submit
  56371. */
  56372. submitFrame(pose?: VRPose): void;
  56373. }
  56374. declare var VRDisplay: {
  56375. prototype: VRDisplay;
  56376. new(): VRDisplay;
  56377. };
  56378. interface VRLayer {
  56379. leftBounds?: number[] | Float32Array | null;
  56380. rightBounds?: number[] | Float32Array | null;
  56381. source?: HTMLCanvasElement | null;
  56382. }
  56383. interface VRDisplayCapabilities {
  56384. readonly canPresent: boolean;
  56385. readonly hasExternalDisplay: boolean;
  56386. readonly hasOrientation: boolean;
  56387. readonly hasPosition: boolean;
  56388. readonly maxLayers: number;
  56389. }
  56390. interface VREyeParameters {
  56391. /** @deprecated */
  56392. readonly fieldOfView: VRFieldOfView;
  56393. readonly offset: Float32Array;
  56394. readonly renderHeight: number;
  56395. readonly renderWidth: number;
  56396. }
  56397. interface VRFieldOfView {
  56398. readonly downDegrees: number;
  56399. readonly leftDegrees: number;
  56400. readonly rightDegrees: number;
  56401. readonly upDegrees: number;
  56402. }
  56403. interface VRFrameData {
  56404. readonly leftProjectionMatrix: Float32Array;
  56405. readonly leftViewMatrix: Float32Array;
  56406. readonly pose: VRPose;
  56407. readonly rightProjectionMatrix: Float32Array;
  56408. readonly rightViewMatrix: Float32Array;
  56409. readonly timestamp: number;
  56410. }
  56411. interface VRPose {
  56412. readonly angularAcceleration: Float32Array | null;
  56413. readonly angularVelocity: Float32Array | null;
  56414. readonly linearAcceleration: Float32Array | null;
  56415. readonly linearVelocity: Float32Array | null;
  56416. readonly orientation: Float32Array | null;
  56417. readonly position: Float32Array | null;
  56418. readonly timestamp: number;
  56419. }
  56420. interface VRStageParameters {
  56421. sittingToStandingTransform?: Float32Array;
  56422. sizeX?: number;
  56423. sizeY?: number;
  56424. }
  56425. interface Navigator {
  56426. getVRDisplays(): Promise<VRDisplay[]>;
  56427. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56428. }
  56429. interface Window {
  56430. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56431. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56432. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56433. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56434. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56435. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56436. }
  56437. interface Gamepad {
  56438. readonly displayId: number;
  56439. }
  56440. interface XRDevice {
  56441. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56442. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56443. }
  56444. interface XRSession {
  56445. getInputSources(): Array<any>;
  56446. baseLayer: XRWebGLLayer;
  56447. requestFrameOfReference(type: string): Promise<void>;
  56448. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56449. end(): Promise<void>;
  56450. requestAnimationFrame: Function;
  56451. addEventListener: Function;
  56452. }
  56453. interface XRSessionCreationOptions {
  56454. outputContext?: WebGLRenderingContext | null;
  56455. immersive?: boolean;
  56456. environmentIntegration?: boolean;
  56457. }
  56458. interface XRLayer {
  56459. getViewport: Function;
  56460. framebufferWidth: number;
  56461. framebufferHeight: number;
  56462. }
  56463. interface XRView {
  56464. projectionMatrix: Float32Array;
  56465. }
  56466. interface XRFrame {
  56467. getDevicePose: Function;
  56468. getInputPose: Function;
  56469. views: Array<XRView>;
  56470. baseLayer: XRLayer;
  56471. }
  56472. interface XRFrameOfReference {
  56473. }
  56474. interface XRWebGLLayer extends XRLayer {
  56475. framebuffer: WebGLFramebuffer;
  56476. }
  56477. declare var XRWebGLLayer: {
  56478. prototype: XRWebGLLayer;
  56479. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56480. };
  56481. declare module "babylonjs" {
  56482. export * from "babylonjs/Legacy/legacy";
  56483. }
  56484. declare module BABYLON {
  56485. /** Alias type for value that can be null */
  56486. export type Nullable<T> = T | null;
  56487. /**
  56488. * Alias type for number that are floats
  56489. * @ignorenaming
  56490. */
  56491. export type float = number;
  56492. /**
  56493. * Alias type for number that are doubles.
  56494. * @ignorenaming
  56495. */
  56496. export type double = number;
  56497. /**
  56498. * Alias type for number that are integer
  56499. * @ignorenaming
  56500. */
  56501. export type int = number;
  56502. /** Alias type for number array or Float32Array */
  56503. export type FloatArray = number[] | Float32Array;
  56504. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56505. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56506. /**
  56507. * Alias for types that can be used by a Buffer or VertexBuffer.
  56508. */
  56509. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56510. /**
  56511. * Alias type for primitive types
  56512. * @ignorenaming
  56513. */
  56514. type Primitive = undefined | null | boolean | string | number | Function;
  56515. /**
  56516. * Type modifier to make all the properties of an object Readonly
  56517. */
  56518. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56519. /**
  56520. * Type modifier to make all the properties of an object Readonly recursively
  56521. */
  56522. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56523. /** @hidden */
  56524. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56525. }
  56526. /** @hidden */
  56527. /** @hidden */
  56528. type DeepImmutableObject<T> = {
  56529. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56530. };
  56531. }
  56532. declare module BABYLON {
  56533. /**
  56534. * Class containing a set of static utilities functions for arrays.
  56535. */
  56536. export class ArrayTools {
  56537. /**
  56538. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56539. * @param size the number of element to construct and put in the array
  56540. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56541. * @returns a new array filled with new objects
  56542. */
  56543. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56544. }
  56545. }
  56546. declare module BABYLON {
  56547. /**
  56548. * Scalar computation library
  56549. */
  56550. export class Scalar {
  56551. /**
  56552. * Two pi constants convenient for computation.
  56553. */
  56554. static TwoPi: number;
  56555. /**
  56556. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56557. * @param a number
  56558. * @param b number
  56559. * @param epsilon (default = 1.401298E-45)
  56560. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56561. */
  56562. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  56563. /**
  56564. * Returns a string : the upper case translation of the number i to hexadecimal.
  56565. * @param i number
  56566. * @returns the upper case translation of the number i to hexadecimal.
  56567. */
  56568. static ToHex(i: number): string;
  56569. /**
  56570. * Returns -1 if value is negative and +1 is value is positive.
  56571. * @param value the value
  56572. * @returns the value itself if it's equal to zero.
  56573. */
  56574. static Sign(value: number): number;
  56575. /**
  56576. * Returns the value itself if it's between min and max.
  56577. * Returns min if the value is lower than min.
  56578. * Returns max if the value is greater than max.
  56579. * @param value the value to clmap
  56580. * @param min the min value to clamp to (default: 0)
  56581. * @param max the max value to clamp to (default: 1)
  56582. * @returns the clamped value
  56583. */
  56584. static Clamp(value: number, min?: number, max?: number): number;
  56585. /**
  56586. * the log2 of value.
  56587. * @param value the value to compute log2 of
  56588. * @returns the log2 of value.
  56589. */
  56590. static Log2(value: number): number;
  56591. /**
  56592. * Loops the value, so that it is never larger than length and never smaller than 0.
  56593. *
  56594. * This is similar to the modulo operator but it works with floating point numbers.
  56595. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56596. * With t = 5 and length = 2.5, the result would be 0.0.
  56597. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56598. * @param value the value
  56599. * @param length the length
  56600. * @returns the looped value
  56601. */
  56602. static Repeat(value: number, length: number): number;
  56603. /**
  56604. * Normalize the value between 0.0 and 1.0 using min and max values
  56605. * @param value value to normalize
  56606. * @param min max to normalize between
  56607. * @param max min to normalize between
  56608. * @returns the normalized value
  56609. */
  56610. static Normalize(value: number, min: number, max: number): number;
  56611. /**
  56612. * Denormalize the value from 0.0 and 1.0 using min and max values
  56613. * @param normalized value to denormalize
  56614. * @param min max to denormalize between
  56615. * @param max min to denormalize between
  56616. * @returns the denormalized value
  56617. */
  56618. static Denormalize(normalized: number, min: number, max: number): number;
  56619. /**
  56620. * Calculates the shortest difference between two given angles given in degrees.
  56621. * @param current current angle in degrees
  56622. * @param target target angle in degrees
  56623. * @returns the delta
  56624. */
  56625. static DeltaAngle(current: number, target: number): number;
  56626. /**
  56627. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56628. * @param tx value
  56629. * @param length length
  56630. * @returns The returned value will move back and forth between 0 and length
  56631. */
  56632. static PingPong(tx: number, length: number): number;
  56633. /**
  56634. * Interpolates between min and max with smoothing at the limits.
  56635. *
  56636. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56637. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56638. * @param from from
  56639. * @param to to
  56640. * @param tx value
  56641. * @returns the smooth stepped value
  56642. */
  56643. static SmoothStep(from: number, to: number, tx: number): number;
  56644. /**
  56645. * Moves a value current towards target.
  56646. *
  56647. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56648. * Negative values of maxDelta pushes the value away from target.
  56649. * @param current current value
  56650. * @param target target value
  56651. * @param maxDelta max distance to move
  56652. * @returns resulting value
  56653. */
  56654. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56655. /**
  56656. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56657. *
  56658. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56659. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56660. * @param current current value
  56661. * @param target target value
  56662. * @param maxDelta max distance to move
  56663. * @returns resulting angle
  56664. */
  56665. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56666. /**
  56667. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56668. * @param start start value
  56669. * @param end target value
  56670. * @param amount amount to lerp between
  56671. * @returns the lerped value
  56672. */
  56673. static Lerp(start: number, end: number, amount: number): number;
  56674. /**
  56675. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56676. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56677. * @param start start value
  56678. * @param end target value
  56679. * @param amount amount to lerp between
  56680. * @returns the lerped value
  56681. */
  56682. static LerpAngle(start: number, end: number, amount: number): number;
  56683. /**
  56684. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56685. * @param a start value
  56686. * @param b target value
  56687. * @param value value between a and b
  56688. * @returns the inverseLerp value
  56689. */
  56690. static InverseLerp(a: number, b: number, value: number): number;
  56691. /**
  56692. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  56693. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  56694. * @param value1 spline value
  56695. * @param tangent1 spline value
  56696. * @param value2 spline value
  56697. * @param tangent2 spline value
  56698. * @param amount input value
  56699. * @returns hermite result
  56700. */
  56701. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  56702. /**
  56703. * Returns a random float number between and min and max values
  56704. * @param min min value of random
  56705. * @param max max value of random
  56706. * @returns random value
  56707. */
  56708. static RandomRange(min: number, max: number): number;
  56709. /**
  56710. * This function returns percentage of a number in a given range.
  56711. *
  56712. * RangeToPercent(40,20,60) will return 0.5 (50%)
  56713. * RangeToPercent(34,0,100) will return 0.34 (34%)
  56714. * @param number to convert to percentage
  56715. * @param min min range
  56716. * @param max max range
  56717. * @returns the percentage
  56718. */
  56719. static RangeToPercent(number: number, min: number, max: number): number;
  56720. /**
  56721. * This function returns number that corresponds to the percentage in a given range.
  56722. *
  56723. * PercentToRange(0.34,0,100) will return 34.
  56724. * @param percent to convert to number
  56725. * @param min min range
  56726. * @param max max range
  56727. * @returns the number
  56728. */
  56729. static PercentToRange(percent: number, min: number, max: number): number;
  56730. /**
  56731. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  56732. * @param angle The angle to normalize in radian.
  56733. * @return The converted angle.
  56734. */
  56735. static NormalizeRadians(angle: number): number;
  56736. }
  56737. }
  56738. declare module BABYLON {
  56739. /**
  56740. * Constant used to convert a value to gamma space
  56741. * @ignorenaming
  56742. */
  56743. export const ToGammaSpace: number;
  56744. /**
  56745. * Constant used to convert a value to linear space
  56746. * @ignorenaming
  56747. */
  56748. export const ToLinearSpace = 2.2;
  56749. /**
  56750. * Constant used to define the minimal number value in Babylon.js
  56751. * @ignorenaming
  56752. */
  56753. export const Epsilon = 0.001;
  56754. /**
  56755. * Class used to hold a RBG color
  56756. */
  56757. export class Color3 {
  56758. /**
  56759. * Defines the red component (between 0 and 1, default is 0)
  56760. */
  56761. r: number;
  56762. /**
  56763. * Defines the green component (between 0 and 1, default is 0)
  56764. */
  56765. g: number;
  56766. /**
  56767. * Defines the blue component (between 0 and 1, default is 0)
  56768. */
  56769. b: number;
  56770. /**
  56771. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  56772. * @param r defines the red component (between 0 and 1, default is 0)
  56773. * @param g defines the green component (between 0 and 1, default is 0)
  56774. * @param b defines the blue component (between 0 and 1, default is 0)
  56775. */
  56776. constructor(
  56777. /**
  56778. * Defines the red component (between 0 and 1, default is 0)
  56779. */
  56780. r?: number,
  56781. /**
  56782. * Defines the green component (between 0 and 1, default is 0)
  56783. */
  56784. g?: number,
  56785. /**
  56786. * Defines the blue component (between 0 and 1, default is 0)
  56787. */
  56788. b?: number);
  56789. /**
  56790. * Creates a string with the Color3 current values
  56791. * @returns the string representation of the Color3 object
  56792. */
  56793. toString(): string;
  56794. /**
  56795. * Returns the string "Color3"
  56796. * @returns "Color3"
  56797. */
  56798. getClassName(): string;
  56799. /**
  56800. * Compute the Color3 hash code
  56801. * @returns an unique number that can be used to hash Color3 objects
  56802. */
  56803. getHashCode(): number;
  56804. /**
  56805. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  56806. * @param array defines the array where to store the r,g,b components
  56807. * @param index defines an optional index in the target array to define where to start storing values
  56808. * @returns the current Color3 object
  56809. */
  56810. toArray(array: FloatArray, index?: number): Color3;
  56811. /**
  56812. * Returns a new Color4 object from the current Color3 and the given alpha
  56813. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  56814. * @returns a new Color4 object
  56815. */
  56816. toColor4(alpha?: number): Color4;
  56817. /**
  56818. * Returns a new array populated with 3 numeric elements : red, green and blue values
  56819. * @returns the new array
  56820. */
  56821. asArray(): number[];
  56822. /**
  56823. * Returns the luminance value
  56824. * @returns a float value
  56825. */
  56826. toLuminance(): number;
  56827. /**
  56828. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  56829. * @param otherColor defines the second operand
  56830. * @returns the new Color3 object
  56831. */
  56832. multiply(otherColor: DeepImmutable<Color3>): Color3;
  56833. /**
  56834. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  56835. * @param otherColor defines the second operand
  56836. * @param result defines the Color3 object where to store the result
  56837. * @returns the current Color3
  56838. */
  56839. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56840. /**
  56841. * Determines equality between Color3 objects
  56842. * @param otherColor defines the second operand
  56843. * @returns true if the rgb values are equal to the given ones
  56844. */
  56845. equals(otherColor: DeepImmutable<Color3>): boolean;
  56846. /**
  56847. * Determines equality between the current Color3 object and a set of r,b,g values
  56848. * @param r defines the red component to check
  56849. * @param g defines the green component to check
  56850. * @param b defines the blue component to check
  56851. * @returns true if the rgb values are equal to the given ones
  56852. */
  56853. equalsFloats(r: number, g: number, b: number): boolean;
  56854. /**
  56855. * Multiplies in place each rgb value by scale
  56856. * @param scale defines the scaling factor
  56857. * @returns the updated Color3
  56858. */
  56859. scale(scale: number): Color3;
  56860. /**
  56861. * Multiplies the rgb values by scale and stores the result into "result"
  56862. * @param scale defines the scaling factor
  56863. * @param result defines the Color3 object where to store the result
  56864. * @returns the unmodified current Color3
  56865. */
  56866. scaleToRef(scale: number, result: Color3): Color3;
  56867. /**
  56868. * Scale the current Color3 values by a factor and add the result to a given Color3
  56869. * @param scale defines the scale factor
  56870. * @param result defines color to store the result into
  56871. * @returns the unmodified current Color3
  56872. */
  56873. scaleAndAddToRef(scale: number, result: Color3): Color3;
  56874. /**
  56875. * Clamps the rgb values by the min and max values and stores the result into "result"
  56876. * @param min defines minimum clamping value (default is 0)
  56877. * @param max defines maximum clamping value (default is 1)
  56878. * @param result defines color to store the result into
  56879. * @returns the original Color3
  56880. */
  56881. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  56882. /**
  56883. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  56884. * @param otherColor defines the second operand
  56885. * @returns the new Color3
  56886. */
  56887. add(otherColor: DeepImmutable<Color3>): Color3;
  56888. /**
  56889. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  56890. * @param otherColor defines the second operand
  56891. * @param result defines Color3 object to store the result into
  56892. * @returns the unmodified current Color3
  56893. */
  56894. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56895. /**
  56896. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  56897. * @param otherColor defines the second operand
  56898. * @returns the new Color3
  56899. */
  56900. subtract(otherColor: DeepImmutable<Color3>): Color3;
  56901. /**
  56902. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  56903. * @param otherColor defines the second operand
  56904. * @param result defines Color3 object to store the result into
  56905. * @returns the unmodified current Color3
  56906. */
  56907. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56908. /**
  56909. * Copy the current object
  56910. * @returns a new Color3 copied the current one
  56911. */
  56912. clone(): Color3;
  56913. /**
  56914. * Copies the rgb values from the source in the current Color3
  56915. * @param source defines the source Color3 object
  56916. * @returns the updated Color3 object
  56917. */
  56918. copyFrom(source: DeepImmutable<Color3>): Color3;
  56919. /**
  56920. * Updates the Color3 rgb values from the given floats
  56921. * @param r defines the red component to read from
  56922. * @param g defines the green component to read from
  56923. * @param b defines the blue component to read from
  56924. * @returns the current Color3 object
  56925. */
  56926. copyFromFloats(r: number, g: number, b: number): Color3;
  56927. /**
  56928. * Updates the Color3 rgb values from the given floats
  56929. * @param r defines the red component to read from
  56930. * @param g defines the green component to read from
  56931. * @param b defines the blue component to read from
  56932. * @returns the current Color3 object
  56933. */
  56934. set(r: number, g: number, b: number): Color3;
  56935. /**
  56936. * Compute the Color3 hexadecimal code as a string
  56937. * @returns a string containing the hexadecimal representation of the Color3 object
  56938. */
  56939. toHexString(): string;
  56940. /**
  56941. * Computes a new Color3 converted from the current one to linear space
  56942. * @returns a new Color3 object
  56943. */
  56944. toLinearSpace(): Color3;
  56945. /**
  56946. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  56947. * @param convertedColor defines the Color3 object where to store the linear space version
  56948. * @returns the unmodified Color3
  56949. */
  56950. toLinearSpaceToRef(convertedColor: Color3): Color3;
  56951. /**
  56952. * Computes a new Color3 converted from the current one to gamma space
  56953. * @returns a new Color3 object
  56954. */
  56955. toGammaSpace(): Color3;
  56956. /**
  56957. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  56958. * @param convertedColor defines the Color3 object where to store the gamma space version
  56959. * @returns the unmodified Color3
  56960. */
  56961. toGammaSpaceToRef(convertedColor: Color3): Color3;
  56962. private static _BlackReadOnly;
  56963. /**
  56964. * Creates a new Color3 from the string containing valid hexadecimal values
  56965. * @param hex defines a string containing valid hexadecimal values
  56966. * @returns a new Color3 object
  56967. */
  56968. static FromHexString(hex: string): Color3;
  56969. /**
  56970. * Creates a new Vector3 from the starting index of the given array
  56971. * @param array defines the source array
  56972. * @param offset defines an offset in the source array
  56973. * @returns a new Color3 object
  56974. */
  56975. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  56976. /**
  56977. * Creates a new Color3 from integer values (< 256)
  56978. * @param r defines the red component to read from (value between 0 and 255)
  56979. * @param g defines the green component to read from (value between 0 and 255)
  56980. * @param b defines the blue component to read from (value between 0 and 255)
  56981. * @returns a new Color3 object
  56982. */
  56983. static FromInts(r: number, g: number, b: number): Color3;
  56984. /**
  56985. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56986. * @param start defines the start Color3 value
  56987. * @param end defines the end Color3 value
  56988. * @param amount defines the gradient value between start and end
  56989. * @returns a new Color3 object
  56990. */
  56991. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  56992. /**
  56993. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56994. * @param left defines the start value
  56995. * @param right defines the end value
  56996. * @param amount defines the gradient factor
  56997. * @param result defines the Color3 object where to store the result
  56998. */
  56999. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57000. /**
  57001. * Returns a Color3 value containing a red color
  57002. * @returns a new Color3 object
  57003. */
  57004. static Red(): Color3;
  57005. /**
  57006. * Returns a Color3 value containing a green color
  57007. * @returns a new Color3 object
  57008. */
  57009. static Green(): Color3;
  57010. /**
  57011. * Returns a Color3 value containing a blue color
  57012. * @returns a new Color3 object
  57013. */
  57014. static Blue(): Color3;
  57015. /**
  57016. * Returns a Color3 value containing a black color
  57017. * @returns a new Color3 object
  57018. */
  57019. static Black(): Color3;
  57020. /**
  57021. * Gets a Color3 value containing a black color that must not be updated
  57022. */
  57023. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57024. /**
  57025. * Returns a Color3 value containing a white color
  57026. * @returns a new Color3 object
  57027. */
  57028. static White(): Color3;
  57029. /**
  57030. * Returns a Color3 value containing a purple color
  57031. * @returns a new Color3 object
  57032. */
  57033. static Purple(): Color3;
  57034. /**
  57035. * Returns a Color3 value containing a magenta color
  57036. * @returns a new Color3 object
  57037. */
  57038. static Magenta(): Color3;
  57039. /**
  57040. * Returns a Color3 value containing a yellow color
  57041. * @returns a new Color3 object
  57042. */
  57043. static Yellow(): Color3;
  57044. /**
  57045. * Returns a Color3 value containing a gray color
  57046. * @returns a new Color3 object
  57047. */
  57048. static Gray(): Color3;
  57049. /**
  57050. * Returns a Color3 value containing a teal color
  57051. * @returns a new Color3 object
  57052. */
  57053. static Teal(): Color3;
  57054. /**
  57055. * Returns a Color3 value containing a random color
  57056. * @returns a new Color3 object
  57057. */
  57058. static Random(): Color3;
  57059. }
  57060. /**
  57061. * Class used to hold a RBGA color
  57062. */
  57063. export class Color4 {
  57064. /**
  57065. * Defines the red component (between 0 and 1, default is 0)
  57066. */
  57067. r: number;
  57068. /**
  57069. * Defines the green component (between 0 and 1, default is 0)
  57070. */
  57071. g: number;
  57072. /**
  57073. * Defines the blue component (between 0 and 1, default is 0)
  57074. */
  57075. b: number;
  57076. /**
  57077. * Defines the alpha component (between 0 and 1, default is 1)
  57078. */
  57079. a: number;
  57080. /**
  57081. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57082. * @param r defines the red component (between 0 and 1, default is 0)
  57083. * @param g defines the green component (between 0 and 1, default is 0)
  57084. * @param b defines the blue component (between 0 and 1, default is 0)
  57085. * @param a defines the alpha component (between 0 and 1, default is 1)
  57086. */
  57087. constructor(
  57088. /**
  57089. * Defines the red component (between 0 and 1, default is 0)
  57090. */
  57091. r?: number,
  57092. /**
  57093. * Defines the green component (between 0 and 1, default is 0)
  57094. */
  57095. g?: number,
  57096. /**
  57097. * Defines the blue component (between 0 and 1, default is 0)
  57098. */
  57099. b?: number,
  57100. /**
  57101. * Defines the alpha component (between 0 and 1, default is 1)
  57102. */
  57103. a?: number);
  57104. /**
  57105. * Adds in place the given Color4 values to the current Color4 object
  57106. * @param right defines the second operand
  57107. * @returns the current updated Color4 object
  57108. */
  57109. addInPlace(right: DeepImmutable<Color4>): Color4;
  57110. /**
  57111. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57112. * @returns the new array
  57113. */
  57114. asArray(): number[];
  57115. /**
  57116. * Stores from the starting index in the given array the Color4 successive values
  57117. * @param array defines the array where to store the r,g,b components
  57118. * @param index defines an optional index in the target array to define where to start storing values
  57119. * @returns the current Color4 object
  57120. */
  57121. toArray(array: number[], index?: number): Color4;
  57122. /**
  57123. * Determines equality between Color4 objects
  57124. * @param otherColor defines the second operand
  57125. * @returns true if the rgba values are equal to the given ones
  57126. */
  57127. equals(otherColor: DeepImmutable<Color4>): boolean;
  57128. /**
  57129. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57130. * @param right defines the second operand
  57131. * @returns a new Color4 object
  57132. */
  57133. add(right: DeepImmutable<Color4>): Color4;
  57134. /**
  57135. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57136. * @param right defines the second operand
  57137. * @returns a new Color4 object
  57138. */
  57139. subtract(right: DeepImmutable<Color4>): Color4;
  57140. /**
  57141. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57142. * @param right defines the second operand
  57143. * @param result defines the Color4 object where to store the result
  57144. * @returns the current Color4 object
  57145. */
  57146. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57147. /**
  57148. * Creates a new Color4 with the current Color4 values multiplied by scale
  57149. * @param scale defines the scaling factor to apply
  57150. * @returns a new Color4 object
  57151. */
  57152. scale(scale: number): Color4;
  57153. /**
  57154. * Multiplies the current Color4 values by scale and stores the result in "result"
  57155. * @param scale defines the scaling factor to apply
  57156. * @param result defines the Color4 object where to store the result
  57157. * @returns the current unmodified Color4
  57158. */
  57159. scaleToRef(scale: number, result: Color4): Color4;
  57160. /**
  57161. * Scale the current Color4 values by a factor and add the result to a given Color4
  57162. * @param scale defines the scale factor
  57163. * @param result defines the Color4 object where to store the result
  57164. * @returns the unmodified current Color4
  57165. */
  57166. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57167. /**
  57168. * Clamps the rgb values by the min and max values and stores the result into "result"
  57169. * @param min defines minimum clamping value (default is 0)
  57170. * @param max defines maximum clamping value (default is 1)
  57171. * @param result defines color to store the result into.
  57172. * @returns the cuurent Color4
  57173. */
  57174. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57175. /**
  57176. * Multipy an Color4 value by another and return a new Color4 object
  57177. * @param color defines the Color4 value to multiply by
  57178. * @returns a new Color4 object
  57179. */
  57180. multiply(color: Color4): Color4;
  57181. /**
  57182. * Multipy a Color4 value by another and push the result in a reference value
  57183. * @param color defines the Color4 value to multiply by
  57184. * @param result defines the Color4 to fill the result in
  57185. * @returns the result Color4
  57186. */
  57187. multiplyToRef(color: Color4, result: Color4): Color4;
  57188. /**
  57189. * Creates a string with the Color4 current values
  57190. * @returns the string representation of the Color4 object
  57191. */
  57192. toString(): string;
  57193. /**
  57194. * Returns the string "Color4"
  57195. * @returns "Color4"
  57196. */
  57197. getClassName(): string;
  57198. /**
  57199. * Compute the Color4 hash code
  57200. * @returns an unique number that can be used to hash Color4 objects
  57201. */
  57202. getHashCode(): number;
  57203. /**
  57204. * Creates a new Color4 copied from the current one
  57205. * @returns a new Color4 object
  57206. */
  57207. clone(): Color4;
  57208. /**
  57209. * Copies the given Color4 values into the current one
  57210. * @param source defines the source Color4 object
  57211. * @returns the current updated Color4 object
  57212. */
  57213. copyFrom(source: Color4): Color4;
  57214. /**
  57215. * Copies the given float values into the current one
  57216. * @param r defines the red component to read from
  57217. * @param g defines the green component to read from
  57218. * @param b defines the blue component to read from
  57219. * @param a defines the alpha component to read from
  57220. * @returns the current updated Color4 object
  57221. */
  57222. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57223. /**
  57224. * Copies the given float values into the current one
  57225. * @param r defines the red component to read from
  57226. * @param g defines the green component to read from
  57227. * @param b defines the blue component to read from
  57228. * @param a defines the alpha component to read from
  57229. * @returns the current updated Color4 object
  57230. */
  57231. set(r: number, g: number, b: number, a: number): Color4;
  57232. /**
  57233. * Compute the Color4 hexadecimal code as a string
  57234. * @returns a string containing the hexadecimal representation of the Color4 object
  57235. */
  57236. toHexString(): string;
  57237. /**
  57238. * Computes a new Color4 converted from the current one to linear space
  57239. * @returns a new Color4 object
  57240. */
  57241. toLinearSpace(): Color4;
  57242. /**
  57243. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57244. * @param convertedColor defines the Color4 object where to store the linear space version
  57245. * @returns the unmodified Color4
  57246. */
  57247. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57248. /**
  57249. * Computes a new Color4 converted from the current one to gamma space
  57250. * @returns a new Color4 object
  57251. */
  57252. toGammaSpace(): Color4;
  57253. /**
  57254. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57255. * @param convertedColor defines the Color4 object where to store the gamma space version
  57256. * @returns the unmodified Color4
  57257. */
  57258. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57259. /**
  57260. * Creates a new Color4 from the string containing valid hexadecimal values
  57261. * @param hex defines a string containing valid hexadecimal values
  57262. * @returns a new Color4 object
  57263. */
  57264. static FromHexString(hex: string): Color4;
  57265. /**
  57266. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57267. * @param left defines the start value
  57268. * @param right defines the end value
  57269. * @param amount defines the gradient factor
  57270. * @returns a new Color4 object
  57271. */
  57272. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57273. /**
  57274. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57275. * @param left defines the start value
  57276. * @param right defines the end value
  57277. * @param amount defines the gradient factor
  57278. * @param result defines the Color4 object where to store data
  57279. */
  57280. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57281. /**
  57282. * Creates a new Color4 from a Color3 and an alpha value
  57283. * @param color3 defines the source Color3 to read from
  57284. * @param alpha defines the alpha component (1.0 by default)
  57285. * @returns a new Color4 object
  57286. */
  57287. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57288. /**
  57289. * Creates a new Color4 from the starting index element of the given array
  57290. * @param array defines the source array to read from
  57291. * @param offset defines the offset in the source array
  57292. * @returns a new Color4 object
  57293. */
  57294. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57295. /**
  57296. * Creates a new Color3 from integer values (< 256)
  57297. * @param r defines the red component to read from (value between 0 and 255)
  57298. * @param g defines the green component to read from (value between 0 and 255)
  57299. * @param b defines the blue component to read from (value between 0 and 255)
  57300. * @param a defines the alpha component to read from (value between 0 and 255)
  57301. * @returns a new Color3 object
  57302. */
  57303. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57304. /**
  57305. * Check the content of a given array and convert it to an array containing RGBA data
  57306. * If the original array was already containing count * 4 values then it is returned directly
  57307. * @param colors defines the array to check
  57308. * @param count defines the number of RGBA data to expect
  57309. * @returns an array containing count * 4 values (RGBA)
  57310. */
  57311. static CheckColors4(colors: number[], count: number): number[];
  57312. }
  57313. /**
  57314. * Class representing a vector containing 2 coordinates
  57315. */
  57316. export class Vector2 {
  57317. /** defines the first coordinate */
  57318. x: number;
  57319. /** defines the second coordinate */
  57320. y: number;
  57321. /**
  57322. * Creates a new Vector2 from the given x and y coordinates
  57323. * @param x defines the first coordinate
  57324. * @param y defines the second coordinate
  57325. */
  57326. constructor(
  57327. /** defines the first coordinate */
  57328. x?: number,
  57329. /** defines the second coordinate */
  57330. y?: number);
  57331. /**
  57332. * Gets a string with the Vector2 coordinates
  57333. * @returns a string with the Vector2 coordinates
  57334. */
  57335. toString(): string;
  57336. /**
  57337. * Gets class name
  57338. * @returns the string "Vector2"
  57339. */
  57340. getClassName(): string;
  57341. /**
  57342. * Gets current vector hash code
  57343. * @returns the Vector2 hash code as a number
  57344. */
  57345. getHashCode(): number;
  57346. /**
  57347. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57348. * @param array defines the source array
  57349. * @param index defines the offset in source array
  57350. * @returns the current Vector2
  57351. */
  57352. toArray(array: FloatArray, index?: number): Vector2;
  57353. /**
  57354. * Copy the current vector to an array
  57355. * @returns a new array with 2 elements: the Vector2 coordinates.
  57356. */
  57357. asArray(): number[];
  57358. /**
  57359. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57360. * @param source defines the source Vector2
  57361. * @returns the current updated Vector2
  57362. */
  57363. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57364. /**
  57365. * Sets the Vector2 coordinates with the given floats
  57366. * @param x defines the first coordinate
  57367. * @param y defines the second coordinate
  57368. * @returns the current updated Vector2
  57369. */
  57370. copyFromFloats(x: number, y: number): Vector2;
  57371. /**
  57372. * Sets the Vector2 coordinates with the given floats
  57373. * @param x defines the first coordinate
  57374. * @param y defines the second coordinate
  57375. * @returns the current updated Vector2
  57376. */
  57377. set(x: number, y: number): Vector2;
  57378. /**
  57379. * Add another vector with the current one
  57380. * @param otherVector defines the other vector
  57381. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57382. */
  57383. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57384. /**
  57385. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57386. * @param otherVector defines the other vector
  57387. * @param result defines the target vector
  57388. * @returns the unmodified current Vector2
  57389. */
  57390. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57391. /**
  57392. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57393. * @param otherVector defines the other vector
  57394. * @returns the current updated Vector2
  57395. */
  57396. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57397. /**
  57398. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57399. * @param otherVector defines the other vector
  57400. * @returns a new Vector2
  57401. */
  57402. addVector3(otherVector: Vector3): Vector2;
  57403. /**
  57404. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57405. * @param otherVector defines the other vector
  57406. * @returns a new Vector2
  57407. */
  57408. subtract(otherVector: Vector2): Vector2;
  57409. /**
  57410. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57411. * @param otherVector defines the other vector
  57412. * @param result defines the target vector
  57413. * @returns the unmodified current Vector2
  57414. */
  57415. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57416. /**
  57417. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57418. * @param otherVector defines the other vector
  57419. * @returns the current updated Vector2
  57420. */
  57421. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57422. /**
  57423. * Multiplies in place the current Vector2 coordinates by the given ones
  57424. * @param otherVector defines the other vector
  57425. * @returns the current updated Vector2
  57426. */
  57427. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57428. /**
  57429. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57430. * @param otherVector defines the other vector
  57431. * @returns a new Vector2
  57432. */
  57433. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57434. /**
  57435. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57436. * @param otherVector defines the other vector
  57437. * @param result defines the target vector
  57438. * @returns the unmodified current Vector2
  57439. */
  57440. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57441. /**
  57442. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57443. * @param x defines the first coordinate
  57444. * @param y defines the second coordinate
  57445. * @returns a new Vector2
  57446. */
  57447. multiplyByFloats(x: number, y: number): Vector2;
  57448. /**
  57449. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57450. * @param otherVector defines the other vector
  57451. * @returns a new Vector2
  57452. */
  57453. divide(otherVector: Vector2): Vector2;
  57454. /**
  57455. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57456. * @param otherVector defines the other vector
  57457. * @param result defines the target vector
  57458. * @returns the unmodified current Vector2
  57459. */
  57460. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57461. /**
  57462. * Divides the current Vector2 coordinates by the given ones
  57463. * @param otherVector defines the other vector
  57464. * @returns the current updated Vector2
  57465. */
  57466. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57467. /**
  57468. * Gets a new Vector2 with current Vector2 negated coordinates
  57469. * @returns a new Vector2
  57470. */
  57471. negate(): Vector2;
  57472. /**
  57473. * Multiply the Vector2 coordinates by scale
  57474. * @param scale defines the scaling factor
  57475. * @returns the current updated Vector2
  57476. */
  57477. scaleInPlace(scale: number): Vector2;
  57478. /**
  57479. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57480. * @param scale defines the scaling factor
  57481. * @returns a new Vector2
  57482. */
  57483. scale(scale: number): Vector2;
  57484. /**
  57485. * Scale the current Vector2 values by a factor to a given Vector2
  57486. * @param scale defines the scale factor
  57487. * @param result defines the Vector2 object where to store the result
  57488. * @returns the unmodified current Vector2
  57489. */
  57490. scaleToRef(scale: number, result: Vector2): Vector2;
  57491. /**
  57492. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57493. * @param scale defines the scale factor
  57494. * @param result defines the Vector2 object where to store the result
  57495. * @returns the unmodified current Vector2
  57496. */
  57497. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57498. /**
  57499. * Gets a boolean if two vectors are equals
  57500. * @param otherVector defines the other vector
  57501. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57502. */
  57503. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57504. /**
  57505. * Gets a boolean if two vectors are equals (using an epsilon value)
  57506. * @param otherVector defines the other vector
  57507. * @param epsilon defines the minimal distance to consider equality
  57508. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57509. */
  57510. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57511. /**
  57512. * Gets a new Vector2 from current Vector2 floored values
  57513. * @returns a new Vector2
  57514. */
  57515. floor(): Vector2;
  57516. /**
  57517. * Gets a new Vector2 from current Vector2 floored values
  57518. * @returns a new Vector2
  57519. */
  57520. fract(): Vector2;
  57521. /**
  57522. * Gets the length of the vector
  57523. * @returns the vector length (float)
  57524. */
  57525. length(): number;
  57526. /**
  57527. * Gets the vector squared length
  57528. * @returns the vector squared length (float)
  57529. */
  57530. lengthSquared(): number;
  57531. /**
  57532. * Normalize the vector
  57533. * @returns the current updated Vector2
  57534. */
  57535. normalize(): Vector2;
  57536. /**
  57537. * Gets a new Vector2 copied from the Vector2
  57538. * @returns a new Vector2
  57539. */
  57540. clone(): Vector2;
  57541. /**
  57542. * Gets a new Vector2(0, 0)
  57543. * @returns a new Vector2
  57544. */
  57545. static Zero(): Vector2;
  57546. /**
  57547. * Gets a new Vector2(1, 1)
  57548. * @returns a new Vector2
  57549. */
  57550. static One(): Vector2;
  57551. /**
  57552. * Gets a new Vector2 set from the given index element of the given array
  57553. * @param array defines the data source
  57554. * @param offset defines the offset in the data source
  57555. * @returns a new Vector2
  57556. */
  57557. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  57558. /**
  57559. * Sets "result" from the given index element of the given array
  57560. * @param array defines the data source
  57561. * @param offset defines the offset in the data source
  57562. * @param result defines the target vector
  57563. */
  57564. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  57565. /**
  57566. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57567. * @param value1 defines 1st point of control
  57568. * @param value2 defines 2nd point of control
  57569. * @param value3 defines 3rd point of control
  57570. * @param value4 defines 4th point of control
  57571. * @param amount defines the interpolation factor
  57572. * @returns a new Vector2
  57573. */
  57574. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57575. /**
  57576. * 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".
  57577. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57578. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57579. * @param value defines the value to clamp
  57580. * @param min defines the lower limit
  57581. * @param max defines the upper limit
  57582. * @returns a new Vector2
  57583. */
  57584. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57585. /**
  57586. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57587. * @param value1 defines the 1st control point
  57588. * @param tangent1 defines the outgoing tangent
  57589. * @param value2 defines the 2nd control point
  57590. * @param tangent2 defines the incoming tangent
  57591. * @param amount defines the interpolation factor
  57592. * @returns a new Vector2
  57593. */
  57594. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57595. /**
  57596. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57597. * @param start defines the start vector
  57598. * @param end defines the end vector
  57599. * @param amount defines the interpolation factor
  57600. * @returns a new Vector2
  57601. */
  57602. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57603. /**
  57604. * Gets the dot product of the vector "left" and the vector "right"
  57605. * @param left defines first vector
  57606. * @param right defines second vector
  57607. * @returns the dot product (float)
  57608. */
  57609. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57610. /**
  57611. * Returns a new Vector2 equal to the normalized given vector
  57612. * @param vector defines the vector to normalize
  57613. * @returns a new Vector2
  57614. */
  57615. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57616. /**
  57617. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57618. * @param left defines 1st vector
  57619. * @param right defines 2nd vector
  57620. * @returns a new Vector2
  57621. */
  57622. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57623. /**
  57624. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57625. * @param left defines 1st vector
  57626. * @param right defines 2nd vector
  57627. * @returns a new Vector2
  57628. */
  57629. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57630. /**
  57631. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57632. * @param vector defines the vector to transform
  57633. * @param transformation defines the matrix to apply
  57634. * @returns a new Vector2
  57635. */
  57636. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57637. /**
  57638. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57639. * @param vector defines the vector to transform
  57640. * @param transformation defines the matrix to apply
  57641. * @param result defines the target vector
  57642. */
  57643. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57644. /**
  57645. * Determines if a given vector is included in a triangle
  57646. * @param p defines the vector to test
  57647. * @param p0 defines 1st triangle point
  57648. * @param p1 defines 2nd triangle point
  57649. * @param p2 defines 3rd triangle point
  57650. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57651. */
  57652. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57653. /**
  57654. * Gets the distance between the vectors "value1" and "value2"
  57655. * @param value1 defines first vector
  57656. * @param value2 defines second vector
  57657. * @returns the distance between vectors
  57658. */
  57659. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57660. /**
  57661. * Returns the squared distance between the vectors "value1" and "value2"
  57662. * @param value1 defines first vector
  57663. * @param value2 defines second vector
  57664. * @returns the squared distance between vectors
  57665. */
  57666. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57667. /**
  57668. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57669. * @param value1 defines first vector
  57670. * @param value2 defines second vector
  57671. * @returns a new Vector2
  57672. */
  57673. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57674. /**
  57675. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57676. * @param p defines the middle point
  57677. * @param segA defines one point of the segment
  57678. * @param segB defines the other point of the segment
  57679. * @returns the shortest distance
  57680. */
  57681. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57682. }
  57683. /**
  57684. * Classed used to store (x,y,z) vector representation
  57685. * A Vector3 is the main object used in 3D geometry
  57686. * It can represent etiher the coordinates of a point the space, either a direction
  57687. * Reminder: js uses a left handed forward facing system
  57688. */
  57689. export class Vector3 {
  57690. /**
  57691. * Defines the first coordinates (on X axis)
  57692. */
  57693. x: number;
  57694. /**
  57695. * Defines the second coordinates (on Y axis)
  57696. */
  57697. y: number;
  57698. /**
  57699. * Defines the third coordinates (on Z axis)
  57700. */
  57701. z: number;
  57702. private static _UpReadOnly;
  57703. /**
  57704. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  57705. * @param x defines the first coordinates (on X axis)
  57706. * @param y defines the second coordinates (on Y axis)
  57707. * @param z defines the third coordinates (on Z axis)
  57708. */
  57709. constructor(
  57710. /**
  57711. * Defines the first coordinates (on X axis)
  57712. */
  57713. x?: number,
  57714. /**
  57715. * Defines the second coordinates (on Y axis)
  57716. */
  57717. y?: number,
  57718. /**
  57719. * Defines the third coordinates (on Z axis)
  57720. */
  57721. z?: number);
  57722. /**
  57723. * Creates a string representation of the Vector3
  57724. * @returns a string with the Vector3 coordinates.
  57725. */
  57726. toString(): string;
  57727. /**
  57728. * Gets the class name
  57729. * @returns the string "Vector3"
  57730. */
  57731. getClassName(): string;
  57732. /**
  57733. * Creates the Vector3 hash code
  57734. * @returns a number which tends to be unique between Vector3 instances
  57735. */
  57736. getHashCode(): number;
  57737. /**
  57738. * Creates an array containing three elements : the coordinates of the Vector3
  57739. * @returns a new array of numbers
  57740. */
  57741. asArray(): number[];
  57742. /**
  57743. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  57744. * @param array defines the destination array
  57745. * @param index defines the offset in the destination array
  57746. * @returns the current Vector3
  57747. */
  57748. toArray(array: FloatArray, index?: number): Vector3;
  57749. /**
  57750. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  57751. * @returns a new Quaternion object, computed from the Vector3 coordinates
  57752. */
  57753. toQuaternion(): Quaternion;
  57754. /**
  57755. * Adds the given vector to the current Vector3
  57756. * @param otherVector defines the second operand
  57757. * @returns the current updated Vector3
  57758. */
  57759. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57760. /**
  57761. * Adds the given coordinates to the current Vector3
  57762. * @param x defines the x coordinate of the operand
  57763. * @param y defines the y coordinate of the operand
  57764. * @param z defines the z coordinate of the operand
  57765. * @returns the current updated Vector3
  57766. */
  57767. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57768. /**
  57769. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  57770. * @param otherVector defines the second operand
  57771. * @returns the resulting Vector3
  57772. */
  57773. add(otherVector: DeepImmutable<Vector3>): Vector3;
  57774. /**
  57775. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  57776. * @param otherVector defines the second operand
  57777. * @param result defines the Vector3 object where to store the result
  57778. * @returns the current Vector3
  57779. */
  57780. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57781. /**
  57782. * Subtract the given vector from the current Vector3
  57783. * @param otherVector defines the second operand
  57784. * @returns the current updated Vector3
  57785. */
  57786. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57787. /**
  57788. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  57789. * @param otherVector defines the second operand
  57790. * @returns the resulting Vector3
  57791. */
  57792. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  57793. /**
  57794. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  57795. * @param otherVector defines the second operand
  57796. * @param result defines the Vector3 object where to store the result
  57797. * @returns the current Vector3
  57798. */
  57799. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57800. /**
  57801. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  57802. * @param x defines the x coordinate of the operand
  57803. * @param y defines the y coordinate of the operand
  57804. * @param z defines the z coordinate of the operand
  57805. * @returns the resulting Vector3
  57806. */
  57807. subtractFromFloats(x: number, y: number, z: number): Vector3;
  57808. /**
  57809. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  57810. * @param x defines the x coordinate of the operand
  57811. * @param y defines the y coordinate of the operand
  57812. * @param z defines the z coordinate of the operand
  57813. * @param result defines the Vector3 object where to store the result
  57814. * @returns the current Vector3
  57815. */
  57816. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  57817. /**
  57818. * Gets a new Vector3 set with the current Vector3 negated coordinates
  57819. * @returns a new Vector3
  57820. */
  57821. negate(): Vector3;
  57822. /**
  57823. * Multiplies the Vector3 coordinates by the float "scale"
  57824. * @param scale defines the multiplier factor
  57825. * @returns the current updated Vector3
  57826. */
  57827. scaleInPlace(scale: number): Vector3;
  57828. /**
  57829. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  57830. * @param scale defines the multiplier factor
  57831. * @returns a new Vector3
  57832. */
  57833. scale(scale: number): Vector3;
  57834. /**
  57835. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  57836. * @param scale defines the multiplier factor
  57837. * @param result defines the Vector3 object where to store the result
  57838. * @returns the current Vector3
  57839. */
  57840. scaleToRef(scale: number, result: Vector3): Vector3;
  57841. /**
  57842. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  57843. * @param scale defines the scale factor
  57844. * @param result defines the Vector3 object where to store the result
  57845. * @returns the unmodified current Vector3
  57846. */
  57847. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  57848. /**
  57849. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  57850. * @param otherVector defines the second operand
  57851. * @returns true if both vectors are equals
  57852. */
  57853. equals(otherVector: DeepImmutable<Vector3>): boolean;
  57854. /**
  57855. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  57856. * @param otherVector defines the second operand
  57857. * @param epsilon defines the minimal distance to define values as equals
  57858. * @returns true if both vectors are distant less than epsilon
  57859. */
  57860. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  57861. /**
  57862. * Returns true if the current Vector3 coordinates equals the given floats
  57863. * @param x defines the x coordinate of the operand
  57864. * @param y defines the y coordinate of the operand
  57865. * @param z defines the z coordinate of the operand
  57866. * @returns true if both vectors are equals
  57867. */
  57868. equalsToFloats(x: number, y: number, z: number): boolean;
  57869. /**
  57870. * Multiplies the current Vector3 coordinates by the given ones
  57871. * @param otherVector defines the second operand
  57872. * @returns the current updated Vector3
  57873. */
  57874. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57875. /**
  57876. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  57877. * @param otherVector defines the second operand
  57878. * @returns the new Vector3
  57879. */
  57880. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  57881. /**
  57882. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  57883. * @param otherVector defines the second operand
  57884. * @param result defines the Vector3 object where to store the result
  57885. * @returns the current Vector3
  57886. */
  57887. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57888. /**
  57889. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  57890. * @param x defines the x coordinate of the operand
  57891. * @param y defines the y coordinate of the operand
  57892. * @param z defines the z coordinate of the operand
  57893. * @returns the new Vector3
  57894. */
  57895. multiplyByFloats(x: number, y: number, z: number): Vector3;
  57896. /**
  57897. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  57898. * @param otherVector defines the second operand
  57899. * @returns the new Vector3
  57900. */
  57901. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  57902. /**
  57903. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  57904. * @param otherVector defines the second operand
  57905. * @param result defines the Vector3 object where to store the result
  57906. * @returns the current Vector3
  57907. */
  57908. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57909. /**
  57910. * Divides the current Vector3 coordinates by the given ones.
  57911. * @param otherVector defines the second operand
  57912. * @returns the current updated Vector3
  57913. */
  57914. divideInPlace(otherVector: Vector3): Vector3;
  57915. /**
  57916. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  57917. * @param other defines the second operand
  57918. * @returns the current updated Vector3
  57919. */
  57920. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57921. /**
  57922. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  57923. * @param other defines the second operand
  57924. * @returns the current updated Vector3
  57925. */
  57926. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57927. /**
  57928. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  57929. * @param x defines the x coordinate of the operand
  57930. * @param y defines the y coordinate of the operand
  57931. * @param z defines the z coordinate of the operand
  57932. * @returns the current updated Vector3
  57933. */
  57934. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57935. /**
  57936. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  57937. * @param x defines the x coordinate of the operand
  57938. * @param y defines the y coordinate of the operand
  57939. * @param z defines the z coordinate of the operand
  57940. * @returns the current updated Vector3
  57941. */
  57942. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57943. /**
  57944. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  57945. * Check if is non uniform within a certain amount of decimal places to account for this
  57946. * @param epsilon the amount the values can differ
  57947. * @returns if the the vector is non uniform to a certain number of decimal places
  57948. */
  57949. isNonUniformWithinEpsilon(epsilon: number): boolean;
  57950. /**
  57951. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  57952. */
  57953. readonly isNonUniform: boolean;
  57954. /**
  57955. * Gets a new Vector3 from current Vector3 floored values
  57956. * @returns a new Vector3
  57957. */
  57958. floor(): Vector3;
  57959. /**
  57960. * Gets a new Vector3 from current Vector3 floored values
  57961. * @returns a new Vector3
  57962. */
  57963. fract(): Vector3;
  57964. /**
  57965. * Gets the length of the Vector3
  57966. * @returns the length of the Vecto3
  57967. */
  57968. length(): number;
  57969. /**
  57970. * Gets the squared length of the Vector3
  57971. * @returns squared length of the Vector3
  57972. */
  57973. lengthSquared(): number;
  57974. /**
  57975. * Normalize the current Vector3.
  57976. * Please note that this is an in place operation.
  57977. * @returns the current updated Vector3
  57978. */
  57979. normalize(): Vector3;
  57980. /**
  57981. * Reorders the x y z properties of the vector in place
  57982. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  57983. * @returns the current updated vector
  57984. */
  57985. reorderInPlace(order: string): this;
  57986. /**
  57987. * Rotates the vector around 0,0,0 by a quaternion
  57988. * @param quaternion the rotation quaternion
  57989. * @param result vector to store the result
  57990. * @returns the resulting vector
  57991. */
  57992. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  57993. /**
  57994. * Rotates a vector around a given point
  57995. * @param quaternion the rotation quaternion
  57996. * @param point the point to rotate around
  57997. * @param result vector to store the result
  57998. * @returns the resulting vector
  57999. */
  58000. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58001. /**
  58002. * Normalize the current Vector3 with the given input length.
  58003. * Please note that this is an in place operation.
  58004. * @param len the length of the vector
  58005. * @returns the current updated Vector3
  58006. */
  58007. normalizeFromLength(len: number): Vector3;
  58008. /**
  58009. * Normalize the current Vector3 to a new vector
  58010. * @returns the new Vector3
  58011. */
  58012. normalizeToNew(): Vector3;
  58013. /**
  58014. * Normalize the current Vector3 to the reference
  58015. * @param reference define the Vector3 to update
  58016. * @returns the updated Vector3
  58017. */
  58018. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58019. /**
  58020. * Creates a new Vector3 copied from the current Vector3
  58021. * @returns the new Vector3
  58022. */
  58023. clone(): Vector3;
  58024. /**
  58025. * Copies the given vector coordinates to the current Vector3 ones
  58026. * @param source defines the source Vector3
  58027. * @returns the current updated Vector3
  58028. */
  58029. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58030. /**
  58031. * Copies the given floats to the current Vector3 coordinates
  58032. * @param x defines the x coordinate of the operand
  58033. * @param y defines the y coordinate of the operand
  58034. * @param z defines the z coordinate of the operand
  58035. * @returns the current updated Vector3
  58036. */
  58037. copyFromFloats(x: number, y: number, z: number): Vector3;
  58038. /**
  58039. * Copies the given floats to the current Vector3 coordinates
  58040. * @param x defines the x coordinate of the operand
  58041. * @param y defines the y coordinate of the operand
  58042. * @param z defines the z coordinate of the operand
  58043. * @returns the current updated Vector3
  58044. */
  58045. set(x: number, y: number, z: number): Vector3;
  58046. /**
  58047. * Copies the given float to the current Vector3 coordinates
  58048. * @param v defines the x, y and z coordinates of the operand
  58049. * @returns the current updated Vector3
  58050. */
  58051. setAll(v: number): Vector3;
  58052. /**
  58053. * Get the clip factor between two vectors
  58054. * @param vector0 defines the first operand
  58055. * @param vector1 defines the second operand
  58056. * @param axis defines the axis to use
  58057. * @param size defines the size along the axis
  58058. * @returns the clip factor
  58059. */
  58060. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58061. /**
  58062. * Get angle between two vectors
  58063. * @param vector0 angle between vector0 and vector1
  58064. * @param vector1 angle between vector0 and vector1
  58065. * @param normal direction of the normal
  58066. * @return the angle between vector0 and vector1
  58067. */
  58068. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58069. /**
  58070. * Returns a new Vector3 set from the index "offset" of the given array
  58071. * @param array defines the source array
  58072. * @param offset defines the offset in the source array
  58073. * @returns the new Vector3
  58074. */
  58075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58076. /**
  58077. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58078. * This function is deprecated. Use FromArray instead
  58079. * @param array defines the source array
  58080. * @param offset defines the offset in the source array
  58081. * @returns the new Vector3
  58082. */
  58083. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58084. /**
  58085. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58086. * @param array defines the source array
  58087. * @param offset defines the offset in the source array
  58088. * @param result defines the Vector3 where to store the result
  58089. */
  58090. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58091. /**
  58092. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58093. * This function is deprecated. Use FromArrayToRef instead.
  58094. * @param array defines the source array
  58095. * @param offset defines the offset in the source array
  58096. * @param result defines the Vector3 where to store the result
  58097. */
  58098. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58099. /**
  58100. * Sets the given vector "result" with the given floats.
  58101. * @param x defines the x coordinate of the source
  58102. * @param y defines the y coordinate of the source
  58103. * @param z defines the z coordinate of the source
  58104. * @param result defines the Vector3 where to store the result
  58105. */
  58106. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58107. /**
  58108. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58109. * @returns a new empty Vector3
  58110. */
  58111. static Zero(): Vector3;
  58112. /**
  58113. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58114. * @returns a new unit Vector3
  58115. */
  58116. static One(): Vector3;
  58117. /**
  58118. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58119. * @returns a new up Vector3
  58120. */
  58121. static Up(): Vector3;
  58122. /**
  58123. * Gets a up Vector3 that must not be updated
  58124. */
  58125. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58126. /**
  58127. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58128. * @returns a new down Vector3
  58129. */
  58130. static Down(): Vector3;
  58131. /**
  58132. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58133. * @returns a new forward Vector3
  58134. */
  58135. static Forward(): Vector3;
  58136. /**
  58137. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58138. * @returns a new forward Vector3
  58139. */
  58140. static Backward(): Vector3;
  58141. /**
  58142. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58143. * @returns a new right Vector3
  58144. */
  58145. static Right(): Vector3;
  58146. /**
  58147. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58148. * @returns a new left Vector3
  58149. */
  58150. static Left(): Vector3;
  58151. /**
  58152. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58153. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58154. * @param vector defines the Vector3 to transform
  58155. * @param transformation defines the transformation matrix
  58156. * @returns the transformed Vector3
  58157. */
  58158. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58159. /**
  58160. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58161. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58162. * @param vector defines the Vector3 to transform
  58163. * @param transformation defines the transformation matrix
  58164. * @param result defines the Vector3 where to store the result
  58165. */
  58166. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58167. /**
  58168. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58169. * This method computes tranformed coordinates only, not transformed direction vectors
  58170. * @param x define the x coordinate of the source vector
  58171. * @param y define the y coordinate of the source vector
  58172. * @param z define the z coordinate of the source vector
  58173. * @param transformation defines the transformation matrix
  58174. * @param result defines the Vector3 where to store the result
  58175. */
  58176. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58177. /**
  58178. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58179. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58180. * @param vector defines the Vector3 to transform
  58181. * @param transformation defines the transformation matrix
  58182. * @returns the new Vector3
  58183. */
  58184. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58185. /**
  58186. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58187. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  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 TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58193. /**
  58194. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58195. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  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 TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58203. /**
  58204. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58205. * @param value1 defines the first control point
  58206. * @param value2 defines the second control point
  58207. * @param value3 defines the third control point
  58208. * @param value4 defines the fourth control point
  58209. * @param amount defines the amount on the spline to use
  58210. * @returns the new Vector3
  58211. */
  58212. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58213. /**
  58214. * 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"
  58215. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58216. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58217. * @param value defines the current value
  58218. * @param min defines the lower range value
  58219. * @param max defines the upper range value
  58220. * @returns the new Vector3
  58221. */
  58222. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58223. /**
  58224. * 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"
  58225. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58226. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58227. * @param value defines the current value
  58228. * @param min defines the lower range value
  58229. * @param max defines the upper range value
  58230. * @param result defines the Vector3 where to store the result
  58231. */
  58232. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58233. /**
  58234. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58235. * @param value1 defines the first control point
  58236. * @param tangent1 defines the first tangent vector
  58237. * @param value2 defines the second control point
  58238. * @param tangent2 defines the second tangent vector
  58239. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58240. * @returns the new Vector3
  58241. */
  58242. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58243. /**
  58244. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58245. * @param start defines the start value
  58246. * @param end defines the end value
  58247. * @param amount max defines amount between both (between 0 and 1)
  58248. * @returns the new Vector3
  58249. */
  58250. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58251. /**
  58252. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58253. * @param start defines the start value
  58254. * @param end defines the end value
  58255. * @param amount max defines amount between both (between 0 and 1)
  58256. * @param result defines the Vector3 where to store the result
  58257. */
  58258. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58259. /**
  58260. * Returns the dot product (float) between the vectors "left" and "right"
  58261. * @param left defines the left operand
  58262. * @param right defines the right operand
  58263. * @returns the dot product
  58264. */
  58265. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58266. /**
  58267. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58268. * The cross product is then orthogonal to both "left" and "right"
  58269. * @param left defines the left operand
  58270. * @param right defines the right operand
  58271. * @returns the cross product
  58272. */
  58273. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58274. /**
  58275. * Sets the given vector "result" with the cross product of "left" and "right"
  58276. * The cross product is then orthogonal to both "left" and "right"
  58277. * @param left defines the left operand
  58278. * @param right defines the right operand
  58279. * @param result defines the Vector3 where to store the result
  58280. */
  58281. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58282. /**
  58283. * Returns a new Vector3 as the normalization of the given vector
  58284. * @param vector defines the Vector3 to normalize
  58285. * @returns the new Vector3
  58286. */
  58287. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58288. /**
  58289. * Sets the given vector "result" with the normalization of the given first vector
  58290. * @param vector defines the Vector3 to normalize
  58291. * @param result defines the Vector3 where to store the result
  58292. */
  58293. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58294. /**
  58295. * Project a Vector3 onto screen space
  58296. * @param vector defines the Vector3 to project
  58297. * @param world defines the world matrix to use
  58298. * @param transform defines the transform (view x projection) matrix to use
  58299. * @param viewport defines the screen viewport to use
  58300. * @returns the new Vector3
  58301. */
  58302. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58303. /** @hidden */
  58304. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58305. /**
  58306. * Unproject from screen space to object space
  58307. * @param source defines the screen space Vector3 to use
  58308. * @param viewportWidth defines the current width of the viewport
  58309. * @param viewportHeight defines the current height of the viewport
  58310. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58311. * @param transform defines the transform (view x projection) matrix to use
  58312. * @returns the new Vector3
  58313. */
  58314. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58315. /**
  58316. * Unproject from screen space to object space
  58317. * @param source defines the screen space Vector3 to use
  58318. * @param viewportWidth defines the current width of the viewport
  58319. * @param viewportHeight defines the current height of the viewport
  58320. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58321. * @param view defines the view matrix to use
  58322. * @param projection defines the projection matrix to use
  58323. * @returns the new Vector3
  58324. */
  58325. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58326. /**
  58327. * Unproject from screen space to object space
  58328. * @param source defines the screen space Vector3 to use
  58329. * @param viewportWidth defines the current width of the viewport
  58330. * @param viewportHeight defines the current height of the viewport
  58331. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58332. * @param view defines the view matrix to use
  58333. * @param projection defines the projection matrix to use
  58334. * @param result defines the Vector3 where to store the result
  58335. */
  58336. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58337. /**
  58338. * Unproject from screen space to object space
  58339. * @param sourceX defines the screen space x coordinate to use
  58340. * @param sourceY defines the screen space y coordinate to use
  58341. * @param sourceZ defines the screen space z coordinate to use
  58342. * @param viewportWidth defines the current width of the viewport
  58343. * @param viewportHeight defines the current height of the viewport
  58344. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58345. * @param view defines the view matrix to use
  58346. * @param projection defines the projection matrix to use
  58347. * @param result defines the Vector3 where to store the result
  58348. */
  58349. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58350. /**
  58351. * Gets the minimal coordinate values between two Vector3
  58352. * @param left defines the first operand
  58353. * @param right defines the second operand
  58354. * @returns the new Vector3
  58355. */
  58356. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58357. /**
  58358. * Gets the maximal coordinate values between two Vector3
  58359. * @param left defines the first operand
  58360. * @param right defines the second operand
  58361. * @returns the new Vector3
  58362. */
  58363. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58364. /**
  58365. * Returns the distance between the vectors "value1" and "value2"
  58366. * @param value1 defines the first operand
  58367. * @param value2 defines the second operand
  58368. * @returns the distance
  58369. */
  58370. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58371. /**
  58372. * Returns the squared distance between the vectors "value1" and "value2"
  58373. * @param value1 defines the first operand
  58374. * @param value2 defines the second operand
  58375. * @returns the squared distance
  58376. */
  58377. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58378. /**
  58379. * Returns a new Vector3 located at the center between "value1" and "value2"
  58380. * @param value1 defines the first operand
  58381. * @param value2 defines the second operand
  58382. * @returns the new Vector3
  58383. */
  58384. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58385. /**
  58386. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58387. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58388. * to something in order to rotate it from its local system to the given target system
  58389. * Note: axis1, axis2 and axis3 are normalized during this operation
  58390. * @param axis1 defines the first axis
  58391. * @param axis2 defines the second axis
  58392. * @param axis3 defines the third axis
  58393. * @returns a new Vector3
  58394. */
  58395. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58396. /**
  58397. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58398. * @param axis1 defines the first axis
  58399. * @param axis2 defines the second axis
  58400. * @param axis3 defines the third axis
  58401. * @param ref defines the Vector3 where to store the result
  58402. */
  58403. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58404. }
  58405. /**
  58406. * Vector4 class created for EulerAngle class conversion to Quaternion
  58407. */
  58408. export class Vector4 {
  58409. /** x value of the vector */
  58410. x: number;
  58411. /** y value of the vector */
  58412. y: number;
  58413. /** z value of the vector */
  58414. z: number;
  58415. /** w value of the vector */
  58416. w: number;
  58417. /**
  58418. * Creates a Vector4 object from the given floats.
  58419. * @param x x value of the vector
  58420. * @param y y value of the vector
  58421. * @param z z value of the vector
  58422. * @param w w value of the vector
  58423. */
  58424. constructor(
  58425. /** x value of the vector */
  58426. x: number,
  58427. /** y value of the vector */
  58428. y: number,
  58429. /** z value of the vector */
  58430. z: number,
  58431. /** w value of the vector */
  58432. w: number);
  58433. /**
  58434. * Returns the string with the Vector4 coordinates.
  58435. * @returns a string containing all the vector values
  58436. */
  58437. toString(): string;
  58438. /**
  58439. * Returns the string "Vector4".
  58440. * @returns "Vector4"
  58441. */
  58442. getClassName(): string;
  58443. /**
  58444. * Returns the Vector4 hash code.
  58445. * @returns a unique hash code
  58446. */
  58447. getHashCode(): number;
  58448. /**
  58449. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58450. * @returns the resulting array
  58451. */
  58452. asArray(): number[];
  58453. /**
  58454. * Populates the given array from the given index with the Vector4 coordinates.
  58455. * @param array array to populate
  58456. * @param index index of the array to start at (default: 0)
  58457. * @returns the Vector4.
  58458. */
  58459. toArray(array: FloatArray, index?: number): Vector4;
  58460. /**
  58461. * Adds the given vector to the current Vector4.
  58462. * @param otherVector the vector to add
  58463. * @returns the updated Vector4.
  58464. */
  58465. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58466. /**
  58467. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58468. * @param otherVector the vector to add
  58469. * @returns the resulting vector
  58470. */
  58471. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58472. /**
  58473. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58474. * @param otherVector the vector to add
  58475. * @param result the vector to store the result
  58476. * @returns the current Vector4.
  58477. */
  58478. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58479. /**
  58480. * Subtract in place the given vector from the current Vector4.
  58481. * @param otherVector the vector to subtract
  58482. * @returns the updated Vector4.
  58483. */
  58484. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58485. /**
  58486. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58487. * @param otherVector the vector to add
  58488. * @returns the new vector with the result
  58489. */
  58490. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58491. /**
  58492. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58493. * @param otherVector the vector to subtract
  58494. * @param result the vector to store the result
  58495. * @returns the current Vector4.
  58496. */
  58497. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58498. /**
  58499. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58500. */
  58501. /**
  58502. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58503. * @param x value to subtract
  58504. * @param y value to subtract
  58505. * @param z value to subtract
  58506. * @param w value to subtract
  58507. * @returns new vector containing the result
  58508. */
  58509. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58510. /**
  58511. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58512. * @param x value to subtract
  58513. * @param y value to subtract
  58514. * @param z value to subtract
  58515. * @param w value to subtract
  58516. * @param result the vector to store the result in
  58517. * @returns the current Vector4.
  58518. */
  58519. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58520. /**
  58521. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58522. * @returns a new vector with the negated values
  58523. */
  58524. negate(): Vector4;
  58525. /**
  58526. * Multiplies the current Vector4 coordinates by scale (float).
  58527. * @param scale the number to scale with
  58528. * @returns the updated Vector4.
  58529. */
  58530. scaleInPlace(scale: number): Vector4;
  58531. /**
  58532. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58533. * @param scale the number to scale with
  58534. * @returns a new vector with the result
  58535. */
  58536. scale(scale: number): Vector4;
  58537. /**
  58538. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58539. * @param scale the number to scale with
  58540. * @param result a vector to store the result in
  58541. * @returns the current Vector4.
  58542. */
  58543. scaleToRef(scale: number, result: Vector4): Vector4;
  58544. /**
  58545. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58546. * @param scale defines the scale factor
  58547. * @param result defines the Vector4 object where to store the result
  58548. * @returns the unmodified current Vector4
  58549. */
  58550. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58551. /**
  58552. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  58553. * @param otherVector the vector to compare against
  58554. * @returns true if they are equal
  58555. */
  58556. equals(otherVector: DeepImmutable<Vector4>): boolean;
  58557. /**
  58558. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  58559. * @param otherVector vector to compare against
  58560. * @param epsilon (Default: very small number)
  58561. * @returns true if they are equal
  58562. */
  58563. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  58564. /**
  58565. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  58566. * @param x x value to compare against
  58567. * @param y y value to compare against
  58568. * @param z z value to compare against
  58569. * @param w w value to compare against
  58570. * @returns true if equal
  58571. */
  58572. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58573. /**
  58574. * Multiplies in place the current Vector4 by the given one.
  58575. * @param otherVector vector to multiple with
  58576. * @returns the updated Vector4.
  58577. */
  58578. multiplyInPlace(otherVector: Vector4): Vector4;
  58579. /**
  58580. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58581. * @param otherVector vector to multiple with
  58582. * @returns resulting new vector
  58583. */
  58584. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58585. /**
  58586. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58587. * @param otherVector vector to multiple with
  58588. * @param result vector to store the result
  58589. * @returns the current Vector4.
  58590. */
  58591. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58592. /**
  58593. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58594. * @param x x value multiply with
  58595. * @param y y value multiply with
  58596. * @param z z value multiply with
  58597. * @param w w value multiply with
  58598. * @returns resulting new vector
  58599. */
  58600. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58601. /**
  58602. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58603. * @param otherVector vector to devide with
  58604. * @returns resulting new vector
  58605. */
  58606. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58607. /**
  58608. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58609. * @param otherVector vector to devide with
  58610. * @param result vector to store the result
  58611. * @returns the current Vector4.
  58612. */
  58613. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58614. /**
  58615. * Divides the current Vector3 coordinates by the given ones.
  58616. * @param otherVector vector to devide with
  58617. * @returns the updated Vector3.
  58618. */
  58619. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58620. /**
  58621. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58622. * @param other defines the second operand
  58623. * @returns the current updated Vector4
  58624. */
  58625. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58626. /**
  58627. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58628. * @param other defines the second operand
  58629. * @returns the current updated Vector4
  58630. */
  58631. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58632. /**
  58633. * Gets a new Vector4 from current Vector4 floored values
  58634. * @returns a new Vector4
  58635. */
  58636. floor(): Vector4;
  58637. /**
  58638. * Gets a new Vector4 from current Vector3 floored values
  58639. * @returns a new Vector4
  58640. */
  58641. fract(): Vector4;
  58642. /**
  58643. * Returns the Vector4 length (float).
  58644. * @returns the length
  58645. */
  58646. length(): number;
  58647. /**
  58648. * Returns the Vector4 squared length (float).
  58649. * @returns the length squared
  58650. */
  58651. lengthSquared(): number;
  58652. /**
  58653. * Normalizes in place the Vector4.
  58654. * @returns the updated Vector4.
  58655. */
  58656. normalize(): Vector4;
  58657. /**
  58658. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58659. * @returns this converted to a new vector3
  58660. */
  58661. toVector3(): Vector3;
  58662. /**
  58663. * Returns a new Vector4 copied from the current one.
  58664. * @returns the new cloned vector
  58665. */
  58666. clone(): Vector4;
  58667. /**
  58668. * Updates the current Vector4 with the given one coordinates.
  58669. * @param source the source vector to copy from
  58670. * @returns the updated Vector4.
  58671. */
  58672. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58673. /**
  58674. * Updates the current Vector4 coordinates with the given floats.
  58675. * @param x float to copy from
  58676. * @param y float to copy from
  58677. * @param z float to copy from
  58678. * @param w float to copy from
  58679. * @returns the updated Vector4.
  58680. */
  58681. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58682. /**
  58683. * Updates the current Vector4 coordinates with the given floats.
  58684. * @param x float to set from
  58685. * @param y float to set from
  58686. * @param z float to set from
  58687. * @param w float to set from
  58688. * @returns the updated Vector4.
  58689. */
  58690. set(x: number, y: number, z: number, w: number): Vector4;
  58691. /**
  58692. * Copies the given float to the current Vector3 coordinates
  58693. * @param v defines the x, y, z and w coordinates of the operand
  58694. * @returns the current updated Vector3
  58695. */
  58696. setAll(v: number): Vector4;
  58697. /**
  58698. * Returns a new Vector4 set from the starting index of the given array.
  58699. * @param array the array to pull values from
  58700. * @param offset the offset into the array to start at
  58701. * @returns the new vector
  58702. */
  58703. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  58704. /**
  58705. * Updates the given vector "result" from the starting index of the given array.
  58706. * @param array the array to pull values from
  58707. * @param offset the offset into the array to start at
  58708. * @param result the vector to store the result in
  58709. */
  58710. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  58711. /**
  58712. * Updates the given vector "result" from the starting index of the given Float32Array.
  58713. * @param array the array to pull values from
  58714. * @param offset the offset into the array to start at
  58715. * @param result the vector to store the result in
  58716. */
  58717. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  58718. /**
  58719. * Updates the given vector "result" coordinates from the given floats.
  58720. * @param x float to set from
  58721. * @param y float to set from
  58722. * @param z float to set from
  58723. * @param w float to set from
  58724. * @param result the vector to the floats in
  58725. */
  58726. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  58727. /**
  58728. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  58729. * @returns the new vector
  58730. */
  58731. static Zero(): Vector4;
  58732. /**
  58733. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  58734. * @returns the new vector
  58735. */
  58736. static One(): Vector4;
  58737. /**
  58738. * Returns a new normalized Vector4 from the given one.
  58739. * @param vector the vector to normalize
  58740. * @returns the vector
  58741. */
  58742. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  58743. /**
  58744. * Updates the given vector "result" from the normalization of the given one.
  58745. * @param vector the vector to normalize
  58746. * @param result the vector to store the result in
  58747. */
  58748. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  58749. /**
  58750. * Returns a vector with the minimum values from the left and right vectors
  58751. * @param left left vector to minimize
  58752. * @param right right vector to minimize
  58753. * @returns a new vector with the minimum of the left and right vector values
  58754. */
  58755. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58756. /**
  58757. * Returns a vector with the maximum values from the left and right vectors
  58758. * @param left left vector to maximize
  58759. * @param right right vector to maximize
  58760. * @returns a new vector with the maximum of the left and right vector values
  58761. */
  58762. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58763. /**
  58764. * Returns the distance (float) between the vectors "value1" and "value2".
  58765. * @param value1 value to calulate the distance between
  58766. * @param value2 value to calulate the distance between
  58767. * @return the distance between the two vectors
  58768. */
  58769. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58770. /**
  58771. * Returns the squared distance (float) between the vectors "value1" and "value2".
  58772. * @param value1 value to calulate the distance between
  58773. * @param value2 value to calulate the distance between
  58774. * @return the distance between the two vectors squared
  58775. */
  58776. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58777. /**
  58778. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  58779. * @param value1 value to calulate the center between
  58780. * @param value2 value to calulate the center between
  58781. * @return the center between the two vectors
  58782. */
  58783. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  58784. /**
  58785. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  58786. * This methods computes transformed normalized direction vectors only.
  58787. * @param vector the vector to transform
  58788. * @param transformation the transformation matrix to apply
  58789. * @returns the new vector
  58790. */
  58791. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  58792. /**
  58793. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  58794. * This methods computes transformed normalized direction vectors only.
  58795. * @param vector the vector to transform
  58796. * @param transformation the transformation matrix to apply
  58797. * @param result the vector to store the result in
  58798. */
  58799. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58800. /**
  58801. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  58802. * This methods computes transformed normalized direction vectors only.
  58803. * @param x value to transform
  58804. * @param y value to transform
  58805. * @param z value to transform
  58806. * @param w value to transform
  58807. * @param transformation the transformation matrix to apply
  58808. * @param result the vector to store the results in
  58809. */
  58810. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58811. /**
  58812. * Creates a new Vector4 from a Vector3
  58813. * @param source defines the source data
  58814. * @param w defines the 4th component (default is 0)
  58815. * @returns a new Vector4
  58816. */
  58817. static FromVector3(source: Vector3, w?: number): Vector4;
  58818. }
  58819. /**
  58820. * Interface for the size containing width and height
  58821. */
  58822. export interface ISize {
  58823. /**
  58824. * Width
  58825. */
  58826. width: number;
  58827. /**
  58828. * Heighht
  58829. */
  58830. height: number;
  58831. }
  58832. /**
  58833. * Size containing widht and height
  58834. */
  58835. export class Size implements ISize {
  58836. /**
  58837. * Width
  58838. */
  58839. width: number;
  58840. /**
  58841. * Height
  58842. */
  58843. height: number;
  58844. /**
  58845. * Creates a Size object from the given width and height (floats).
  58846. * @param width width of the new size
  58847. * @param height height of the new size
  58848. */
  58849. constructor(width: number, height: number);
  58850. /**
  58851. * Returns a string with the Size width and height
  58852. * @returns a string with the Size width and height
  58853. */
  58854. toString(): string;
  58855. /**
  58856. * "Size"
  58857. * @returns the string "Size"
  58858. */
  58859. getClassName(): string;
  58860. /**
  58861. * Returns the Size hash code.
  58862. * @returns a hash code for a unique width and height
  58863. */
  58864. getHashCode(): number;
  58865. /**
  58866. * Updates the current size from the given one.
  58867. * @param src the given size
  58868. */
  58869. copyFrom(src: Size): void;
  58870. /**
  58871. * Updates in place the current Size from the given floats.
  58872. * @param width width of the new size
  58873. * @param height height of the new size
  58874. * @returns the updated Size.
  58875. */
  58876. copyFromFloats(width: number, height: number): Size;
  58877. /**
  58878. * Updates in place the current Size from the given floats.
  58879. * @param width width to set
  58880. * @param height height to set
  58881. * @returns the updated Size.
  58882. */
  58883. set(width: number, height: number): Size;
  58884. /**
  58885. * Multiplies the width and height by numbers
  58886. * @param w factor to multiple the width by
  58887. * @param h factor to multiple the height by
  58888. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  58889. */
  58890. multiplyByFloats(w: number, h: number): Size;
  58891. /**
  58892. * Clones the size
  58893. * @returns a new Size copied from the given one.
  58894. */
  58895. clone(): Size;
  58896. /**
  58897. * True if the current Size and the given one width and height are strictly equal.
  58898. * @param other the other size to compare against
  58899. * @returns True if the current Size and the given one width and height are strictly equal.
  58900. */
  58901. equals(other: Size): boolean;
  58902. /**
  58903. * The surface of the Size : width * height (float).
  58904. */
  58905. readonly surface: number;
  58906. /**
  58907. * Create a new size of zero
  58908. * @returns a new Size set to (0.0, 0.0)
  58909. */
  58910. static Zero(): Size;
  58911. /**
  58912. * Sums the width and height of two sizes
  58913. * @param otherSize size to add to this size
  58914. * @returns a new Size set as the addition result of the current Size and the given one.
  58915. */
  58916. add(otherSize: Size): Size;
  58917. /**
  58918. * Subtracts the width and height of two
  58919. * @param otherSize size to subtract to this size
  58920. * @returns a new Size set as the subtraction result of the given one from the current Size.
  58921. */
  58922. subtract(otherSize: Size): Size;
  58923. /**
  58924. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  58925. * @param start starting size to lerp between
  58926. * @param end end size to lerp between
  58927. * @param amount amount to lerp between the start and end values
  58928. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  58929. */
  58930. static Lerp(start: Size, end: Size, amount: number): Size;
  58931. }
  58932. /**
  58933. * Class used to store quaternion data
  58934. * @see https://en.wikipedia.org/wiki/Quaternion
  58935. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  58936. */
  58937. export class Quaternion {
  58938. /** defines the first component (0 by default) */
  58939. x: number;
  58940. /** defines the second component (0 by default) */
  58941. y: number;
  58942. /** defines the third component (0 by default) */
  58943. z: number;
  58944. /** defines the fourth component (1.0 by default) */
  58945. w: number;
  58946. /**
  58947. * Creates a new Quaternion from the given floats
  58948. * @param x defines the first component (0 by default)
  58949. * @param y defines the second component (0 by default)
  58950. * @param z defines the third component (0 by default)
  58951. * @param w defines the fourth component (1.0 by default)
  58952. */
  58953. constructor(
  58954. /** defines the first component (0 by default) */
  58955. x?: number,
  58956. /** defines the second component (0 by default) */
  58957. y?: number,
  58958. /** defines the third component (0 by default) */
  58959. z?: number,
  58960. /** defines the fourth component (1.0 by default) */
  58961. w?: number);
  58962. /**
  58963. * Gets a string representation for the current quaternion
  58964. * @returns a string with the Quaternion coordinates
  58965. */
  58966. toString(): string;
  58967. /**
  58968. * Gets the class name of the quaternion
  58969. * @returns the string "Quaternion"
  58970. */
  58971. getClassName(): string;
  58972. /**
  58973. * Gets a hash code for this quaternion
  58974. * @returns the quaternion hash code
  58975. */
  58976. getHashCode(): number;
  58977. /**
  58978. * Copy the quaternion to an array
  58979. * @returns a new array populated with 4 elements from the quaternion coordinates
  58980. */
  58981. asArray(): number[];
  58982. /**
  58983. * Check if two quaternions are equals
  58984. * @param otherQuaternion defines the second operand
  58985. * @return true if the current quaternion and the given one coordinates are strictly equals
  58986. */
  58987. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  58988. /**
  58989. * Clone the current quaternion
  58990. * @returns a new quaternion copied from the current one
  58991. */
  58992. clone(): Quaternion;
  58993. /**
  58994. * Copy a quaternion to the current one
  58995. * @param other defines the other quaternion
  58996. * @returns the updated current quaternion
  58997. */
  58998. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  58999. /**
  59000. * Updates the current quaternion with the given float coordinates
  59001. * @param x defines the x coordinate
  59002. * @param y defines the y coordinate
  59003. * @param z defines the z coordinate
  59004. * @param w defines the w coordinate
  59005. * @returns the updated current quaternion
  59006. */
  59007. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59008. /**
  59009. * Updates the current quaternion from the given float coordinates
  59010. * @param x defines the x coordinate
  59011. * @param y defines the y coordinate
  59012. * @param z defines the z coordinate
  59013. * @param w defines the w coordinate
  59014. * @returns the updated current quaternion
  59015. */
  59016. set(x: number, y: number, z: number, w: number): Quaternion;
  59017. /**
  59018. * Adds two quaternions
  59019. * @param other defines the second operand
  59020. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59021. */
  59022. add(other: DeepImmutable<Quaternion>): Quaternion;
  59023. /**
  59024. * Add a quaternion to the current one
  59025. * @param other defines the quaternion to add
  59026. * @returns the current quaternion
  59027. */
  59028. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59029. /**
  59030. * Subtract two quaternions
  59031. * @param other defines the second operand
  59032. * @returns a new quaternion as the subtraction result of the given one from the current one
  59033. */
  59034. subtract(other: Quaternion): Quaternion;
  59035. /**
  59036. * Multiplies the current quaternion by a scale factor
  59037. * @param value defines the scale factor
  59038. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59039. */
  59040. scale(value: number): Quaternion;
  59041. /**
  59042. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59043. * @param scale defines the scale factor
  59044. * @param result defines the Quaternion object where to store the result
  59045. * @returns the unmodified current quaternion
  59046. */
  59047. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59048. /**
  59049. * Multiplies in place the current quaternion by a scale factor
  59050. * @param value defines the scale factor
  59051. * @returns the current modified quaternion
  59052. */
  59053. scaleInPlace(value: number): Quaternion;
  59054. /**
  59055. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59056. * @param scale defines the scale factor
  59057. * @param result defines the Quaternion object where to store the result
  59058. * @returns the unmodified current quaternion
  59059. */
  59060. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59061. /**
  59062. * Multiplies two quaternions
  59063. * @param q1 defines the second operand
  59064. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59065. */
  59066. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59067. /**
  59068. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59069. * @param q1 defines the second operand
  59070. * @param result defines the target quaternion
  59071. * @returns the current quaternion
  59072. */
  59073. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59074. /**
  59075. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59076. * @param q1 defines the second operand
  59077. * @returns the currentupdated quaternion
  59078. */
  59079. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59080. /**
  59081. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59082. * @param ref defines the target quaternion
  59083. * @returns the current quaternion
  59084. */
  59085. conjugateToRef(ref: Quaternion): Quaternion;
  59086. /**
  59087. * Conjugates in place (1-q) the current quaternion
  59088. * @returns the current updated quaternion
  59089. */
  59090. conjugateInPlace(): Quaternion;
  59091. /**
  59092. * Conjugates in place (1-q) the current quaternion
  59093. * @returns a new quaternion
  59094. */
  59095. conjugate(): Quaternion;
  59096. /**
  59097. * Gets length of current quaternion
  59098. * @returns the quaternion length (float)
  59099. */
  59100. length(): number;
  59101. /**
  59102. * Normalize in place the current quaternion
  59103. * @returns the current updated quaternion
  59104. */
  59105. normalize(): Quaternion;
  59106. /**
  59107. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59108. * @param order is a reserved parameter and is ignore for now
  59109. * @returns a new Vector3 containing the Euler angles
  59110. */
  59111. toEulerAngles(order?: string): Vector3;
  59112. /**
  59113. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59114. * @param result defines the vector which will be filled with the Euler angles
  59115. * @param order is a reserved parameter and is ignore for now
  59116. * @returns the current unchanged quaternion
  59117. */
  59118. toEulerAnglesToRef(result: Vector3): Quaternion;
  59119. /**
  59120. * Updates the given rotation matrix with the current quaternion values
  59121. * @param result defines the target matrix
  59122. * @returns the current unchanged quaternion
  59123. */
  59124. toRotationMatrix(result: Matrix): Quaternion;
  59125. /**
  59126. * Updates the current quaternion from the given rotation matrix values
  59127. * @param matrix defines the source matrix
  59128. * @returns the current updated quaternion
  59129. */
  59130. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59131. /**
  59132. * Creates a new quaternion from a rotation matrix
  59133. * @param matrix defines the source matrix
  59134. * @returns a new quaternion created from the given rotation matrix values
  59135. */
  59136. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59137. /**
  59138. * Updates the given quaternion with the given rotation matrix values
  59139. * @param matrix defines the source matrix
  59140. * @param result defines the target quaternion
  59141. */
  59142. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59143. /**
  59144. * Returns the dot product (float) between the quaternions "left" and "right"
  59145. * @param left defines the left operand
  59146. * @param right defines the right operand
  59147. * @returns the dot product
  59148. */
  59149. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59150. /**
  59151. * Checks if the two quaternions are close to each other
  59152. * @param quat0 defines the first quaternion to check
  59153. * @param quat1 defines the second quaternion to check
  59154. * @returns true if the two quaternions are close to each other
  59155. */
  59156. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59157. /**
  59158. * Creates an empty quaternion
  59159. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59160. */
  59161. static Zero(): Quaternion;
  59162. /**
  59163. * Inverse a given quaternion
  59164. * @param q defines the source quaternion
  59165. * @returns a new quaternion as the inverted current quaternion
  59166. */
  59167. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59168. /**
  59169. * Inverse a given quaternion
  59170. * @param q defines the source quaternion
  59171. * @param result the quaternion the result will be stored in
  59172. * @returns the result quaternion
  59173. */
  59174. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59175. /**
  59176. * Creates an identity quaternion
  59177. * @returns the identity quaternion
  59178. */
  59179. static Identity(): Quaternion;
  59180. /**
  59181. * Gets a boolean indicating if the given quaternion is identity
  59182. * @param quaternion defines the quaternion to check
  59183. * @returns true if the quaternion is identity
  59184. */
  59185. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59186. /**
  59187. * Creates a quaternion from a rotation around an axis
  59188. * @param axis defines the axis to use
  59189. * @param angle defines the angle to use
  59190. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59191. */
  59192. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59193. /**
  59194. * Creates a rotation around an axis and stores it into the given quaternion
  59195. * @param axis defines the axis to use
  59196. * @param angle defines the angle to use
  59197. * @param result defines the target quaternion
  59198. * @returns the target quaternion
  59199. */
  59200. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59201. /**
  59202. * Creates a new quaternion from data stored into an array
  59203. * @param array defines the data source
  59204. * @param offset defines the offset in the source array where the data starts
  59205. * @returns a new quaternion
  59206. */
  59207. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59208. /**
  59209. * Create a quaternion from Euler rotation angles
  59210. * @param x Pitch
  59211. * @param y Yaw
  59212. * @param z Roll
  59213. * @returns the new Quaternion
  59214. */
  59215. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59216. /**
  59217. * Updates a quaternion from Euler rotation angles
  59218. * @param x Pitch
  59219. * @param y Yaw
  59220. * @param z Roll
  59221. * @param result the quaternion to store the result
  59222. * @returns the updated quaternion
  59223. */
  59224. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59225. /**
  59226. * Create a quaternion from Euler rotation vector
  59227. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59228. * @returns the new Quaternion
  59229. */
  59230. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59231. /**
  59232. * Updates a quaternion from Euler rotation vector
  59233. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59234. * @param result the quaternion to store the result
  59235. * @returns the updated quaternion
  59236. */
  59237. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59238. /**
  59239. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59240. * @param yaw defines the rotation around Y axis
  59241. * @param pitch defines the rotation around X axis
  59242. * @param roll defines the rotation around Z axis
  59243. * @returns the new quaternion
  59244. */
  59245. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59246. /**
  59247. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59248. * @param yaw defines the rotation around Y axis
  59249. * @param pitch defines the rotation around X axis
  59250. * @param roll defines the rotation around Z axis
  59251. * @param result defines the target quaternion
  59252. */
  59253. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59254. /**
  59255. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59256. * @param alpha defines the rotation around first axis
  59257. * @param beta defines the rotation around second axis
  59258. * @param gamma defines the rotation around third axis
  59259. * @returns the new quaternion
  59260. */
  59261. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59262. /**
  59263. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59264. * @param alpha defines the rotation around first axis
  59265. * @param beta defines the rotation around second axis
  59266. * @param gamma defines the rotation around third axis
  59267. * @param result defines the target quaternion
  59268. */
  59269. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59270. /**
  59271. * 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)
  59272. * @param axis1 defines the first axis
  59273. * @param axis2 defines the second axis
  59274. * @param axis3 defines the third axis
  59275. * @returns the new quaternion
  59276. */
  59277. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59278. /**
  59279. * 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
  59280. * @param axis1 defines the first axis
  59281. * @param axis2 defines the second axis
  59282. * @param axis3 defines the third axis
  59283. * @param ref defines the target quaternion
  59284. */
  59285. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59286. /**
  59287. * Interpolates between two quaternions
  59288. * @param left defines first quaternion
  59289. * @param right defines second quaternion
  59290. * @param amount defines the gradient to use
  59291. * @returns the new interpolated quaternion
  59292. */
  59293. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59294. /**
  59295. * Interpolates between two quaternions and stores it into a target quaternion
  59296. * @param left defines first quaternion
  59297. * @param right defines second quaternion
  59298. * @param amount defines the gradient to use
  59299. * @param result defines the target quaternion
  59300. */
  59301. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59302. /**
  59303. * Interpolate between two quaternions using Hermite interpolation
  59304. * @param value1 defines first quaternion
  59305. * @param tangent1 defines the incoming tangent
  59306. * @param value2 defines second quaternion
  59307. * @param tangent2 defines the outgoing tangent
  59308. * @param amount defines the target quaternion
  59309. * @returns the new interpolated quaternion
  59310. */
  59311. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59312. }
  59313. /**
  59314. * Class used to store matrix data (4x4)
  59315. */
  59316. export class Matrix {
  59317. private static _updateFlagSeed;
  59318. private static _identityReadOnly;
  59319. private _isIdentity;
  59320. private _isIdentityDirty;
  59321. private _isIdentity3x2;
  59322. private _isIdentity3x2Dirty;
  59323. /**
  59324. * Gets the update flag of the matrix which is an unique number for the matrix.
  59325. * It will be incremented every time the matrix data change.
  59326. * You can use it to speed the comparison between two versions of the same matrix.
  59327. */
  59328. updateFlag: number;
  59329. private readonly _m;
  59330. /**
  59331. * Gets the internal data of the matrix
  59332. */
  59333. readonly m: DeepImmutable<Float32Array>;
  59334. /** @hidden */
  59335. _markAsUpdated(): void;
  59336. /** @hidden */
  59337. private _updateIdentityStatus;
  59338. /**
  59339. * Creates an empty matrix (filled with zeros)
  59340. */
  59341. constructor();
  59342. /**
  59343. * Check if the current matrix is identity
  59344. * @returns true is the matrix is the identity matrix
  59345. */
  59346. isIdentity(): boolean;
  59347. /**
  59348. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59349. * @returns true is the matrix is the identity matrix
  59350. */
  59351. isIdentityAs3x2(): boolean;
  59352. /**
  59353. * Gets the determinant of the matrix
  59354. * @returns the matrix determinant
  59355. */
  59356. determinant(): number;
  59357. /**
  59358. * Returns the matrix as a Float32Array
  59359. * @returns the matrix underlying array
  59360. */
  59361. toArray(): DeepImmutable<Float32Array>;
  59362. /**
  59363. * Returns the matrix as a Float32Array
  59364. * @returns the matrix underlying array.
  59365. */
  59366. asArray(): DeepImmutable<Float32Array>;
  59367. /**
  59368. * Inverts the current matrix in place
  59369. * @returns the current inverted matrix
  59370. */
  59371. invert(): Matrix;
  59372. /**
  59373. * Sets all the matrix elements to zero
  59374. * @returns the current matrix
  59375. */
  59376. reset(): Matrix;
  59377. /**
  59378. * Adds the current matrix with a second one
  59379. * @param other defines the matrix to add
  59380. * @returns a new matrix as the addition of the current matrix and the given one
  59381. */
  59382. add(other: DeepImmutable<Matrix>): Matrix;
  59383. /**
  59384. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59385. * @param other defines the matrix to add
  59386. * @param result defines the target matrix
  59387. * @returns the current matrix
  59388. */
  59389. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59390. /**
  59391. * Adds in place the given matrix to the current matrix
  59392. * @param other defines the second operand
  59393. * @returns the current updated matrix
  59394. */
  59395. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59396. /**
  59397. * Sets the given matrix to the current inverted Matrix
  59398. * @param other defines the target matrix
  59399. * @returns the unmodified current matrix
  59400. */
  59401. invertToRef(other: Matrix): Matrix;
  59402. /**
  59403. * add a value at the specified position in the current Matrix
  59404. * @param index the index of the value within the matrix. between 0 and 15.
  59405. * @param value the value to be added
  59406. * @returns the current updated matrix
  59407. */
  59408. addAtIndex(index: number, value: number): Matrix;
  59409. /**
  59410. * mutiply the specified position in the current Matrix by a value
  59411. * @param index the index of the value within the matrix. between 0 and 15.
  59412. * @param value the value to be added
  59413. * @returns the current updated matrix
  59414. */
  59415. multiplyAtIndex(index: number, value: number): Matrix;
  59416. /**
  59417. * Inserts the translation vector (using 3 floats) in the current matrix
  59418. * @param x defines the 1st component of the translation
  59419. * @param y defines the 2nd component of the translation
  59420. * @param z defines the 3rd component of the translation
  59421. * @returns the current updated matrix
  59422. */
  59423. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59424. /**
  59425. * Inserts the translation vector in the current matrix
  59426. * @param vector3 defines the translation to insert
  59427. * @returns the current updated matrix
  59428. */
  59429. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59430. /**
  59431. * Gets the translation value of the current matrix
  59432. * @returns a new Vector3 as the extracted translation from the matrix
  59433. */
  59434. getTranslation(): Vector3;
  59435. /**
  59436. * Fill a Vector3 with the extracted translation from the matrix
  59437. * @param result defines the Vector3 where to store the translation
  59438. * @returns the current matrix
  59439. */
  59440. getTranslationToRef(result: Vector3): Matrix;
  59441. /**
  59442. * Remove rotation and scaling part from the matrix
  59443. * @returns the updated matrix
  59444. */
  59445. removeRotationAndScaling(): Matrix;
  59446. /**
  59447. * Multiply two matrices
  59448. * @param other defines the second operand
  59449. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59450. */
  59451. multiply(other: DeepImmutable<Matrix>): Matrix;
  59452. /**
  59453. * Copy the current matrix from the given one
  59454. * @param other defines the source matrix
  59455. * @returns the current updated matrix
  59456. */
  59457. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59458. /**
  59459. * Populates the given array from the starting index with the current matrix values
  59460. * @param array defines the target array
  59461. * @param offset defines the offset in the target array where to start storing values
  59462. * @returns the current matrix
  59463. */
  59464. copyToArray(array: Float32Array, offset?: number): Matrix;
  59465. /**
  59466. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59467. * @param other defines the second operand
  59468. * @param result defines the matrix where to store the multiplication
  59469. * @returns the current matrix
  59470. */
  59471. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59472. /**
  59473. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59474. * @param other defines the second operand
  59475. * @param result defines the array where to store the multiplication
  59476. * @param offset defines the offset in the target array where to start storing values
  59477. * @returns the current matrix
  59478. */
  59479. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59480. /**
  59481. * Check equality between this matrix and a second one
  59482. * @param value defines the second matrix to compare
  59483. * @returns true is the current matrix and the given one values are strictly equal
  59484. */
  59485. equals(value: DeepImmutable<Matrix>): boolean;
  59486. /**
  59487. * Clone the current matrix
  59488. * @returns a new matrix from the current matrix
  59489. */
  59490. clone(): Matrix;
  59491. /**
  59492. * Returns the name of the current matrix class
  59493. * @returns the string "Matrix"
  59494. */
  59495. getClassName(): string;
  59496. /**
  59497. * Gets the hash code of the current matrix
  59498. * @returns the hash code
  59499. */
  59500. getHashCode(): number;
  59501. /**
  59502. * Decomposes the current Matrix into a translation, rotation and scaling components
  59503. * @param scale defines the scale vector3 given as a reference to update
  59504. * @param rotation defines the rotation quaternion given as a reference to update
  59505. * @param translation defines the translation vector3 given as a reference to update
  59506. * @returns true if operation was successful
  59507. */
  59508. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59509. /**
  59510. * Gets specific row of the matrix
  59511. * @param index defines the number of the row to get
  59512. * @returns the index-th row of the current matrix as a new Vector4
  59513. */
  59514. getRow(index: number): Nullable<Vector4>;
  59515. /**
  59516. * Sets the index-th row of the current matrix to the vector4 values
  59517. * @param index defines the number of the row to set
  59518. * @param row defines the target vector4
  59519. * @returns the updated current matrix
  59520. */
  59521. setRow(index: number, row: Vector4): Matrix;
  59522. /**
  59523. * Compute the transpose of the matrix
  59524. * @returns the new transposed matrix
  59525. */
  59526. transpose(): Matrix;
  59527. /**
  59528. * Compute the transpose of the matrix and store it in a given matrix
  59529. * @param result defines the target matrix
  59530. * @returns the current matrix
  59531. */
  59532. transposeToRef(result: Matrix): Matrix;
  59533. /**
  59534. * Sets the index-th row of the current matrix with the given 4 x float values
  59535. * @param index defines the row index
  59536. * @param x defines the x component to set
  59537. * @param y defines the y component to set
  59538. * @param z defines the z component to set
  59539. * @param w defines the w component to set
  59540. * @returns the updated current matrix
  59541. */
  59542. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59543. /**
  59544. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59545. * @param scale defines the scale factor
  59546. * @returns a new matrix
  59547. */
  59548. scale(scale: number): Matrix;
  59549. /**
  59550. * Scale the current matrix values by a factor to a given result matrix
  59551. * @param scale defines the scale factor
  59552. * @param result defines the matrix to store the result
  59553. * @returns the current matrix
  59554. */
  59555. scaleToRef(scale: number, result: Matrix): Matrix;
  59556. /**
  59557. * Scale the current matrix values by a factor and add the result to a given matrix
  59558. * @param scale defines the scale factor
  59559. * @param result defines the Matrix to store the result
  59560. * @returns the current matrix
  59561. */
  59562. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  59563. /**
  59564. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  59565. * @param ref matrix to store the result
  59566. */
  59567. toNormalMatrix(ref: Matrix): void;
  59568. /**
  59569. * Gets only rotation part of the current matrix
  59570. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59571. */
  59572. getRotationMatrix(): Matrix;
  59573. /**
  59574. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59575. * @param result defines the target matrix to store data to
  59576. * @returns the current matrix
  59577. */
  59578. getRotationMatrixToRef(result: Matrix): Matrix;
  59579. /**
  59580. * Toggles model matrix from being right handed to left handed in place and vice versa
  59581. */
  59582. toggleModelMatrixHandInPlace(): void;
  59583. /**
  59584. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59585. */
  59586. toggleProjectionMatrixHandInPlace(): void;
  59587. /**
  59588. * Creates a matrix from an array
  59589. * @param array defines the source array
  59590. * @param offset defines an offset in the source array
  59591. * @returns a new Matrix set from the starting index of the given array
  59592. */
  59593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59594. /**
  59595. * Copy the content of an array into a given matrix
  59596. * @param array defines the source array
  59597. * @param offset defines an offset in the source array
  59598. * @param result defines the target matrix
  59599. */
  59600. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59601. /**
  59602. * Stores an array into a matrix after having multiplied each component by a given factor
  59603. * @param array defines the source array
  59604. * @param offset defines the offset in the source array
  59605. * @param scale defines the scaling factor
  59606. * @param result defines the target matrix
  59607. */
  59608. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59609. /**
  59610. * Gets an identity matrix that must not be updated
  59611. */
  59612. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59613. /**
  59614. * Stores a list of values (16) inside a given matrix
  59615. * @param initialM11 defines 1st value of 1st row
  59616. * @param initialM12 defines 2nd value of 1st row
  59617. * @param initialM13 defines 3rd value of 1st row
  59618. * @param initialM14 defines 4th value of 1st row
  59619. * @param initialM21 defines 1st value of 2nd row
  59620. * @param initialM22 defines 2nd value of 2nd row
  59621. * @param initialM23 defines 3rd value of 2nd row
  59622. * @param initialM24 defines 4th value of 2nd row
  59623. * @param initialM31 defines 1st value of 3rd row
  59624. * @param initialM32 defines 2nd value of 3rd row
  59625. * @param initialM33 defines 3rd value of 3rd row
  59626. * @param initialM34 defines 4th value of 3rd row
  59627. * @param initialM41 defines 1st value of 4th row
  59628. * @param initialM42 defines 2nd value of 4th row
  59629. * @param initialM43 defines 3rd value of 4th row
  59630. * @param initialM44 defines 4th value of 4th row
  59631. * @param result defines the target matrix
  59632. */
  59633. 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;
  59634. /**
  59635. * Creates new matrix from a list of values (16)
  59636. * @param initialM11 defines 1st value of 1st row
  59637. * @param initialM12 defines 2nd value of 1st row
  59638. * @param initialM13 defines 3rd value of 1st row
  59639. * @param initialM14 defines 4th value of 1st row
  59640. * @param initialM21 defines 1st value of 2nd row
  59641. * @param initialM22 defines 2nd value of 2nd row
  59642. * @param initialM23 defines 3rd value of 2nd row
  59643. * @param initialM24 defines 4th value of 2nd row
  59644. * @param initialM31 defines 1st value of 3rd row
  59645. * @param initialM32 defines 2nd value of 3rd row
  59646. * @param initialM33 defines 3rd value of 3rd row
  59647. * @param initialM34 defines 4th value of 3rd row
  59648. * @param initialM41 defines 1st value of 4th row
  59649. * @param initialM42 defines 2nd value of 4th row
  59650. * @param initialM43 defines 3rd value of 4th row
  59651. * @param initialM44 defines 4th value of 4th row
  59652. * @returns the new matrix
  59653. */
  59654. 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;
  59655. /**
  59656. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59657. * @param scale defines the scale vector3
  59658. * @param rotation defines the rotation quaternion
  59659. * @param translation defines the translation vector3
  59660. * @returns a new matrix
  59661. */
  59662. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59663. /**
  59664. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59665. * @param scale defines the scale vector3
  59666. * @param rotation defines the rotation quaternion
  59667. * @param translation defines the translation vector3
  59668. * @param result defines the target matrix
  59669. */
  59670. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59671. /**
  59672. * Creates a new identity matrix
  59673. * @returns a new identity matrix
  59674. */
  59675. static Identity(): Matrix;
  59676. /**
  59677. * Creates a new identity matrix and stores the result in a given matrix
  59678. * @param result defines the target matrix
  59679. */
  59680. static IdentityToRef(result: Matrix): void;
  59681. /**
  59682. * Creates a new zero matrix
  59683. * @returns a new zero matrix
  59684. */
  59685. static Zero(): Matrix;
  59686. /**
  59687. * Creates a new rotation matrix for "angle" radians around the X axis
  59688. * @param angle defines the angle (in radians) to use
  59689. * @return the new matrix
  59690. */
  59691. static RotationX(angle: number): Matrix;
  59692. /**
  59693. * Creates a new matrix as the invert of a given matrix
  59694. * @param source defines the source matrix
  59695. * @returns the new matrix
  59696. */
  59697. static Invert(source: DeepImmutable<Matrix>): Matrix;
  59698. /**
  59699. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  59700. * @param angle defines the angle (in radians) to use
  59701. * @param result defines the target matrix
  59702. */
  59703. static RotationXToRef(angle: number, result: Matrix): void;
  59704. /**
  59705. * Creates a new rotation matrix for "angle" radians around the Y axis
  59706. * @param angle defines the angle (in radians) to use
  59707. * @return the new matrix
  59708. */
  59709. static RotationY(angle: number): Matrix;
  59710. /**
  59711. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  59712. * @param angle defines the angle (in radians) to use
  59713. * @param result defines the target matrix
  59714. */
  59715. static RotationYToRef(angle: number, result: Matrix): void;
  59716. /**
  59717. * Creates a new rotation matrix for "angle" radians around the Z axis
  59718. * @param angle defines the angle (in radians) to use
  59719. * @return the new matrix
  59720. */
  59721. static RotationZ(angle: number): Matrix;
  59722. /**
  59723. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  59724. * @param angle defines the angle (in radians) to use
  59725. * @param result defines the target matrix
  59726. */
  59727. static RotationZToRef(angle: number, result: Matrix): void;
  59728. /**
  59729. * Creates a new rotation matrix for "angle" radians around the given axis
  59730. * @param axis defines the axis to use
  59731. * @param angle defines the angle (in radians) to use
  59732. * @return the new matrix
  59733. */
  59734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  59735. /**
  59736. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  59737. * @param axis defines the axis to use
  59738. * @param angle defines the angle (in radians) to use
  59739. * @param result defines the target matrix
  59740. */
  59741. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  59742. /**
  59743. * Creates a rotation matrix
  59744. * @param yaw defines the yaw angle in radians (Y axis)
  59745. * @param pitch defines the pitch angle in radians (X axis)
  59746. * @param roll defines the roll angle in radians (X axis)
  59747. * @returns the new rotation matrix
  59748. */
  59749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  59750. /**
  59751. * Creates a rotation matrix and stores it in a given matrix
  59752. * @param yaw defines the yaw angle in radians (Y axis)
  59753. * @param pitch defines the pitch angle in radians (X axis)
  59754. * @param roll defines the roll angle in radians (X axis)
  59755. * @param result defines the target matrix
  59756. */
  59757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  59758. /**
  59759. * Creates a scaling matrix
  59760. * @param x defines the scale factor on X axis
  59761. * @param y defines the scale factor on Y axis
  59762. * @param z defines the scale factor on Z axis
  59763. * @returns the new matrix
  59764. */
  59765. static Scaling(x: number, y: number, z: number): Matrix;
  59766. /**
  59767. * Creates a scaling matrix and stores it in a given matrix
  59768. * @param x defines the scale factor on X axis
  59769. * @param y defines the scale factor on Y axis
  59770. * @param z defines the scale factor on Z axis
  59771. * @param result defines the target matrix
  59772. */
  59773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  59774. /**
  59775. * Creates a translation matrix
  59776. * @param x defines the translation on X axis
  59777. * @param y defines the translation on Y axis
  59778. * @param z defines the translationon Z axis
  59779. * @returns the new matrix
  59780. */
  59781. static Translation(x: number, y: number, z: number): Matrix;
  59782. /**
  59783. * Creates a translation matrix and stores it in a given matrix
  59784. * @param x defines the translation on X axis
  59785. * @param y defines the translation on Y axis
  59786. * @param z defines the translationon Z axis
  59787. * @param result defines the target matrix
  59788. */
  59789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  59790. /**
  59791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59792. * @param startValue defines the start value
  59793. * @param endValue defines the end value
  59794. * @param gradient defines the gradient factor
  59795. * @returns the new matrix
  59796. */
  59797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59798. /**
  59799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59800. * @param startValue defines the start value
  59801. * @param endValue defines the end value
  59802. * @param gradient defines the gradient factor
  59803. * @param result defines the Matrix object where to store data
  59804. */
  59805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59806. /**
  59807. * Builds a new matrix whose values are computed by:
  59808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59811. * @param startValue defines the first matrix
  59812. * @param endValue defines the second matrix
  59813. * @param gradient defines the gradient between the two matrices
  59814. * @returns the new matrix
  59815. */
  59816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59817. /**
  59818. * Update a matrix to values which are computed by:
  59819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59822. * @param startValue defines the first matrix
  59823. * @param endValue defines the second matrix
  59824. * @param gradient defines the gradient between the two matrices
  59825. * @param result defines the target matrix
  59826. */
  59827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59828. /**
  59829. * 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"
  59830. * This function works in left handed mode
  59831. * @param eye defines the final position of the entity
  59832. * @param target defines where the entity should look at
  59833. * @param up defines the up vector for the entity
  59834. * @returns the new matrix
  59835. */
  59836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59837. /**
  59838. * 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".
  59839. * This function works in left handed mode
  59840. * @param eye defines the final position of the entity
  59841. * @param target defines where the entity should look at
  59842. * @param up defines the up vector for the entity
  59843. * @param result defines the target matrix
  59844. */
  59845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59846. /**
  59847. * 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"
  59848. * This function works in right handed mode
  59849. * @param eye defines the final position of the entity
  59850. * @param target defines where the entity should look at
  59851. * @param up defines the up vector for the entity
  59852. * @returns the new matrix
  59853. */
  59854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59855. /**
  59856. * 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".
  59857. * This function works in right handed mode
  59858. * @param eye defines the final position of the entity
  59859. * @param target defines where the entity should look at
  59860. * @param up defines the up vector for the entity
  59861. * @param result defines the target matrix
  59862. */
  59863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59864. /**
  59865. * Create a left-handed orthographic projection matrix
  59866. * @param width defines the viewport width
  59867. * @param height defines the viewport height
  59868. * @param znear defines the near clip plane
  59869. * @param zfar defines the far clip plane
  59870. * @returns a new matrix as a left-handed orthographic projection matrix
  59871. */
  59872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59873. /**
  59874. * Store a left-handed orthographic projection to a given matrix
  59875. * @param width defines the viewport width
  59876. * @param height defines the viewport height
  59877. * @param znear defines the near clip plane
  59878. * @param zfar defines the far clip plane
  59879. * @param result defines the target matrix
  59880. */
  59881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  59882. /**
  59883. * Create a left-handed orthographic projection matrix
  59884. * @param left defines the viewport left coordinate
  59885. * @param right defines the viewport right coordinate
  59886. * @param bottom defines the viewport bottom coordinate
  59887. * @param top defines the viewport top coordinate
  59888. * @param znear defines the near clip plane
  59889. * @param zfar defines the far clip plane
  59890. * @returns a new matrix as a left-handed orthographic projection matrix
  59891. */
  59892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59893. /**
  59894. * Stores a left-handed orthographic projection into a given matrix
  59895. * @param left defines the viewport left coordinate
  59896. * @param right defines the viewport right coordinate
  59897. * @param bottom defines the viewport bottom coordinate
  59898. * @param top defines the viewport top coordinate
  59899. * @param znear defines the near clip plane
  59900. * @param zfar defines the far clip plane
  59901. * @param result defines the target matrix
  59902. */
  59903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59904. /**
  59905. * Creates a right-handed orthographic projection matrix
  59906. * @param left defines the viewport left coordinate
  59907. * @param right defines the viewport right coordinate
  59908. * @param bottom defines the viewport bottom coordinate
  59909. * @param top defines the viewport top coordinate
  59910. * @param znear defines the near clip plane
  59911. * @param zfar defines the far clip plane
  59912. * @returns a new matrix as a right-handed orthographic projection matrix
  59913. */
  59914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59915. /**
  59916. * Stores a right-handed orthographic projection into a given matrix
  59917. * @param left defines the viewport left coordinate
  59918. * @param right defines the viewport right coordinate
  59919. * @param bottom defines the viewport bottom coordinate
  59920. * @param top defines the viewport top coordinate
  59921. * @param znear defines the near clip plane
  59922. * @param zfar defines the far clip plane
  59923. * @param result defines the target matrix
  59924. */
  59925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59926. /**
  59927. * Creates a left-handed perspective projection matrix
  59928. * @param width defines the viewport width
  59929. * @param height defines the viewport height
  59930. * @param znear defines the near clip plane
  59931. * @param zfar defines the far clip plane
  59932. * @returns a new matrix as a left-handed perspective projection matrix
  59933. */
  59934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59935. /**
  59936. * Creates a left-handed perspective projection matrix
  59937. * @param fov defines the horizontal field of view
  59938. * @param aspect defines the aspect ratio
  59939. * @param znear defines the near clip plane
  59940. * @param zfar defines the far clip plane
  59941. * @returns a new matrix as a left-handed perspective projection matrix
  59942. */
  59943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59944. /**
  59945. * Stores a left-handed perspective projection into a given matrix
  59946. * @param fov defines the horizontal field of view
  59947. * @param aspect defines the aspect ratio
  59948. * @param znear defines the near clip plane
  59949. * @param zfar defines the far clip plane
  59950. * @param result defines the target matrix
  59951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59952. */
  59953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59954. /**
  59955. * Creates a right-handed perspective projection matrix
  59956. * @param fov defines the horizontal field of view
  59957. * @param aspect defines the aspect ratio
  59958. * @param znear defines the near clip plane
  59959. * @param zfar defines the far clip plane
  59960. * @returns a new matrix as a right-handed perspective projection matrix
  59961. */
  59962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59963. /**
  59964. * Stores a right-handed perspective projection into a given matrix
  59965. * @param fov defines the horizontal field of view
  59966. * @param aspect defines the aspect ratio
  59967. * @param znear defines the near clip plane
  59968. * @param zfar defines the far clip plane
  59969. * @param result defines the target matrix
  59970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59971. */
  59972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59973. /**
  59974. * Stores a perspective projection for WebVR info a given matrix
  59975. * @param fov defines the field of view
  59976. * @param znear defines the near clip plane
  59977. * @param zfar defines the far clip plane
  59978. * @param result defines the target matrix
  59979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  59980. */
  59981. static PerspectiveFovWebVRToRef(fov: {
  59982. upDegrees: number;
  59983. downDegrees: number;
  59984. leftDegrees: number;
  59985. rightDegrees: number;
  59986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  59987. /**
  59988. * Computes a complete transformation matrix
  59989. * @param viewport defines the viewport to use
  59990. * @param world defines the world matrix
  59991. * @param view defines the view matrix
  59992. * @param projection defines the projection matrix
  59993. * @param zmin defines the near clip plane
  59994. * @param zmax defines the far clip plane
  59995. * @returns the transformation matrix
  59996. */
  59997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  59998. /**
  59999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60000. * @param matrix defines the matrix to use
  60001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60002. */
  60003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60004. /**
  60005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60006. * @param matrix defines the matrix to use
  60007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60008. */
  60009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60010. /**
  60011. * Compute the transpose of a given matrix
  60012. * @param matrix defines the matrix to transpose
  60013. * @returns the new matrix
  60014. */
  60015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60016. /**
  60017. * Compute the transpose of a matrix and store it in a target matrix
  60018. * @param matrix defines the matrix to transpose
  60019. * @param result defines the target matrix
  60020. */
  60021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60022. /**
  60023. * Computes a reflection matrix from a plane
  60024. * @param plane defines the reflection plane
  60025. * @returns a new matrix
  60026. */
  60027. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60028. /**
  60029. * Computes a reflection matrix from a plane
  60030. * @param plane defines the reflection plane
  60031. * @param result defines the target matrix
  60032. */
  60033. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60034. /**
  60035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60036. * @param xaxis defines the value of the 1st axis
  60037. * @param yaxis defines the value of the 2nd axis
  60038. * @param zaxis defines the value of the 3rd axis
  60039. * @param result defines the target matrix
  60040. */
  60041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60042. /**
  60043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60044. * @param quat defines the quaternion to use
  60045. * @param result defines the target matrix
  60046. */
  60047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60048. }
  60049. /**
  60050. * Represens a plane by the equation ax + by + cz + d = 0
  60051. */
  60052. export class Plane {
  60053. /**
  60054. * Normal of the plane (a,b,c)
  60055. */
  60056. normal: Vector3;
  60057. /**
  60058. * d component of the plane
  60059. */
  60060. d: number;
  60061. /**
  60062. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60063. * @param a a component of the plane
  60064. * @param b b component of the plane
  60065. * @param c c component of the plane
  60066. * @param d d component of the plane
  60067. */
  60068. constructor(a: number, b: number, c: number, d: number);
  60069. /**
  60070. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60071. */
  60072. asArray(): number[];
  60073. /**
  60074. * @returns a new plane copied from the current Plane.
  60075. */
  60076. clone(): Plane;
  60077. /**
  60078. * @returns the string "Plane".
  60079. */
  60080. getClassName(): string;
  60081. /**
  60082. * @returns the Plane hash code.
  60083. */
  60084. getHashCode(): number;
  60085. /**
  60086. * Normalize the current Plane in place.
  60087. * @returns the updated Plane.
  60088. */
  60089. normalize(): Plane;
  60090. /**
  60091. * Applies a transformation the plane and returns the result
  60092. * @param transformation the transformation matrix to be applied to the plane
  60093. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60094. */
  60095. transform(transformation: DeepImmutable<Matrix>): Plane;
  60096. /**
  60097. * Calcualtte the dot product between the point and the plane normal
  60098. * @param point point to calculate the dot product with
  60099. * @returns the dot product (float) of the point coordinates and the plane normal.
  60100. */
  60101. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60102. /**
  60103. * Updates the current Plane from the plane defined by the three given points.
  60104. * @param point1 one of the points used to contruct the plane
  60105. * @param point2 one of the points used to contruct the plane
  60106. * @param point3 one of the points used to contruct the plane
  60107. * @returns the updated Plane.
  60108. */
  60109. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60110. /**
  60111. * Checks if the plane is facing a given direction
  60112. * @param direction the direction to check if the plane is facing
  60113. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60114. * @returns True is the vector "direction" is the same side than the plane normal.
  60115. */
  60116. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60117. /**
  60118. * Calculates the distance to a point
  60119. * @param point point to calculate distance to
  60120. * @returns the signed distance (float) from the given point to the Plane.
  60121. */
  60122. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60123. /**
  60124. * Creates a plane from an array
  60125. * @param array the array to create a plane from
  60126. * @returns a new Plane from the given array.
  60127. */
  60128. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60129. /**
  60130. * Creates a plane from three points
  60131. * @param point1 point used to create the plane
  60132. * @param point2 point used to create the plane
  60133. * @param point3 point used to create the plane
  60134. * @returns a new Plane defined by the three given points.
  60135. */
  60136. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60137. /**
  60138. * Creates a plane from an origin point and a normal
  60139. * @param origin origin of the plane to be constructed
  60140. * @param normal normal of the plane to be constructed
  60141. * @returns a new Plane the normal vector to this plane at the given origin point.
  60142. * Note : the vector "normal" is updated because normalized.
  60143. */
  60144. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60145. /**
  60146. * Calculates the distance from a plane and a point
  60147. * @param origin origin of the plane to be constructed
  60148. * @param normal normal of the plane to be constructed
  60149. * @param point point to calculate distance to
  60150. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60151. */
  60152. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60153. }
  60154. /**
  60155. * Class used to represent a viewport on screen
  60156. */
  60157. export class Viewport {
  60158. /** viewport left coordinate */
  60159. x: number;
  60160. /** viewport top coordinate */
  60161. y: number;
  60162. /**viewport width */
  60163. width: number;
  60164. /** viewport height */
  60165. height: number;
  60166. /**
  60167. * Creates a Viewport object located at (x, y) and sized (width, height)
  60168. * @param x defines viewport left coordinate
  60169. * @param y defines viewport top coordinate
  60170. * @param width defines the viewport width
  60171. * @param height defines the viewport height
  60172. */
  60173. constructor(
  60174. /** viewport left coordinate */
  60175. x: number,
  60176. /** viewport top coordinate */
  60177. y: number,
  60178. /**viewport width */
  60179. width: number,
  60180. /** viewport height */
  60181. height: number);
  60182. /**
  60183. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60184. * @param renderWidth defines the rendering width
  60185. * @param renderHeight defines the rendering height
  60186. * @returns a new Viewport
  60187. */
  60188. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60189. /**
  60190. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60191. * @param renderWidth defines the rendering width
  60192. * @param renderHeight defines the rendering height
  60193. * @param ref defines the target viewport
  60194. * @returns the current viewport
  60195. */
  60196. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60197. /**
  60198. * Returns a new Viewport copied from the current one
  60199. * @returns a new Viewport
  60200. */
  60201. clone(): Viewport;
  60202. }
  60203. /**
  60204. * Reprasents a camera frustum
  60205. */
  60206. export class Frustum {
  60207. /**
  60208. * Gets the planes representing the frustum
  60209. * @param transform matrix to be applied to the returned planes
  60210. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60211. */
  60212. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60213. /**
  60214. * Gets the near frustum plane transformed by the transform matrix
  60215. * @param transform transformation matrix to be applied to the resulting frustum plane
  60216. * @param frustumPlane the resuling frustum plane
  60217. */
  60218. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60219. /**
  60220. * Gets the far frustum plane transformed by the transform matrix
  60221. * @param transform transformation matrix to be applied to the resulting frustum plane
  60222. * @param frustumPlane the resuling frustum plane
  60223. */
  60224. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60225. /**
  60226. * Gets the left frustum plane transformed by the transform matrix
  60227. * @param transform transformation matrix to be applied to the resulting frustum plane
  60228. * @param frustumPlane the resuling frustum plane
  60229. */
  60230. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60231. /**
  60232. * Gets the right frustum plane transformed by the transform matrix
  60233. * @param transform transformation matrix to be applied to the resulting frustum plane
  60234. * @param frustumPlane the resuling frustum plane
  60235. */
  60236. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60237. /**
  60238. * Gets the top frustum plane transformed by the transform matrix
  60239. * @param transform transformation matrix to be applied to the resulting frustum plane
  60240. * @param frustumPlane the resuling frustum plane
  60241. */
  60242. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60243. /**
  60244. * Gets the bottom frustum plane transformed by the transform matrix
  60245. * @param transform transformation matrix to be applied to the resulting frustum plane
  60246. * @param frustumPlane the resuling frustum plane
  60247. */
  60248. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60249. /**
  60250. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60251. * @param transform transformation matrix to be applied to the resulting frustum planes
  60252. * @param frustumPlanes the resuling frustum planes
  60253. */
  60254. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60255. }
  60256. /** Defines supported spaces */
  60257. export enum Space {
  60258. /** Local (object) space */
  60259. LOCAL = 0,
  60260. /** World space */
  60261. WORLD = 1,
  60262. /** Bone space */
  60263. BONE = 2
  60264. }
  60265. /** Defines the 3 main axes */
  60266. export class Axis {
  60267. /** X axis */
  60268. static X: Vector3;
  60269. /** Y axis */
  60270. static Y: Vector3;
  60271. /** Z axis */
  60272. static Z: Vector3;
  60273. }
  60274. /** Class used to represent a Bezier curve */
  60275. export class BezierCurve {
  60276. /**
  60277. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60278. * @param t defines the time
  60279. * @param x1 defines the left coordinate on X axis
  60280. * @param y1 defines the left coordinate on Y axis
  60281. * @param x2 defines the right coordinate on X axis
  60282. * @param y2 defines the right coordinate on Y axis
  60283. * @returns the interpolated value
  60284. */
  60285. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60286. }
  60287. /**
  60288. * Defines potential orientation for back face culling
  60289. */
  60290. export enum Orientation {
  60291. /**
  60292. * Clockwise
  60293. */
  60294. CW = 0,
  60295. /** Counter clockwise */
  60296. CCW = 1
  60297. }
  60298. /**
  60299. * Defines angle representation
  60300. */
  60301. export class Angle {
  60302. private _radians;
  60303. /**
  60304. * Creates an Angle object of "radians" radians (float).
  60305. * @param radians the angle in radians
  60306. */
  60307. constructor(radians: number);
  60308. /**
  60309. * Get value in degrees
  60310. * @returns the Angle value in degrees (float)
  60311. */
  60312. degrees(): number;
  60313. /**
  60314. * Get value in radians
  60315. * @returns the Angle value in radians (float)
  60316. */
  60317. radians(): number;
  60318. /**
  60319. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60320. * @param a defines first vector
  60321. * @param b defines second vector
  60322. * @returns a new Angle
  60323. */
  60324. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60325. /**
  60326. * Gets a new Angle object from the given float in radians
  60327. * @param radians defines the angle value in radians
  60328. * @returns a new Angle
  60329. */
  60330. static FromRadians(radians: number): Angle;
  60331. /**
  60332. * Gets a new Angle object from the given float in degrees
  60333. * @param degrees defines the angle value in degrees
  60334. * @returns a new Angle
  60335. */
  60336. static FromDegrees(degrees: number): Angle;
  60337. }
  60338. /**
  60339. * This represents an arc in a 2d space.
  60340. */
  60341. export class Arc2 {
  60342. /** Defines the start point of the arc */
  60343. startPoint: Vector2;
  60344. /** Defines the mid point of the arc */
  60345. midPoint: Vector2;
  60346. /** Defines the end point of the arc */
  60347. endPoint: Vector2;
  60348. /**
  60349. * Defines the center point of the arc.
  60350. */
  60351. centerPoint: Vector2;
  60352. /**
  60353. * Defines the radius of the arc.
  60354. */
  60355. radius: number;
  60356. /**
  60357. * Defines the angle of the arc (from mid point to end point).
  60358. */
  60359. angle: Angle;
  60360. /**
  60361. * Defines the start angle of the arc (from start point to middle point).
  60362. */
  60363. startAngle: Angle;
  60364. /**
  60365. * Defines the orientation of the arc (clock wise/counter clock wise).
  60366. */
  60367. orientation: Orientation;
  60368. /**
  60369. * Creates an Arc object from the three given points : start, middle and end.
  60370. * @param startPoint Defines the start point of the arc
  60371. * @param midPoint Defines the midlle point of the arc
  60372. * @param endPoint Defines the end point of the arc
  60373. */
  60374. constructor(
  60375. /** Defines the start point of the arc */
  60376. startPoint: Vector2,
  60377. /** Defines the mid point of the arc */
  60378. midPoint: Vector2,
  60379. /** Defines the end point of the arc */
  60380. endPoint: Vector2);
  60381. }
  60382. /**
  60383. * Represents a 2D path made up of multiple 2D points
  60384. */
  60385. export class Path2 {
  60386. private _points;
  60387. private _length;
  60388. /**
  60389. * If the path start and end point are the same
  60390. */
  60391. closed: boolean;
  60392. /**
  60393. * Creates a Path2 object from the starting 2D coordinates x and y.
  60394. * @param x the starting points x value
  60395. * @param y the starting points y value
  60396. */
  60397. constructor(x: number, y: number);
  60398. /**
  60399. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60400. * @param x the added points x value
  60401. * @param y the added points y value
  60402. * @returns the updated Path2.
  60403. */
  60404. addLineTo(x: number, y: number): Path2;
  60405. /**
  60406. * 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.
  60407. * @param midX middle point x value
  60408. * @param midY middle point y value
  60409. * @param endX end point x value
  60410. * @param endY end point y value
  60411. * @param numberOfSegments (default: 36)
  60412. * @returns the updated Path2.
  60413. */
  60414. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60415. /**
  60416. * Closes the Path2.
  60417. * @returns the Path2.
  60418. */
  60419. close(): Path2;
  60420. /**
  60421. * Gets the sum of the distance between each sequential point in the path
  60422. * @returns the Path2 total length (float).
  60423. */
  60424. length(): number;
  60425. /**
  60426. * Gets the points which construct the path
  60427. * @returns the Path2 internal array of points.
  60428. */
  60429. getPoints(): Vector2[];
  60430. /**
  60431. * Retreives the point at the distance aways from the starting point
  60432. * @param normalizedLengthPosition the length along the path to retreive the point from
  60433. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60434. */
  60435. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60436. /**
  60437. * Creates a new path starting from an x and y position
  60438. * @param x starting x value
  60439. * @param y starting y value
  60440. * @returns a new Path2 starting at the coordinates (x, y).
  60441. */
  60442. static StartingAt(x: number, y: number): Path2;
  60443. }
  60444. /**
  60445. * Represents a 3D path made up of multiple 3D points
  60446. */
  60447. export class Path3D {
  60448. /**
  60449. * an array of Vector3, the curve axis of the Path3D
  60450. */
  60451. path: Vector3[];
  60452. private _curve;
  60453. private _distances;
  60454. private _tangents;
  60455. private _normals;
  60456. private _binormals;
  60457. private _raw;
  60458. /**
  60459. * new Path3D(path, normal, raw)
  60460. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60461. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60462. * @param path an array of Vector3, the curve axis of the Path3D
  60463. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60464. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60465. */
  60466. constructor(
  60467. /**
  60468. * an array of Vector3, the curve axis of the Path3D
  60469. */
  60470. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60471. /**
  60472. * Returns the Path3D array of successive Vector3 designing its curve.
  60473. * @returns the Path3D array of successive Vector3 designing its curve.
  60474. */
  60475. getCurve(): Vector3[];
  60476. /**
  60477. * Returns an array populated with tangent vectors on each Path3D curve point.
  60478. * @returns an array populated with tangent vectors on each Path3D curve point.
  60479. */
  60480. getTangents(): Vector3[];
  60481. /**
  60482. * Returns an array populated with normal vectors on each Path3D curve point.
  60483. * @returns an array populated with normal vectors on each Path3D curve point.
  60484. */
  60485. getNormals(): Vector3[];
  60486. /**
  60487. * Returns an array populated with binormal vectors on each Path3D curve point.
  60488. * @returns an array populated with binormal vectors on each Path3D curve point.
  60489. */
  60490. getBinormals(): Vector3[];
  60491. /**
  60492. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60493. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60494. */
  60495. getDistances(): number[];
  60496. /**
  60497. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60498. * @param path path which all values are copied into the curves points
  60499. * @param firstNormal which should be projected onto the curve
  60500. * @returns the same object updated.
  60501. */
  60502. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60503. private _compute;
  60504. private _getFirstNonNullVector;
  60505. private _getLastNonNullVector;
  60506. private _normalVector;
  60507. }
  60508. /**
  60509. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60510. * A Curve3 is designed from a series of successive Vector3.
  60511. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60512. */
  60513. export class Curve3 {
  60514. private _points;
  60515. private _length;
  60516. /**
  60517. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60518. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60519. * @param v1 (Vector3) the control point
  60520. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60521. * @param nbPoints (integer) the wanted number of points in the curve
  60522. * @returns the created Curve3
  60523. */
  60524. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60525. /**
  60526. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60527. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60528. * @param v1 (Vector3) the first control point
  60529. * @param v2 (Vector3) the second control point
  60530. * @param v3 (Vector3) the end point of the Cubic Bezier
  60531. * @param nbPoints (integer) the wanted number of points in the curve
  60532. * @returns the created Curve3
  60533. */
  60534. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60535. /**
  60536. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60537. * @param p1 (Vector3) the origin point of the Hermite Spline
  60538. * @param t1 (Vector3) the tangent vector at the origin point
  60539. * @param p2 (Vector3) the end point of the Hermite Spline
  60540. * @param t2 (Vector3) the tangent vector at the end point
  60541. * @param nbPoints (integer) the wanted number of points in the curve
  60542. * @returns the created Curve3
  60543. */
  60544. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60545. /**
  60546. * Returns a Curve3 object along a CatmullRom Spline curve :
  60547. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60548. * @param nbPoints (integer) the wanted number of points between each curve control points
  60549. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60550. * @returns the created Curve3
  60551. */
  60552. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  60553. /**
  60554. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60555. * A Curve3 is designed from a series of successive Vector3.
  60556. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  60557. * @param points points which make up the curve
  60558. */
  60559. constructor(points: Vector3[]);
  60560. /**
  60561. * @returns the Curve3 stored array of successive Vector3
  60562. */
  60563. getPoints(): Vector3[];
  60564. /**
  60565. * @returns the computed length (float) of the curve.
  60566. */
  60567. length(): number;
  60568. /**
  60569. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60570. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60571. * curveA and curveB keep unchanged.
  60572. * @param curve the curve to continue from this curve
  60573. * @returns the newly constructed curve
  60574. */
  60575. continue(curve: DeepImmutable<Curve3>): Curve3;
  60576. private _computeLength;
  60577. }
  60578. /**
  60579. * Contains position and normal vectors for a vertex
  60580. */
  60581. export class PositionNormalVertex {
  60582. /** the position of the vertex (defaut: 0,0,0) */
  60583. position: Vector3;
  60584. /** the normal of the vertex (defaut: 0,1,0) */
  60585. normal: Vector3;
  60586. /**
  60587. * Creates a PositionNormalVertex
  60588. * @param position the position of the vertex (defaut: 0,0,0)
  60589. * @param normal the normal of the vertex (defaut: 0,1,0)
  60590. */
  60591. constructor(
  60592. /** the position of the vertex (defaut: 0,0,0) */
  60593. position?: Vector3,
  60594. /** the normal of the vertex (defaut: 0,1,0) */
  60595. normal?: Vector3);
  60596. /**
  60597. * Clones the PositionNormalVertex
  60598. * @returns the cloned PositionNormalVertex
  60599. */
  60600. clone(): PositionNormalVertex;
  60601. }
  60602. /**
  60603. * Contains position, normal and uv vectors for a vertex
  60604. */
  60605. export class PositionNormalTextureVertex {
  60606. /** the position of the vertex (defaut: 0,0,0) */
  60607. position: Vector3;
  60608. /** the normal of the vertex (defaut: 0,1,0) */
  60609. normal: Vector3;
  60610. /** the uv of the vertex (default: 0,0) */
  60611. uv: Vector2;
  60612. /**
  60613. * Creates a PositionNormalTextureVertex
  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. * @param uv the uv of the vertex (default: 0,0)
  60617. */
  60618. constructor(
  60619. /** the position of the vertex (defaut: 0,0,0) */
  60620. position?: Vector3,
  60621. /** the normal of the vertex (defaut: 0,1,0) */
  60622. normal?: Vector3,
  60623. /** the uv of the vertex (default: 0,0) */
  60624. uv?: Vector2);
  60625. /**
  60626. * Clones the PositionNormalTextureVertex
  60627. * @returns the cloned PositionNormalTextureVertex
  60628. */
  60629. clone(): PositionNormalTextureVertex;
  60630. }
  60631. /**
  60632. * @hidden
  60633. */
  60634. export class Tmp {
  60635. static Color3: Color3[];
  60636. static Color4: Color4[];
  60637. static Vector2: Vector2[];
  60638. static Vector3: Vector3[];
  60639. static Vector4: Vector4[];
  60640. static Quaternion: Quaternion[];
  60641. static Matrix: Matrix[];
  60642. }
  60643. }
  60644. declare module BABYLON {
  60645. /**
  60646. * Class used to enable access to offline support
  60647. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60648. */
  60649. export interface IOfflineProvider {
  60650. /**
  60651. * Gets a boolean indicating if scene must be saved in the database
  60652. */
  60653. enableSceneOffline: boolean;
  60654. /**
  60655. * Gets a boolean indicating if textures must be saved in the database
  60656. */
  60657. enableTexturesOffline: boolean;
  60658. /**
  60659. * Open the offline support and make it available
  60660. * @param successCallback defines the callback to call on success
  60661. * @param errorCallback defines the callback to call on error
  60662. */
  60663. open(successCallback: () => void, errorCallback: () => void): void;
  60664. /**
  60665. * Loads an image from the offline support
  60666. * @param url defines the url to load from
  60667. * @param image defines the target DOM image
  60668. */
  60669. loadImage(url: string, image: HTMLImageElement): void;
  60670. /**
  60671. * Loads a file from offline support
  60672. * @param url defines the URL to load from
  60673. * @param sceneLoaded defines a callback to call on success
  60674. * @param progressCallBack defines a callback to call when progress changed
  60675. * @param errorCallback defines a callback to call on error
  60676. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60677. */
  60678. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60679. }
  60680. }
  60681. declare module BABYLON {
  60682. /**
  60683. * A class serves as a medium between the observable and its observers
  60684. */
  60685. export class EventState {
  60686. /**
  60687. * Create a new EventState
  60688. * @param mask defines the mask associated with this state
  60689. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60690. * @param target defines the original target of the state
  60691. * @param currentTarget defines the current target of the state
  60692. */
  60693. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  60694. /**
  60695. * Initialize the current event state
  60696. * @param mask defines the mask associated with this state
  60697. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60698. * @param target defines the original target of the state
  60699. * @param currentTarget defines the current target of the state
  60700. * @returns the current event state
  60701. */
  60702. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  60703. /**
  60704. * An Observer can set this property to true to prevent subsequent observers of being notified
  60705. */
  60706. skipNextObservers: boolean;
  60707. /**
  60708. * Get the mask value that were used to trigger the event corresponding to this EventState object
  60709. */
  60710. mask: number;
  60711. /**
  60712. * The object that originally notified the event
  60713. */
  60714. target?: any;
  60715. /**
  60716. * The current object in the bubbling phase
  60717. */
  60718. currentTarget?: any;
  60719. /**
  60720. * This will be populated with the return value of the last function that was executed.
  60721. * If it is the first function in the callback chain it will be the event data.
  60722. */
  60723. lastReturnValue?: any;
  60724. }
  60725. /**
  60726. * Represent an Observer registered to a given Observable object.
  60727. */
  60728. export class Observer<T> {
  60729. /**
  60730. * Defines the callback to call when the observer is notified
  60731. */
  60732. callback: (eventData: T, eventState: EventState) => void;
  60733. /**
  60734. * Defines the mask of the observer (used to filter notifications)
  60735. */
  60736. mask: number;
  60737. /**
  60738. * Defines the current scope used to restore the JS context
  60739. */
  60740. scope: any;
  60741. /** @hidden */
  60742. _willBeUnregistered: boolean;
  60743. /**
  60744. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  60745. */
  60746. unregisterOnNextCall: boolean;
  60747. /**
  60748. * Creates a new observer
  60749. * @param callback defines the callback to call when the observer is notified
  60750. * @param mask defines the mask of the observer (used to filter notifications)
  60751. * @param scope defines the current scope used to restore the JS context
  60752. */
  60753. constructor(
  60754. /**
  60755. * Defines the callback to call when the observer is notified
  60756. */
  60757. callback: (eventData: T, eventState: EventState) => void,
  60758. /**
  60759. * Defines the mask of the observer (used to filter notifications)
  60760. */
  60761. mask: number,
  60762. /**
  60763. * Defines the current scope used to restore the JS context
  60764. */
  60765. scope?: any);
  60766. }
  60767. /**
  60768. * Represent a list of observers registered to multiple Observables object.
  60769. */
  60770. export class MultiObserver<T> {
  60771. private _observers;
  60772. private _observables;
  60773. /**
  60774. * Release associated resources
  60775. */
  60776. dispose(): void;
  60777. /**
  60778. * Raise a callback when one of the observable will notify
  60779. * @param observables defines a list of observables to watch
  60780. * @param callback defines the callback to call on notification
  60781. * @param mask defines the mask used to filter notifications
  60782. * @param scope defines the current scope used to restore the JS context
  60783. * @returns the new MultiObserver
  60784. */
  60785. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  60786. }
  60787. /**
  60788. * The Observable class is a simple implementation of the Observable pattern.
  60789. *
  60790. * 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.
  60791. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  60792. * 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).
  60793. * 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.
  60794. */
  60795. export class Observable<T> {
  60796. private _observers;
  60797. private _eventState;
  60798. private _onObserverAdded;
  60799. /**
  60800. * Creates a new observable
  60801. * @param onObserverAdded defines a callback to call when a new observer is added
  60802. */
  60803. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  60804. /**
  60805. * Create a new Observer with the specified callback
  60806. * @param callback the callback that will be executed for that Observer
  60807. * @param mask the mask used to filter observers
  60808. * @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.
  60809. * @param scope optional scope for the callback to be called from
  60810. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  60811. * @returns the new observer created for the callback
  60812. */
  60813. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  60814. /**
  60815. * Create a new Observer with the specified callback and unregisters after the next notification
  60816. * @param callback the callback that will be executed for that Observer
  60817. * @returns the new observer created for the callback
  60818. */
  60819. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  60820. /**
  60821. * Remove an Observer from the Observable object
  60822. * @param observer the instance of the Observer to remove
  60823. * @returns false if it doesn't belong to this Observable
  60824. */
  60825. remove(observer: Nullable<Observer<T>>): boolean;
  60826. /**
  60827. * Remove a callback from the Observable object
  60828. * @param callback the callback to remove
  60829. * @param scope optional scope. If used only the callbacks with this scope will be removed
  60830. * @returns false if it doesn't belong to this Observable
  60831. */
  60832. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  60833. private _deferUnregister;
  60834. private _remove;
  60835. /**
  60836. * Notify all Observers by calling their respective callback with the given data
  60837. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  60838. * @param eventData defines the data to send to all observers
  60839. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  60840. * @param target defines the original target of the state
  60841. * @param currentTarget defines the current target of the state
  60842. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  60843. */
  60844. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  60845. /**
  60846. * Calling this will execute each callback, expecting it to be a promise or return a value.
  60847. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  60848. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  60849. * and it is crucial that all callbacks will be executed.
  60850. * The order of the callbacks is kept, callbacks are not executed parallel.
  60851. *
  60852. * @param eventData The data to be sent to each callback
  60853. * @param mask is used to filter observers defaults to -1
  60854. * @param target defines the callback target (see EventState)
  60855. * @param currentTarget defines he current object in the bubbling phase
  60856. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  60857. */
  60858. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  60859. /**
  60860. * Notify a specific observer
  60861. * @param observer defines the observer to notify
  60862. * @param eventData defines the data to be sent to each callback
  60863. * @param mask is used to filter observers defaults to -1
  60864. */
  60865. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  60866. /**
  60867. * Gets a boolean indicating if the observable has at least one observer
  60868. * @returns true is the Observable has at least one Observer registered
  60869. */
  60870. hasObservers(): boolean;
  60871. /**
  60872. * Clear the list of observers
  60873. */
  60874. clear(): void;
  60875. /**
  60876. * Clone the current observable
  60877. * @returns a new observable
  60878. */
  60879. clone(): Observable<T>;
  60880. /**
  60881. * Does this observable handles observer registered with a given mask
  60882. * @param mask defines the mask to be tested
  60883. * @return whether or not one observer registered with the given mask is handeled
  60884. **/
  60885. hasSpecificMask(mask?: number): boolean;
  60886. }
  60887. }
  60888. declare module BABYLON {
  60889. /**
  60890. * Class used to help managing file picking and drag'n'drop
  60891. * File Storage
  60892. */
  60893. export class FilesInputStore {
  60894. /**
  60895. * List of files ready to be loaded
  60896. */
  60897. static FilesToLoad: {
  60898. [key: string]: File;
  60899. };
  60900. }
  60901. }
  60902. declare module BABYLON {
  60903. /** Defines the cross module used constants to avoid circular dependncies */
  60904. export class Constants {
  60905. /** Defines that alpha blending is disabled */
  60906. static readonly ALPHA_DISABLE: number;
  60907. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  60908. static readonly ALPHA_ADD: number;
  60909. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  60910. static readonly ALPHA_COMBINE: number;
  60911. /** Defines that alpha blending to DEST - SRC * DEST */
  60912. static readonly ALPHA_SUBTRACT: number;
  60913. /** Defines that alpha blending to SRC * DEST */
  60914. static readonly ALPHA_MULTIPLY: number;
  60915. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  60916. static readonly ALPHA_MAXIMIZED: number;
  60917. /** Defines that alpha blending to SRC + DEST */
  60918. static readonly ALPHA_ONEONE: number;
  60919. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  60920. static readonly ALPHA_PREMULTIPLIED: number;
  60921. /**
  60922. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  60923. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  60924. */
  60925. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  60926. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  60927. static readonly ALPHA_INTERPOLATE: number;
  60928. /**
  60929. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  60930. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  60931. */
  60932. static readonly ALPHA_SCREENMODE: number;
  60933. /** Defines that the ressource is not delayed*/
  60934. static readonly DELAYLOADSTATE_NONE: number;
  60935. /** Defines that the ressource was successfully delay loaded */
  60936. static readonly DELAYLOADSTATE_LOADED: number;
  60937. /** Defines that the ressource is currently delay loading */
  60938. static readonly DELAYLOADSTATE_LOADING: number;
  60939. /** Defines that the ressource is delayed and has not started loading */
  60940. static readonly DELAYLOADSTATE_NOTLOADED: number;
  60941. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  60942. static readonly NEVER: number;
  60943. /** 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 */
  60944. static readonly ALWAYS: number;
  60945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  60946. static readonly LESS: number;
  60947. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  60948. static readonly EQUAL: number;
  60949. /** 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 */
  60950. static readonly LEQUAL: number;
  60951. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  60952. static readonly GREATER: number;
  60953. /** 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 */
  60954. static readonly GEQUAL: number;
  60955. /** 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 */
  60956. static readonly NOTEQUAL: number;
  60957. /** Passed to stencilOperation to specify that stencil value must be kept */
  60958. static readonly KEEP: number;
  60959. /** Passed to stencilOperation to specify that stencil value must be replaced */
  60960. static readonly REPLACE: number;
  60961. /** Passed to stencilOperation to specify that stencil value must be incremented */
  60962. static readonly INCR: number;
  60963. /** Passed to stencilOperation to specify that stencil value must be decremented */
  60964. static readonly DECR: number;
  60965. /** Passed to stencilOperation to specify that stencil value must be inverted */
  60966. static readonly INVERT: number;
  60967. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  60968. static readonly INCR_WRAP: number;
  60969. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  60970. static readonly DECR_WRAP: number;
  60971. /** Texture is not repeating outside of 0..1 UVs */
  60972. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  60973. /** Texture is repeating outside of 0..1 UVs */
  60974. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  60975. /** Texture is repeating and mirrored */
  60976. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  60977. /** ALPHA */
  60978. static readonly TEXTUREFORMAT_ALPHA: number;
  60979. /** LUMINANCE */
  60980. static readonly TEXTUREFORMAT_LUMINANCE: number;
  60981. /** LUMINANCE_ALPHA */
  60982. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  60983. /** RGB */
  60984. static readonly TEXTUREFORMAT_RGB: number;
  60985. /** RGBA */
  60986. static readonly TEXTUREFORMAT_RGBA: number;
  60987. /** RED */
  60988. static readonly TEXTUREFORMAT_RED: number;
  60989. /** RED (2nd reference) */
  60990. static readonly TEXTUREFORMAT_R: number;
  60991. /** RG */
  60992. static readonly TEXTUREFORMAT_RG: number;
  60993. /** RED_INTEGER */
  60994. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  60995. /** RED_INTEGER (2nd reference) */
  60996. static readonly TEXTUREFORMAT_R_INTEGER: number;
  60997. /** RG_INTEGER */
  60998. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  60999. /** RGB_INTEGER */
  61000. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61001. /** RGBA_INTEGER */
  61002. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61003. /** UNSIGNED_BYTE */
  61004. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61005. /** UNSIGNED_BYTE (2nd reference) */
  61006. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61007. /** FLOAT */
  61008. static readonly TEXTURETYPE_FLOAT: number;
  61009. /** HALF_FLOAT */
  61010. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61011. /** BYTE */
  61012. static readonly TEXTURETYPE_BYTE: number;
  61013. /** SHORT */
  61014. static readonly TEXTURETYPE_SHORT: number;
  61015. /** UNSIGNED_SHORT */
  61016. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61017. /** INT */
  61018. static readonly TEXTURETYPE_INT: number;
  61019. /** UNSIGNED_INT */
  61020. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61021. /** UNSIGNED_SHORT_4_4_4_4 */
  61022. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61023. /** UNSIGNED_SHORT_5_5_5_1 */
  61024. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61025. /** UNSIGNED_SHORT_5_6_5 */
  61026. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61027. /** UNSIGNED_INT_2_10_10_10_REV */
  61028. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61029. /** UNSIGNED_INT_24_8 */
  61030. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61031. /** UNSIGNED_INT_10F_11F_11F_REV */
  61032. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61033. /** UNSIGNED_INT_5_9_9_9_REV */
  61034. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61035. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61036. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61037. /** nearest is mag = nearest and min = nearest and mip = linear */
  61038. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61039. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61040. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61041. /** Trilinear is mag = linear and min = linear and mip = linear */
  61042. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61043. /** nearest is mag = nearest and min = nearest and mip = linear */
  61044. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61045. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61046. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61047. /** Trilinear is mag = linear and min = linear and mip = linear */
  61048. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61049. /** mag = nearest and min = nearest and mip = nearest */
  61050. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61051. /** mag = nearest and min = linear and mip = nearest */
  61052. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61053. /** mag = nearest and min = linear and mip = linear */
  61054. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61055. /** mag = nearest and min = linear and mip = none */
  61056. static readonly TEXTURE_NEAREST_LINEAR: number;
  61057. /** mag = nearest and min = nearest and mip = none */
  61058. static readonly TEXTURE_NEAREST_NEAREST: number;
  61059. /** mag = linear and min = nearest and mip = nearest */
  61060. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61061. /** mag = linear and min = nearest and mip = linear */
  61062. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61063. /** mag = linear and min = linear and mip = none */
  61064. static readonly TEXTURE_LINEAR_LINEAR: number;
  61065. /** mag = linear and min = nearest and mip = none */
  61066. static readonly TEXTURE_LINEAR_NEAREST: number;
  61067. /** Explicit coordinates mode */
  61068. static readonly TEXTURE_EXPLICIT_MODE: number;
  61069. /** Spherical coordinates mode */
  61070. static readonly TEXTURE_SPHERICAL_MODE: number;
  61071. /** Planar coordinates mode */
  61072. static readonly TEXTURE_PLANAR_MODE: number;
  61073. /** Cubic coordinates mode */
  61074. static readonly TEXTURE_CUBIC_MODE: number;
  61075. /** Projection coordinates mode */
  61076. static readonly TEXTURE_PROJECTION_MODE: number;
  61077. /** Skybox coordinates mode */
  61078. static readonly TEXTURE_SKYBOX_MODE: number;
  61079. /** Inverse Cubic coordinates mode */
  61080. static readonly TEXTURE_INVCUBIC_MODE: number;
  61081. /** Equirectangular coordinates mode */
  61082. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61083. /** Equirectangular Fixed coordinates mode */
  61084. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61085. /** Equirectangular Fixed Mirrored coordinates mode */
  61086. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61087. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61088. static readonly SCALEMODE_FLOOR: number;
  61089. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61090. static readonly SCALEMODE_NEAREST: number;
  61091. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61092. static readonly SCALEMODE_CEILING: number;
  61093. /**
  61094. * The dirty texture flag value
  61095. */
  61096. static readonly MATERIAL_TextureDirtyFlag: number;
  61097. /**
  61098. * The dirty light flag value
  61099. */
  61100. static readonly MATERIAL_LightDirtyFlag: number;
  61101. /**
  61102. * The dirty fresnel flag value
  61103. */
  61104. static readonly MATERIAL_FresnelDirtyFlag: number;
  61105. /**
  61106. * The dirty attribute flag value
  61107. */
  61108. static readonly MATERIAL_AttributesDirtyFlag: number;
  61109. /**
  61110. * The dirty misc flag value
  61111. */
  61112. static readonly MATERIAL_MiscDirtyFlag: number;
  61113. /**
  61114. * The all dirty flag value
  61115. */
  61116. static readonly MATERIAL_AllDirtyFlag: number;
  61117. /**
  61118. * Returns the triangle fill mode
  61119. */
  61120. static readonly MATERIAL_TriangleFillMode: number;
  61121. /**
  61122. * Returns the wireframe mode
  61123. */
  61124. static readonly MATERIAL_WireFrameFillMode: number;
  61125. /**
  61126. * Returns the point fill mode
  61127. */
  61128. static readonly MATERIAL_PointFillMode: number;
  61129. /**
  61130. * Returns the point list draw mode
  61131. */
  61132. static readonly MATERIAL_PointListDrawMode: number;
  61133. /**
  61134. * Returns the line list draw mode
  61135. */
  61136. static readonly MATERIAL_LineListDrawMode: number;
  61137. /**
  61138. * Returns the line loop draw mode
  61139. */
  61140. static readonly MATERIAL_LineLoopDrawMode: number;
  61141. /**
  61142. * Returns the line strip draw mode
  61143. */
  61144. static readonly MATERIAL_LineStripDrawMode: number;
  61145. /**
  61146. * Returns the triangle strip draw mode
  61147. */
  61148. static readonly MATERIAL_TriangleStripDrawMode: number;
  61149. /**
  61150. * Returns the triangle fan draw mode
  61151. */
  61152. static readonly MATERIAL_TriangleFanDrawMode: number;
  61153. /**
  61154. * Stores the clock-wise side orientation
  61155. */
  61156. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61157. /**
  61158. * Stores the counter clock-wise side orientation
  61159. */
  61160. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61161. /**
  61162. * Nothing
  61163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61164. */
  61165. static readonly ACTION_NothingTrigger: number;
  61166. /**
  61167. * On pick
  61168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61169. */
  61170. static readonly ACTION_OnPickTrigger: number;
  61171. /**
  61172. * On left pick
  61173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61174. */
  61175. static readonly ACTION_OnLeftPickTrigger: number;
  61176. /**
  61177. * On right pick
  61178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61179. */
  61180. static readonly ACTION_OnRightPickTrigger: number;
  61181. /**
  61182. * On center pick
  61183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61184. */
  61185. static readonly ACTION_OnCenterPickTrigger: number;
  61186. /**
  61187. * On pick down
  61188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61189. */
  61190. static readonly ACTION_OnPickDownTrigger: number;
  61191. /**
  61192. * On double pick
  61193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61194. */
  61195. static readonly ACTION_OnDoublePickTrigger: number;
  61196. /**
  61197. * On pick up
  61198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61199. */
  61200. static readonly ACTION_OnPickUpTrigger: number;
  61201. /**
  61202. * On pick out.
  61203. * This trigger will only be raised if you also declared a OnPickDown
  61204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61205. */
  61206. static readonly ACTION_OnPickOutTrigger: number;
  61207. /**
  61208. * On long press
  61209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61210. */
  61211. static readonly ACTION_OnLongPressTrigger: number;
  61212. /**
  61213. * On pointer over
  61214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61215. */
  61216. static readonly ACTION_OnPointerOverTrigger: number;
  61217. /**
  61218. * On pointer out
  61219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61220. */
  61221. static readonly ACTION_OnPointerOutTrigger: number;
  61222. /**
  61223. * On every frame
  61224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61225. */
  61226. static readonly ACTION_OnEveryFrameTrigger: number;
  61227. /**
  61228. * On intersection enter
  61229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61230. */
  61231. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61232. /**
  61233. * On intersection exit
  61234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61235. */
  61236. static readonly ACTION_OnIntersectionExitTrigger: number;
  61237. /**
  61238. * On key down
  61239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61240. */
  61241. static readonly ACTION_OnKeyDownTrigger: number;
  61242. /**
  61243. * On key up
  61244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61245. */
  61246. static readonly ACTION_OnKeyUpTrigger: number;
  61247. /**
  61248. * Billboard mode will only apply to Y axis
  61249. */
  61250. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61251. /**
  61252. * Billboard mode will apply to all axes
  61253. */
  61254. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61255. /**
  61256. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61257. */
  61258. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61259. /**
  61260. * Gets or sets base Assets URL
  61261. */
  61262. static readonly PARTICLES_BaseAssetsUrl: string;
  61263. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61264. * Test order :
  61265. * Is the bounding sphere outside the frustum ?
  61266. * If not, are the bounding box vertices outside the frustum ?
  61267. * It not, then the cullable object is in the frustum.
  61268. */
  61269. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61270. /** Culling strategy : Bounding Sphere Only.
  61271. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61272. * It's also less accurate than the standard because some not visible objects can still be selected.
  61273. * Test : is the bounding sphere outside the frustum ?
  61274. * If not, then the cullable object is in the frustum.
  61275. */
  61276. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61277. /** Culling strategy : Optimistic Inclusion.
  61278. * This in an inclusion test first, then the standard exclusion test.
  61279. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61280. * 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.
  61281. * Anyway, it's as accurate as the standard strategy.
  61282. * Test :
  61283. * Is the cullable object bounding sphere center in the frustum ?
  61284. * If not, apply the default culling strategy.
  61285. */
  61286. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61287. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61288. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61289. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61290. * 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.
  61291. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61292. * Test :
  61293. * Is the cullable object bounding sphere center in the frustum ?
  61294. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61295. */
  61296. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61297. /**
  61298. * No logging while loading
  61299. */
  61300. static readonly SCENELOADER_NO_LOGGING: number;
  61301. /**
  61302. * Minimal logging while loading
  61303. */
  61304. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61305. /**
  61306. * Summary logging while loading
  61307. */
  61308. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61309. /**
  61310. * Detailled logging while loading
  61311. */
  61312. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61313. }
  61314. }
  61315. declare module BABYLON {
  61316. /**
  61317. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61318. * Babylon.js
  61319. */
  61320. export class DomManagement {
  61321. /**
  61322. * Checks if the window object exists
  61323. * @returns true if the window object exists
  61324. */
  61325. static IsWindowObjectExist(): boolean;
  61326. /**
  61327. * Extracts text content from a DOM element hierarchy
  61328. * @param element defines the root element
  61329. * @returns a string
  61330. */
  61331. static GetDOMTextContent(element: HTMLElement): string;
  61332. }
  61333. }
  61334. declare module BABYLON {
  61335. /**
  61336. * Logger used througouht the application to allow configuration of
  61337. * the log level required for the messages.
  61338. */
  61339. export class Logger {
  61340. /**
  61341. * No log
  61342. */
  61343. static readonly NoneLogLevel: number;
  61344. /**
  61345. * Only message logs
  61346. */
  61347. static readonly MessageLogLevel: number;
  61348. /**
  61349. * Only warning logs
  61350. */
  61351. static readonly WarningLogLevel: number;
  61352. /**
  61353. * Only error logs
  61354. */
  61355. static readonly ErrorLogLevel: number;
  61356. /**
  61357. * All logs
  61358. */
  61359. static readonly AllLogLevel: number;
  61360. private static _LogCache;
  61361. /**
  61362. * Gets a value indicating the number of loading errors
  61363. * @ignorenaming
  61364. */
  61365. static errorsCount: number;
  61366. /**
  61367. * Callback called when a new log is added
  61368. */
  61369. static OnNewCacheEntry: (entry: string) => void;
  61370. private static _AddLogEntry;
  61371. private static _FormatMessage;
  61372. private static _LogDisabled;
  61373. private static _LogEnabled;
  61374. private static _WarnDisabled;
  61375. private static _WarnEnabled;
  61376. private static _ErrorDisabled;
  61377. private static _ErrorEnabled;
  61378. /**
  61379. * Log a message to the console
  61380. */
  61381. static Log: (message: string) => void;
  61382. /**
  61383. * Write a warning message to the console
  61384. */
  61385. static Warn: (message: string) => void;
  61386. /**
  61387. * Write an error message to the console
  61388. */
  61389. static Error: (message: string) => void;
  61390. /**
  61391. * Gets current log cache (list of logs)
  61392. */
  61393. static readonly LogCache: string;
  61394. /**
  61395. * Clears the log cache
  61396. */
  61397. static ClearLogCache(): void;
  61398. /**
  61399. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61400. */
  61401. static LogLevels: number;
  61402. }
  61403. }
  61404. declare module BABYLON {
  61405. /** @hidden */
  61406. export class _TypeStore {
  61407. /** @hidden */
  61408. static RegisteredTypes: {
  61409. [key: string]: Object;
  61410. };
  61411. /** @hidden */
  61412. static GetClass(fqdn: string): any;
  61413. }
  61414. }
  61415. declare module BABYLON {
  61416. /**
  61417. * Class containing a set of static utilities functions for deep copy.
  61418. */
  61419. export class DeepCopier {
  61420. /**
  61421. * Tries to copy an object by duplicating every property
  61422. * @param source defines the source object
  61423. * @param destination defines the target object
  61424. * @param doNotCopyList defines a list of properties to avoid
  61425. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61426. */
  61427. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61428. }
  61429. }
  61430. declare module BABYLON {
  61431. /**
  61432. * Class containing a set of static utilities functions for precision date
  61433. */
  61434. export class PrecisionDate {
  61435. /**
  61436. * Gets either window.performance.now() if supported or Date.now() else
  61437. */
  61438. static readonly Now: number;
  61439. }
  61440. }
  61441. declare module BABYLON {
  61442. /** @hidden */
  61443. export class _DevTools {
  61444. static WarnImport(name: string): string;
  61445. }
  61446. }
  61447. declare module BABYLON {
  61448. /**
  61449. * Class used to evalaute queries containing `and` and `or` operators
  61450. */
  61451. export class AndOrNotEvaluator {
  61452. /**
  61453. * Evaluate a query
  61454. * @param query defines the query to evaluate
  61455. * @param evaluateCallback defines the callback used to filter result
  61456. * @returns true if the query matches
  61457. */
  61458. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61459. private static _HandleParenthesisContent;
  61460. private static _SimplifyNegation;
  61461. }
  61462. }
  61463. declare module BABYLON {
  61464. /**
  61465. * Class used to store custom tags
  61466. */
  61467. export class Tags {
  61468. /**
  61469. * Adds support for tags on the given object
  61470. * @param obj defines the object to use
  61471. */
  61472. static EnableFor(obj: any): void;
  61473. /**
  61474. * Removes tags support
  61475. * @param obj defines the object to use
  61476. */
  61477. static DisableFor(obj: any): void;
  61478. /**
  61479. * Gets a boolean indicating if the given object has tags
  61480. * @param obj defines the object to use
  61481. * @returns a boolean
  61482. */
  61483. static HasTags(obj: any): boolean;
  61484. /**
  61485. * Gets the tags available on a given object
  61486. * @param obj defines the object to use
  61487. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61488. * @returns the tags
  61489. */
  61490. static GetTags(obj: any, asString?: boolean): any;
  61491. /**
  61492. * Adds tags to an object
  61493. * @param obj defines the object to use
  61494. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61495. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61496. */
  61497. static AddTagsTo(obj: any, tagsString: string): void;
  61498. /**
  61499. * @hidden
  61500. */
  61501. static _AddTagTo(obj: any, tag: string): void;
  61502. /**
  61503. * Removes specific tags from a specific object
  61504. * @param obj defines the object to use
  61505. * @param tagsString defines the tags to remove
  61506. */
  61507. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61508. /**
  61509. * @hidden
  61510. */
  61511. static _RemoveTagFrom(obj: any, tag: string): void;
  61512. /**
  61513. * Defines if tags hosted on an object match a given query
  61514. * @param obj defines the object to use
  61515. * @param tagsQuery defines the tag query
  61516. * @returns a boolean
  61517. */
  61518. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61519. }
  61520. }
  61521. declare module BABYLON {
  61522. /**
  61523. * Manages the defines for the Material
  61524. */
  61525. export class MaterialDefines {
  61526. private _keys;
  61527. private _isDirty;
  61528. /** @hidden */
  61529. _renderId: number;
  61530. /** @hidden */
  61531. _areLightsDirty: boolean;
  61532. /** @hidden */
  61533. _areAttributesDirty: boolean;
  61534. /** @hidden */
  61535. _areTexturesDirty: boolean;
  61536. /** @hidden */
  61537. _areFresnelDirty: boolean;
  61538. /** @hidden */
  61539. _areMiscDirty: boolean;
  61540. /** @hidden */
  61541. _areImageProcessingDirty: boolean;
  61542. /** @hidden */
  61543. _normals: boolean;
  61544. /** @hidden */
  61545. _uvs: boolean;
  61546. /** @hidden */
  61547. _needNormals: boolean;
  61548. /** @hidden */
  61549. _needUVs: boolean;
  61550. /**
  61551. * Specifies if the material needs to be re-calculated
  61552. */
  61553. readonly isDirty: boolean;
  61554. /**
  61555. * Marks the material to indicate that it has been re-calculated
  61556. */
  61557. markAsProcessed(): void;
  61558. /**
  61559. * Marks the material to indicate that it needs to be re-calculated
  61560. */
  61561. markAsUnprocessed(): void;
  61562. /**
  61563. * Marks the material to indicate all of its defines need to be re-calculated
  61564. */
  61565. markAllAsDirty(): void;
  61566. /**
  61567. * Marks the material to indicate that image processing needs to be re-calculated
  61568. */
  61569. markAsImageProcessingDirty(): void;
  61570. /**
  61571. * Marks the material to indicate the lights need to be re-calculated
  61572. */
  61573. markAsLightDirty(): void;
  61574. /**
  61575. * Marks the attribute state as changed
  61576. */
  61577. markAsAttributesDirty(): void;
  61578. /**
  61579. * Marks the texture state as changed
  61580. */
  61581. markAsTexturesDirty(): void;
  61582. /**
  61583. * Marks the fresnel state as changed
  61584. */
  61585. markAsFresnelDirty(): void;
  61586. /**
  61587. * Marks the misc state as changed
  61588. */
  61589. markAsMiscDirty(): void;
  61590. /**
  61591. * Rebuilds the material defines
  61592. */
  61593. rebuild(): void;
  61594. /**
  61595. * Specifies if two material defines are equal
  61596. * @param other - A material define instance to compare to
  61597. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61598. */
  61599. isEqual(other: MaterialDefines): boolean;
  61600. /**
  61601. * Clones this instance's defines to another instance
  61602. * @param other - material defines to clone values to
  61603. */
  61604. cloneTo(other: MaterialDefines): void;
  61605. /**
  61606. * Resets the material define values
  61607. */
  61608. reset(): void;
  61609. /**
  61610. * Converts the material define values to a string
  61611. * @returns - String of material define information
  61612. */
  61613. toString(): string;
  61614. }
  61615. }
  61616. declare module BABYLON {
  61617. /**
  61618. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61619. */
  61620. export class PerformanceMonitor {
  61621. private _enabled;
  61622. private _rollingFrameTime;
  61623. private _lastFrameTimeMs;
  61624. /**
  61625. * constructor
  61626. * @param frameSampleSize The number of samples required to saturate the sliding window
  61627. */
  61628. constructor(frameSampleSize?: number);
  61629. /**
  61630. * Samples current frame
  61631. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61632. */
  61633. sampleFrame(timeMs?: number): void;
  61634. /**
  61635. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61636. */
  61637. readonly averageFrameTime: number;
  61638. /**
  61639. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61640. */
  61641. readonly averageFrameTimeVariance: number;
  61642. /**
  61643. * Returns the frame time of the most recent frame
  61644. */
  61645. readonly instantaneousFrameTime: number;
  61646. /**
  61647. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61648. */
  61649. readonly averageFPS: number;
  61650. /**
  61651. * Returns the average framerate in frames per second using the most recent frame time
  61652. */
  61653. readonly instantaneousFPS: number;
  61654. /**
  61655. * Returns true if enough samples have been taken to completely fill the sliding window
  61656. */
  61657. readonly isSaturated: boolean;
  61658. /**
  61659. * Enables contributions to the sliding window sample set
  61660. */
  61661. enable(): void;
  61662. /**
  61663. * Disables contributions to the sliding window sample set
  61664. * Samples will not be interpolated over the disabled period
  61665. */
  61666. disable(): void;
  61667. /**
  61668. * Returns true if sampling is enabled
  61669. */
  61670. readonly isEnabled: boolean;
  61671. /**
  61672. * Resets performance monitor
  61673. */
  61674. reset(): void;
  61675. }
  61676. /**
  61677. * RollingAverage
  61678. *
  61679. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61680. */
  61681. export class RollingAverage {
  61682. /**
  61683. * Current average
  61684. */
  61685. average: number;
  61686. /**
  61687. * Current variance
  61688. */
  61689. variance: number;
  61690. protected _samples: Array<number>;
  61691. protected _sampleCount: number;
  61692. protected _pos: number;
  61693. protected _m2: number;
  61694. /**
  61695. * constructor
  61696. * @param length The number of samples required to saturate the sliding window
  61697. */
  61698. constructor(length: number);
  61699. /**
  61700. * Adds a sample to the sample set
  61701. * @param v The sample value
  61702. */
  61703. add(v: number): void;
  61704. /**
  61705. * Returns previously added values or null if outside of history or outside the sliding window domain
  61706. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61707. * @return Value previously recorded with add() or null if outside of range
  61708. */
  61709. history(i: number): number;
  61710. /**
  61711. * Returns true if enough samples have been taken to completely fill the sliding window
  61712. * @return true if sample-set saturated
  61713. */
  61714. isSaturated(): boolean;
  61715. /**
  61716. * Resets the rolling average (equivalent to 0 samples taken so far)
  61717. */
  61718. reset(): void;
  61719. /**
  61720. * Wraps a value around the sample range boundaries
  61721. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61722. * @return Wrapped position in sample range
  61723. */
  61724. protected _wrapPosition(i: number): number;
  61725. }
  61726. }
  61727. declare module BABYLON {
  61728. /**
  61729. * This class implement a typical dictionary using a string as key and the generic type T as value.
  61730. * The underlying implementation relies on an associative array to ensure the best performances.
  61731. * The value can be anything including 'null' but except 'undefined'
  61732. */
  61733. export class StringDictionary<T> {
  61734. /**
  61735. * This will clear this dictionary and copy the content from the 'source' one.
  61736. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  61737. * @param source the dictionary to take the content from and copy to this dictionary
  61738. */
  61739. copyFrom(source: StringDictionary<T>): void;
  61740. /**
  61741. * Get a value based from its key
  61742. * @param key the given key to get the matching value from
  61743. * @return the value if found, otherwise undefined is returned
  61744. */
  61745. get(key: string): T | undefined;
  61746. /**
  61747. * Get a value from its key or add it if it doesn't exist.
  61748. * This method will ensure you that a given key/data will be present in the dictionary.
  61749. * @param key the given key to get the matching value from
  61750. * @param factory the factory that will create the value if the key is not present in the dictionary.
  61751. * The factory will only be invoked if there's no data for the given key.
  61752. * @return the value corresponding to the key.
  61753. */
  61754. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  61755. /**
  61756. * Get a value from its key if present in the dictionary otherwise add it
  61757. * @param key the key to get the value from
  61758. * @param val if there's no such key/value pair in the dictionary add it with this value
  61759. * @return the value corresponding to the key
  61760. */
  61761. getOrAdd(key: string, val: T): T;
  61762. /**
  61763. * Check if there's a given key in the dictionary
  61764. * @param key the key to check for
  61765. * @return true if the key is present, false otherwise
  61766. */
  61767. contains(key: string): boolean;
  61768. /**
  61769. * Add a new key and its corresponding value
  61770. * @param key the key to add
  61771. * @param value the value corresponding to the key
  61772. * @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
  61773. */
  61774. add(key: string, value: T): boolean;
  61775. /**
  61776. * Update a specific value associated to a key
  61777. * @param key defines the key to use
  61778. * @param value defines the value to store
  61779. * @returns true if the value was updated (or false if the key was not found)
  61780. */
  61781. set(key: string, value: T): boolean;
  61782. /**
  61783. * Get the element of the given key and remove it from the dictionary
  61784. * @param key defines the key to search
  61785. * @returns the value associated with the key or null if not found
  61786. */
  61787. getAndRemove(key: string): Nullable<T>;
  61788. /**
  61789. * Remove a key/value from the dictionary.
  61790. * @param key the key to remove
  61791. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  61792. */
  61793. remove(key: string): boolean;
  61794. /**
  61795. * Clear the whole content of the dictionary
  61796. */
  61797. clear(): void;
  61798. /**
  61799. * Gets the current count
  61800. */
  61801. readonly count: number;
  61802. /**
  61803. * Execute a callback on each key/val of the dictionary.
  61804. * Note that you can remove any element in this dictionary in the callback implementation
  61805. * @param callback the callback to execute on a given key/value pair
  61806. */
  61807. forEach(callback: (key: string, val: T) => void): void;
  61808. /**
  61809. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  61810. * If the callback returns null or undefined the method will iterate to the next key/value pair
  61811. * Note that you can remove any element in this dictionary in the callback implementation
  61812. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  61813. * @returns the first item
  61814. */
  61815. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  61816. private _count;
  61817. private _data;
  61818. }
  61819. }
  61820. declare module BABYLON {
  61821. /**
  61822. * Helper class that provides a small promise polyfill
  61823. */
  61824. export class PromisePolyfill {
  61825. /**
  61826. * Static function used to check if the polyfill is required
  61827. * If this is the case then the function will inject the polyfill to window.Promise
  61828. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  61829. */
  61830. static Apply(force?: boolean): void;
  61831. }
  61832. }
  61833. declare module BABYLON {
  61834. /**
  61835. * Class used to store data that will be store in GPU memory
  61836. */
  61837. export class Buffer {
  61838. private _engine;
  61839. private _buffer;
  61840. /** @hidden */
  61841. _data: Nullable<DataArray>;
  61842. private _updatable;
  61843. private _instanced;
  61844. /**
  61845. * Gets the byte stride.
  61846. */
  61847. readonly byteStride: number;
  61848. /**
  61849. * Constructor
  61850. * @param engine the engine
  61851. * @param data the data to use for this buffer
  61852. * @param updatable whether the data is updatable
  61853. * @param stride the stride (optional)
  61854. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61855. * @param instanced whether the buffer is instanced (optional)
  61856. * @param useBytes set to true if the stride in in bytes (optional)
  61857. */
  61858. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  61859. /**
  61860. * Create a new VertexBuffer based on the current buffer
  61861. * @param kind defines the vertex buffer kind (position, normal, etc.)
  61862. * @param offset defines offset in the buffer (0 by default)
  61863. * @param size defines the size in floats of attributes (position is 3 for instance)
  61864. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  61865. * @param instanced defines if the vertex buffer contains indexed data
  61866. * @param useBytes defines if the offset and stride are in bytes
  61867. * @returns the new vertex buffer
  61868. */
  61869. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  61870. /**
  61871. * Gets a boolean indicating if the Buffer is updatable?
  61872. * @returns true if the buffer is updatable
  61873. */
  61874. isUpdatable(): boolean;
  61875. /**
  61876. * Gets current buffer's data
  61877. * @returns a DataArray or null
  61878. */
  61879. getData(): Nullable<DataArray>;
  61880. /**
  61881. * Gets underlying native buffer
  61882. * @returns underlying native buffer
  61883. */
  61884. getBuffer(): Nullable<WebGLBuffer>;
  61885. /**
  61886. * Gets the stride in float32 units (i.e. byte stride / 4).
  61887. * May not be an integer if the byte stride is not divisible by 4.
  61888. * DEPRECATED. Use byteStride instead.
  61889. * @returns the stride in float32 units
  61890. */
  61891. getStrideSize(): number;
  61892. /**
  61893. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61894. * @param data defines the data to store
  61895. */
  61896. create(data?: Nullable<DataArray>): void;
  61897. /** @hidden */
  61898. _rebuild(): void;
  61899. /**
  61900. * Update current buffer data
  61901. * @param data defines the data to store
  61902. */
  61903. update(data: DataArray): void;
  61904. /**
  61905. * Updates the data directly.
  61906. * @param data the new data
  61907. * @param offset the new offset
  61908. * @param vertexCount the vertex count (optional)
  61909. * @param useBytes set to true if the offset is in bytes
  61910. */
  61911. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  61912. /**
  61913. * Release all resources
  61914. */
  61915. dispose(): void;
  61916. }
  61917. /**
  61918. * Specialized buffer used to store vertex data
  61919. */
  61920. export class VertexBuffer {
  61921. /** @hidden */
  61922. _buffer: Buffer;
  61923. private _kind;
  61924. private _size;
  61925. private _ownsBuffer;
  61926. private _instanced;
  61927. private _instanceDivisor;
  61928. /**
  61929. * The byte type.
  61930. */
  61931. static readonly BYTE: number;
  61932. /**
  61933. * The unsigned byte type.
  61934. */
  61935. static readonly UNSIGNED_BYTE: number;
  61936. /**
  61937. * The short type.
  61938. */
  61939. static readonly SHORT: number;
  61940. /**
  61941. * The unsigned short type.
  61942. */
  61943. static readonly UNSIGNED_SHORT: number;
  61944. /**
  61945. * The integer type.
  61946. */
  61947. static readonly INT: number;
  61948. /**
  61949. * The unsigned integer type.
  61950. */
  61951. static readonly UNSIGNED_INT: number;
  61952. /**
  61953. * The float type.
  61954. */
  61955. static readonly FLOAT: number;
  61956. /**
  61957. * Gets or sets the instance divisor when in instanced mode
  61958. */
  61959. instanceDivisor: number;
  61960. /**
  61961. * Gets the byte stride.
  61962. */
  61963. readonly byteStride: number;
  61964. /**
  61965. * Gets the byte offset.
  61966. */
  61967. readonly byteOffset: number;
  61968. /**
  61969. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  61970. */
  61971. readonly normalized: boolean;
  61972. /**
  61973. * Gets the data type of each component in the array.
  61974. */
  61975. readonly type: number;
  61976. /**
  61977. * Constructor
  61978. * @param engine the engine
  61979. * @param data the data to use for this vertex buffer
  61980. * @param kind the vertex buffer kind
  61981. * @param updatable whether the data is updatable
  61982. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61983. * @param stride the stride (optional)
  61984. * @param instanced whether the buffer is instanced (optional)
  61985. * @param offset the offset of the data (optional)
  61986. * @param size the number of components (optional)
  61987. * @param type the type of the component (optional)
  61988. * @param normalized whether the data contains normalized data (optional)
  61989. * @param useBytes set to true if stride and offset are in bytes (optional)
  61990. */
  61991. 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);
  61992. /** @hidden */
  61993. _rebuild(): void;
  61994. /**
  61995. * Returns the kind of the VertexBuffer (string)
  61996. * @returns a string
  61997. */
  61998. getKind(): string;
  61999. /**
  62000. * Gets a boolean indicating if the VertexBuffer is updatable?
  62001. * @returns true if the buffer is updatable
  62002. */
  62003. isUpdatable(): boolean;
  62004. /**
  62005. * Gets current buffer's data
  62006. * @returns a DataArray or null
  62007. */
  62008. getData(): Nullable<DataArray>;
  62009. /**
  62010. * Gets underlying native buffer
  62011. * @returns underlying native buffer
  62012. */
  62013. getBuffer(): Nullable<WebGLBuffer>;
  62014. /**
  62015. * Gets the stride in float32 units (i.e. byte stride / 4).
  62016. * May not be an integer if the byte stride is not divisible by 4.
  62017. * DEPRECATED. Use byteStride instead.
  62018. * @returns the stride in float32 units
  62019. */
  62020. getStrideSize(): number;
  62021. /**
  62022. * Returns the offset as a multiple of the type byte length.
  62023. * DEPRECATED. Use byteOffset instead.
  62024. * @returns the offset in bytes
  62025. */
  62026. getOffset(): number;
  62027. /**
  62028. * Returns the number of components per vertex attribute (integer)
  62029. * @returns the size in float
  62030. */
  62031. getSize(): number;
  62032. /**
  62033. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62034. * @returns true if this buffer is instanced
  62035. */
  62036. getIsInstanced(): boolean;
  62037. /**
  62038. * Returns the instancing divisor, zero for non-instanced (integer).
  62039. * @returns a number
  62040. */
  62041. getInstanceDivisor(): number;
  62042. /**
  62043. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62044. * @param data defines the data to store
  62045. */
  62046. create(data?: DataArray): void;
  62047. /**
  62048. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62049. * This function will create a new buffer if the current one is not updatable
  62050. * @param data defines the data to store
  62051. */
  62052. update(data: DataArray): void;
  62053. /**
  62054. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62055. * Returns the directly updated WebGLBuffer.
  62056. * @param data the new data
  62057. * @param offset the new offset
  62058. * @param useBytes set to true if the offset is in bytes
  62059. */
  62060. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62061. /**
  62062. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62063. */
  62064. dispose(): void;
  62065. /**
  62066. * Enumerates each value of this vertex buffer as numbers.
  62067. * @param count the number of values to enumerate
  62068. * @param callback the callback function called for each value
  62069. */
  62070. forEach(count: number, callback: (value: number, index: number) => void): void;
  62071. /**
  62072. * Positions
  62073. */
  62074. static readonly PositionKind: string;
  62075. /**
  62076. * Normals
  62077. */
  62078. static readonly NormalKind: string;
  62079. /**
  62080. * Tangents
  62081. */
  62082. static readonly TangentKind: string;
  62083. /**
  62084. * Texture coordinates
  62085. */
  62086. static readonly UVKind: string;
  62087. /**
  62088. * Texture coordinates 2
  62089. */
  62090. static readonly UV2Kind: string;
  62091. /**
  62092. * Texture coordinates 3
  62093. */
  62094. static readonly UV3Kind: string;
  62095. /**
  62096. * Texture coordinates 4
  62097. */
  62098. static readonly UV4Kind: string;
  62099. /**
  62100. * Texture coordinates 5
  62101. */
  62102. static readonly UV5Kind: string;
  62103. /**
  62104. * Texture coordinates 6
  62105. */
  62106. static readonly UV6Kind: string;
  62107. /**
  62108. * Colors
  62109. */
  62110. static readonly ColorKind: string;
  62111. /**
  62112. * Matrix indices (for bones)
  62113. */
  62114. static readonly MatricesIndicesKind: string;
  62115. /**
  62116. * Matrix weights (for bones)
  62117. */
  62118. static readonly MatricesWeightsKind: string;
  62119. /**
  62120. * Additional matrix indices (for bones)
  62121. */
  62122. static readonly MatricesIndicesExtraKind: string;
  62123. /**
  62124. * Additional matrix weights (for bones)
  62125. */
  62126. static readonly MatricesWeightsExtraKind: string;
  62127. /**
  62128. * Deduces the stride given a kind.
  62129. * @param kind The kind string to deduce
  62130. * @returns The deduced stride
  62131. */
  62132. static DeduceStride(kind: string): number;
  62133. /**
  62134. * Gets the byte length of the given type.
  62135. * @param type the type
  62136. * @returns the number of bytes
  62137. */
  62138. static GetTypeByteLength(type: number): number;
  62139. /**
  62140. * Enumerates each value of the given parameters as numbers.
  62141. * @param data the data to enumerate
  62142. * @param byteOffset the byte offset of the data
  62143. * @param byteStride the byte stride of the data
  62144. * @param componentCount the number of components per element
  62145. * @param componentType the type of the component
  62146. * @param count the total number of components
  62147. * @param normalized whether the data is normalized
  62148. * @param callback the callback function called for each value
  62149. */
  62150. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62151. private static _GetFloatValue;
  62152. }
  62153. }
  62154. declare module BABYLON {
  62155. /**
  62156. * Class representing spherical polynomial coefficients to the 3rd degree
  62157. */
  62158. export class SphericalPolynomial {
  62159. /**
  62160. * The x coefficients of the spherical polynomial
  62161. */
  62162. x: Vector3;
  62163. /**
  62164. * The y coefficients of the spherical polynomial
  62165. */
  62166. y: Vector3;
  62167. /**
  62168. * The z coefficients of the spherical polynomial
  62169. */
  62170. z: Vector3;
  62171. /**
  62172. * The xx coefficients of the spherical polynomial
  62173. */
  62174. xx: Vector3;
  62175. /**
  62176. * The yy coefficients of the spherical polynomial
  62177. */
  62178. yy: Vector3;
  62179. /**
  62180. * The zz coefficients of the spherical polynomial
  62181. */
  62182. zz: Vector3;
  62183. /**
  62184. * The xy coefficients of the spherical polynomial
  62185. */
  62186. xy: Vector3;
  62187. /**
  62188. * The yz coefficients of the spherical polynomial
  62189. */
  62190. yz: Vector3;
  62191. /**
  62192. * The zx coefficients of the spherical polynomial
  62193. */
  62194. zx: Vector3;
  62195. /**
  62196. * Adds an ambient color to the spherical polynomial
  62197. * @param color the color to add
  62198. */
  62199. addAmbient(color: Color3): void;
  62200. /**
  62201. * Scales the spherical polynomial by the given amount
  62202. * @param scale the amount to scale
  62203. */
  62204. scale(scale: number): void;
  62205. /**
  62206. * Gets the spherical polynomial from harmonics
  62207. * @param harmonics the spherical harmonics
  62208. * @returns the spherical polynomial
  62209. */
  62210. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62211. /**
  62212. * Constructs a spherical polynomial from an array.
  62213. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62214. * @returns the spherical polynomial
  62215. */
  62216. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62217. }
  62218. /**
  62219. * Class representing spherical harmonics coefficients to the 3rd degree
  62220. */
  62221. export class SphericalHarmonics {
  62222. /**
  62223. * The l0,0 coefficients of the spherical harmonics
  62224. */
  62225. l00: Vector3;
  62226. /**
  62227. * The l1,-1 coefficients of the spherical harmonics
  62228. */
  62229. l1_1: Vector3;
  62230. /**
  62231. * The l1,0 coefficients of the spherical harmonics
  62232. */
  62233. l10: Vector3;
  62234. /**
  62235. * The l1,1 coefficients of the spherical harmonics
  62236. */
  62237. l11: Vector3;
  62238. /**
  62239. * The l2,-2 coefficients of the spherical harmonics
  62240. */
  62241. l2_2: Vector3;
  62242. /**
  62243. * The l2,-1 coefficients of the spherical harmonics
  62244. */
  62245. l2_1: Vector3;
  62246. /**
  62247. * The l2,0 coefficients of the spherical harmonics
  62248. */
  62249. l20: Vector3;
  62250. /**
  62251. * The l2,1 coefficients of the spherical harmonics
  62252. */
  62253. l21: Vector3;
  62254. /**
  62255. * The l2,2 coefficients of the spherical harmonics
  62256. */
  62257. lL22: Vector3;
  62258. /**
  62259. * Adds a light to the spherical harmonics
  62260. * @param direction the direction of the light
  62261. * @param color the color of the light
  62262. * @param deltaSolidAngle the delta solid angle of the light
  62263. */
  62264. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62265. /**
  62266. * Scales the spherical harmonics by the given amount
  62267. * @param scale the amount to scale
  62268. */
  62269. scale(scale: number): void;
  62270. /**
  62271. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62272. *
  62273. * ```
  62274. * E_lm = A_l * L_lm
  62275. * ```
  62276. *
  62277. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62278. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62279. * the scaling factors are given in equation 9.
  62280. */
  62281. convertIncidentRadianceToIrradiance(): void;
  62282. /**
  62283. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62284. *
  62285. * ```
  62286. * L = (1/pi) * E * rho
  62287. * ```
  62288. *
  62289. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62290. */
  62291. convertIrradianceToLambertianRadiance(): void;
  62292. /**
  62293. * Gets the spherical harmonics from polynomial
  62294. * @param polynomial the spherical polynomial
  62295. * @returns the spherical harmonics
  62296. */
  62297. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62298. /**
  62299. * Constructs a spherical harmonics from an array.
  62300. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62301. * @returns the spherical harmonics
  62302. */
  62303. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62304. }
  62305. }
  62306. declare module BABYLON {
  62307. /**
  62308. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62309. */
  62310. export interface CubeMapInfo {
  62311. /**
  62312. * The pixel array for the front face.
  62313. * This is stored in format, left to right, up to down format.
  62314. */
  62315. front: Nullable<ArrayBufferView>;
  62316. /**
  62317. * The pixel array for the back face.
  62318. * This is stored in format, left to right, up to down format.
  62319. */
  62320. back: Nullable<ArrayBufferView>;
  62321. /**
  62322. * The pixel array for the left face.
  62323. * This is stored in format, left to right, up to down format.
  62324. */
  62325. left: Nullable<ArrayBufferView>;
  62326. /**
  62327. * The pixel array for the right face.
  62328. * This is stored in format, left to right, up to down format.
  62329. */
  62330. right: Nullable<ArrayBufferView>;
  62331. /**
  62332. * The pixel array for the up face.
  62333. * This is stored in format, left to right, up to down format.
  62334. */
  62335. up: Nullable<ArrayBufferView>;
  62336. /**
  62337. * The pixel array for the down face.
  62338. * This is stored in format, left to right, up to down format.
  62339. */
  62340. down: Nullable<ArrayBufferView>;
  62341. /**
  62342. * The size of the cubemap stored.
  62343. *
  62344. * Each faces will be size * size pixels.
  62345. */
  62346. size: number;
  62347. /**
  62348. * The format of the texture.
  62349. *
  62350. * RGBA, RGB.
  62351. */
  62352. format: number;
  62353. /**
  62354. * The type of the texture data.
  62355. *
  62356. * UNSIGNED_INT, FLOAT.
  62357. */
  62358. type: number;
  62359. /**
  62360. * Specifies whether the texture is in gamma space.
  62361. */
  62362. gammaSpace: boolean;
  62363. }
  62364. /**
  62365. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62366. */
  62367. export class PanoramaToCubeMapTools {
  62368. private static FACE_FRONT;
  62369. private static FACE_BACK;
  62370. private static FACE_RIGHT;
  62371. private static FACE_LEFT;
  62372. private static FACE_DOWN;
  62373. private static FACE_UP;
  62374. /**
  62375. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62376. *
  62377. * @param float32Array The source data.
  62378. * @param inputWidth The width of the input panorama.
  62379. * @param inputHeight The height of the input panorama.
  62380. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62381. * @return The cubemap data
  62382. */
  62383. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62384. private static CreateCubemapTexture;
  62385. private static CalcProjectionSpherical;
  62386. }
  62387. }
  62388. declare module BABYLON {
  62389. /**
  62390. * Helper class dealing with the extraction of spherical polynomial dataArray
  62391. * from a cube map.
  62392. */
  62393. export class CubeMapToSphericalPolynomialTools {
  62394. private static FileFaces;
  62395. /**
  62396. * Converts a texture to the according Spherical Polynomial data.
  62397. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62398. *
  62399. * @param texture The texture to extract the information from.
  62400. * @return The Spherical Polynomial data.
  62401. */
  62402. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62403. /**
  62404. * Converts a cubemap to the according Spherical Polynomial data.
  62405. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62406. *
  62407. * @param cubeInfo The Cube map to extract the information from.
  62408. * @return The Spherical Polynomial data.
  62409. */
  62410. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62411. }
  62412. }
  62413. declare module BABYLON {
  62414. /**
  62415. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62416. * during the life time of the application.
  62417. */
  62418. export class EngineStore {
  62419. /** Gets the list of created engines */
  62420. static Instances: Engine[];
  62421. /**
  62422. * Gets the latest created engine
  62423. */
  62424. static readonly LastCreatedEngine: Nullable<Engine>;
  62425. /**
  62426. * Gets the latest created scene
  62427. */
  62428. static readonly LastCreatedScene: Nullable<Scene>;
  62429. }
  62430. }
  62431. declare module BABYLON {
  62432. /**
  62433. * Define options used to create a render target texture
  62434. */
  62435. export class RenderTargetCreationOptions {
  62436. /**
  62437. * Specifies is mipmaps must be generated
  62438. */
  62439. generateMipMaps?: boolean;
  62440. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62441. generateDepthBuffer?: boolean;
  62442. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62443. generateStencilBuffer?: boolean;
  62444. /** Defines texture type (int by default) */
  62445. type?: number;
  62446. /** Defines sampling mode (trilinear by default) */
  62447. samplingMode?: number;
  62448. /** Defines format (RGBA by default) */
  62449. format?: number;
  62450. }
  62451. }
  62452. declare module BABYLON {
  62453. /**
  62454. * @hidden
  62455. **/
  62456. export class _AlphaState {
  62457. private _isAlphaBlendDirty;
  62458. private _isBlendFunctionParametersDirty;
  62459. private _isBlendEquationParametersDirty;
  62460. private _isBlendConstantsDirty;
  62461. private _alphaBlend;
  62462. private _blendFunctionParameters;
  62463. private _blendEquationParameters;
  62464. private _blendConstants;
  62465. /**
  62466. * Initializes the state.
  62467. */
  62468. constructor();
  62469. readonly isDirty: boolean;
  62470. alphaBlend: boolean;
  62471. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62472. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62473. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62474. reset(): void;
  62475. apply(gl: WebGLRenderingContext): void;
  62476. }
  62477. }
  62478. declare module BABYLON {
  62479. /**
  62480. * @hidden
  62481. **/
  62482. export class _DepthCullingState {
  62483. private _isDepthTestDirty;
  62484. private _isDepthMaskDirty;
  62485. private _isDepthFuncDirty;
  62486. private _isCullFaceDirty;
  62487. private _isCullDirty;
  62488. private _isZOffsetDirty;
  62489. private _isFrontFaceDirty;
  62490. private _depthTest;
  62491. private _depthMask;
  62492. private _depthFunc;
  62493. private _cull;
  62494. private _cullFace;
  62495. private _zOffset;
  62496. private _frontFace;
  62497. /**
  62498. * Initializes the state.
  62499. */
  62500. constructor();
  62501. readonly isDirty: boolean;
  62502. zOffset: number;
  62503. cullFace: Nullable<number>;
  62504. cull: Nullable<boolean>;
  62505. depthFunc: Nullable<number>;
  62506. depthMask: boolean;
  62507. depthTest: boolean;
  62508. frontFace: Nullable<number>;
  62509. reset(): void;
  62510. apply(gl: WebGLRenderingContext): void;
  62511. }
  62512. }
  62513. declare module BABYLON {
  62514. /**
  62515. * @hidden
  62516. **/
  62517. export class _StencilState {
  62518. /** 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 */
  62519. static readonly ALWAYS: number;
  62520. /** Passed to stencilOperation to specify that stencil value must be kept */
  62521. static readonly KEEP: number;
  62522. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62523. static readonly REPLACE: number;
  62524. private _isStencilTestDirty;
  62525. private _isStencilMaskDirty;
  62526. private _isStencilFuncDirty;
  62527. private _isStencilOpDirty;
  62528. private _stencilTest;
  62529. private _stencilMask;
  62530. private _stencilFunc;
  62531. private _stencilFuncRef;
  62532. private _stencilFuncMask;
  62533. private _stencilOpStencilFail;
  62534. private _stencilOpDepthFail;
  62535. private _stencilOpStencilDepthPass;
  62536. readonly isDirty: boolean;
  62537. stencilFunc: number;
  62538. stencilFuncRef: number;
  62539. stencilFuncMask: number;
  62540. stencilOpStencilFail: number;
  62541. stencilOpDepthFail: number;
  62542. stencilOpStencilDepthPass: number;
  62543. stencilMask: number;
  62544. stencilTest: boolean;
  62545. constructor();
  62546. reset(): void;
  62547. apply(gl: WebGLRenderingContext): void;
  62548. }
  62549. }
  62550. declare module BABYLON {
  62551. /**
  62552. * @hidden
  62553. **/
  62554. export class _TimeToken {
  62555. _startTimeQuery: Nullable<WebGLQuery>;
  62556. _endTimeQuery: Nullable<WebGLQuery>;
  62557. _timeElapsedQuery: Nullable<WebGLQuery>;
  62558. _timeElapsedQueryEnded: boolean;
  62559. }
  62560. }
  62561. declare module BABYLON {
  62562. /**
  62563. * Internal interface used to track InternalTexture already bound to the GL context
  62564. */
  62565. export interface IInternalTextureTracker {
  62566. /**
  62567. * Gets or set the previous tracker in the list
  62568. */
  62569. previous: Nullable<IInternalTextureTracker>;
  62570. /**
  62571. * Gets or set the next tracker in the list
  62572. */
  62573. next: Nullable<IInternalTextureTracker>;
  62574. }
  62575. /**
  62576. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62577. */
  62578. export class DummyInternalTextureTracker {
  62579. /**
  62580. * Gets or set the previous tracker in the list
  62581. */
  62582. previous: Nullable<IInternalTextureTracker>;
  62583. /**
  62584. * Gets or set the next tracker in the list
  62585. */
  62586. next: Nullable<IInternalTextureTracker>;
  62587. }
  62588. }
  62589. declare module BABYLON {
  62590. /**
  62591. * Class used to store data associated with WebGL texture data for the engine
  62592. * This class should not be used directly
  62593. */
  62594. export class InternalTexture implements IInternalTextureTracker {
  62595. /** hidden */
  62596. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62597. /**
  62598. * The source of the texture data is unknown
  62599. */
  62600. static DATASOURCE_UNKNOWN: number;
  62601. /**
  62602. * Texture data comes from an URL
  62603. */
  62604. static DATASOURCE_URL: number;
  62605. /**
  62606. * Texture data is only used for temporary storage
  62607. */
  62608. static DATASOURCE_TEMP: number;
  62609. /**
  62610. * Texture data comes from raw data (ArrayBuffer)
  62611. */
  62612. static DATASOURCE_RAW: number;
  62613. /**
  62614. * Texture content is dynamic (video or dynamic texture)
  62615. */
  62616. static DATASOURCE_DYNAMIC: number;
  62617. /**
  62618. * Texture content is generated by rendering to it
  62619. */
  62620. static DATASOURCE_RENDERTARGET: number;
  62621. /**
  62622. * Texture content is part of a multi render target process
  62623. */
  62624. static DATASOURCE_MULTIRENDERTARGET: number;
  62625. /**
  62626. * Texture data comes from a cube data file
  62627. */
  62628. static DATASOURCE_CUBE: number;
  62629. /**
  62630. * Texture data comes from a raw cube data
  62631. */
  62632. static DATASOURCE_CUBERAW: number;
  62633. /**
  62634. * Texture data come from a prefiltered cube data file
  62635. */
  62636. static DATASOURCE_CUBEPREFILTERED: number;
  62637. /**
  62638. * Texture content is raw 3D data
  62639. */
  62640. static DATASOURCE_RAW3D: number;
  62641. /**
  62642. * Texture content is a depth texture
  62643. */
  62644. static DATASOURCE_DEPTHTEXTURE: number;
  62645. /**
  62646. * Texture data comes from a raw cube data encoded with RGBD
  62647. */
  62648. static DATASOURCE_CUBERAW_RGBD: number;
  62649. /**
  62650. * Defines if the texture is ready
  62651. */
  62652. isReady: boolean;
  62653. /**
  62654. * Defines if the texture is a cube texture
  62655. */
  62656. isCube: boolean;
  62657. /**
  62658. * Defines if the texture contains 3D data
  62659. */
  62660. is3D: boolean;
  62661. /**
  62662. * Gets the URL used to load this texture
  62663. */
  62664. url: string;
  62665. /**
  62666. * Gets the sampling mode of the texture
  62667. */
  62668. samplingMode: number;
  62669. /**
  62670. * Gets a boolean indicating if the texture needs mipmaps generation
  62671. */
  62672. generateMipMaps: boolean;
  62673. /**
  62674. * Gets the number of samples used by the texture (WebGL2+ only)
  62675. */
  62676. samples: number;
  62677. /**
  62678. * Gets the type of the texture (int, float...)
  62679. */
  62680. type: number;
  62681. /**
  62682. * Gets the format of the texture (RGB, RGBA...)
  62683. */
  62684. format: number;
  62685. /**
  62686. * Observable called when the texture is loaded
  62687. */
  62688. onLoadedObservable: Observable<InternalTexture>;
  62689. /**
  62690. * Gets the width of the texture
  62691. */
  62692. width: number;
  62693. /**
  62694. * Gets the height of the texture
  62695. */
  62696. height: number;
  62697. /**
  62698. * Gets the depth of the texture
  62699. */
  62700. depth: number;
  62701. /**
  62702. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  62703. */
  62704. baseWidth: number;
  62705. /**
  62706. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  62707. */
  62708. baseHeight: number;
  62709. /**
  62710. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  62711. */
  62712. baseDepth: number;
  62713. /**
  62714. * Gets a boolean indicating if the texture is inverted on Y axis
  62715. */
  62716. invertY: boolean;
  62717. /**
  62718. * Gets or set the previous tracker in the list
  62719. */
  62720. previous: Nullable<IInternalTextureTracker>;
  62721. /**
  62722. * Gets or set the next tracker in the list
  62723. */
  62724. next: Nullable<IInternalTextureTracker>;
  62725. /** @hidden */
  62726. _invertVScale: boolean;
  62727. /** @hidden */
  62728. _initialSlot: number;
  62729. /** @hidden */
  62730. _designatedSlot: number;
  62731. /** @hidden */
  62732. _dataSource: number;
  62733. /** @hidden */
  62734. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  62735. /** @hidden */
  62736. _bufferView: Nullable<ArrayBufferView>;
  62737. /** @hidden */
  62738. _bufferViewArray: Nullable<ArrayBufferView[]>;
  62739. /** @hidden */
  62740. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  62741. /** @hidden */
  62742. _size: number;
  62743. /** @hidden */
  62744. _extension: string;
  62745. /** @hidden */
  62746. _files: Nullable<string[]>;
  62747. /** @hidden */
  62748. _workingCanvas: HTMLCanvasElement;
  62749. /** @hidden */
  62750. _workingContext: CanvasRenderingContext2D;
  62751. /** @hidden */
  62752. _framebuffer: Nullable<WebGLFramebuffer>;
  62753. /** @hidden */
  62754. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  62755. /** @hidden */
  62756. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  62757. /** @hidden */
  62758. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  62759. /** @hidden */
  62760. _attachments: Nullable<number[]>;
  62761. /** @hidden */
  62762. _cachedCoordinatesMode: Nullable<number>;
  62763. /** @hidden */
  62764. _cachedWrapU: Nullable<number>;
  62765. /** @hidden */
  62766. _cachedWrapV: Nullable<number>;
  62767. /** @hidden */
  62768. _cachedWrapR: Nullable<number>;
  62769. /** @hidden */
  62770. _cachedAnisotropicFilteringLevel: Nullable<number>;
  62771. /** @hidden */
  62772. _isDisabled: boolean;
  62773. /** @hidden */
  62774. _compression: Nullable<string>;
  62775. /** @hidden */
  62776. _generateStencilBuffer: boolean;
  62777. /** @hidden */
  62778. _generateDepthBuffer: boolean;
  62779. /** @hidden */
  62780. _comparisonFunction: number;
  62781. /** @hidden */
  62782. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  62783. /** @hidden */
  62784. _lodGenerationScale: number;
  62785. /** @hidden */
  62786. _lodGenerationOffset: number;
  62787. /** @hidden */
  62788. _lodTextureHigh: BaseTexture;
  62789. /** @hidden */
  62790. _lodTextureMid: BaseTexture;
  62791. /** @hidden */
  62792. _lodTextureLow: BaseTexture;
  62793. /** @hidden */
  62794. _isRGBD: boolean;
  62795. /** @hidden */
  62796. _webGLTexture: Nullable<WebGLTexture>;
  62797. /** @hidden */
  62798. _references: number;
  62799. private _engine;
  62800. /**
  62801. * Gets the Engine the texture belongs to.
  62802. * @returns The babylon engine
  62803. */
  62804. getEngine(): Engine;
  62805. /**
  62806. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  62807. */
  62808. readonly dataSource: number;
  62809. /**
  62810. * Creates a new InternalTexture
  62811. * @param engine defines the engine to use
  62812. * @param dataSource defines the type of data that will be used
  62813. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62814. */
  62815. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  62816. /**
  62817. * Increments the number of references (ie. the number of Texture that point to it)
  62818. */
  62819. incrementReferences(): void;
  62820. /**
  62821. * Change the size of the texture (not the size of the content)
  62822. * @param width defines the new width
  62823. * @param height defines the new height
  62824. * @param depth defines the new depth (1 by default)
  62825. */
  62826. updateSize(width: int, height: int, depth?: int): void;
  62827. /** @hidden */
  62828. _rebuild(): void;
  62829. /** @hidden */
  62830. _swapAndDie(target: InternalTexture): void;
  62831. /**
  62832. * Dispose the current allocated resources
  62833. */
  62834. dispose(): void;
  62835. }
  62836. }
  62837. declare module BABYLON {
  62838. /**
  62839. * This represents the main contract an easing function should follow.
  62840. * Easing functions are used throughout the animation system.
  62841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62842. */
  62843. export interface IEasingFunction {
  62844. /**
  62845. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62846. * of the easing function.
  62847. * The link below provides some of the most common examples of easing functions.
  62848. * @see https://easings.net/
  62849. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62850. * @returns the corresponding value on the curve defined by the easing function
  62851. */
  62852. ease(gradient: number): number;
  62853. }
  62854. /**
  62855. * Base class used for every default easing function.
  62856. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62857. */
  62858. export class EasingFunction implements IEasingFunction {
  62859. /**
  62860. * Interpolation follows the mathematical formula associated with the easing function.
  62861. */
  62862. static readonly EASINGMODE_EASEIN: number;
  62863. /**
  62864. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  62865. */
  62866. static readonly EASINGMODE_EASEOUT: number;
  62867. /**
  62868. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  62869. */
  62870. static readonly EASINGMODE_EASEINOUT: number;
  62871. private _easingMode;
  62872. /**
  62873. * Sets the easing mode of the current function.
  62874. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  62875. */
  62876. setEasingMode(easingMode: number): void;
  62877. /**
  62878. * Gets the current easing mode.
  62879. * @returns the easing mode
  62880. */
  62881. getEasingMode(): number;
  62882. /**
  62883. * @hidden
  62884. */
  62885. easeInCore(gradient: number): number;
  62886. /**
  62887. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62888. * of the easing function.
  62889. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62890. * @returns the corresponding value on the curve defined by the easing function
  62891. */
  62892. ease(gradient: number): number;
  62893. }
  62894. /**
  62895. * Easing function with a circle shape (see link below).
  62896. * @see https://easings.net/#easeInCirc
  62897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62898. */
  62899. export class CircleEase extends EasingFunction implements IEasingFunction {
  62900. /** @hidden */
  62901. easeInCore(gradient: number): number;
  62902. }
  62903. /**
  62904. * Easing function with a ease back shape (see link below).
  62905. * @see https://easings.net/#easeInBack
  62906. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62907. */
  62908. export class BackEase extends EasingFunction implements IEasingFunction {
  62909. /** Defines the amplitude of the function */
  62910. amplitude: number;
  62911. /**
  62912. * Instantiates a back ease easing
  62913. * @see https://easings.net/#easeInBack
  62914. * @param amplitude Defines the amplitude of the function
  62915. */
  62916. constructor(
  62917. /** Defines the amplitude of the function */
  62918. amplitude?: number);
  62919. /** @hidden */
  62920. easeInCore(gradient: number): number;
  62921. }
  62922. /**
  62923. * Easing function with a bouncing shape (see link below).
  62924. * @see https://easings.net/#easeInBounce
  62925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62926. */
  62927. export class BounceEase extends EasingFunction implements IEasingFunction {
  62928. /** Defines the number of bounces */
  62929. bounces: number;
  62930. /** Defines the amplitude of the bounce */
  62931. bounciness: number;
  62932. /**
  62933. * Instantiates a bounce easing
  62934. * @see https://easings.net/#easeInBounce
  62935. * @param bounces Defines the number of bounces
  62936. * @param bounciness Defines the amplitude of the bounce
  62937. */
  62938. constructor(
  62939. /** Defines the number of bounces */
  62940. bounces?: number,
  62941. /** Defines the amplitude of the bounce */
  62942. bounciness?: number);
  62943. /** @hidden */
  62944. easeInCore(gradient: number): number;
  62945. }
  62946. /**
  62947. * Easing function with a power of 3 shape (see link below).
  62948. * @see https://easings.net/#easeInCubic
  62949. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62950. */
  62951. export class CubicEase extends EasingFunction implements IEasingFunction {
  62952. /** @hidden */
  62953. easeInCore(gradient: number): number;
  62954. }
  62955. /**
  62956. * Easing function with an elastic shape (see link below).
  62957. * @see https://easings.net/#easeInElastic
  62958. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62959. */
  62960. export class ElasticEase extends EasingFunction implements IEasingFunction {
  62961. /** Defines the number of oscillations*/
  62962. oscillations: number;
  62963. /** Defines the amplitude of the oscillations*/
  62964. springiness: number;
  62965. /**
  62966. * Instantiates an elastic easing function
  62967. * @see https://easings.net/#easeInElastic
  62968. * @param oscillations Defines the number of oscillations
  62969. * @param springiness Defines the amplitude of the oscillations
  62970. */
  62971. constructor(
  62972. /** Defines the number of oscillations*/
  62973. oscillations?: number,
  62974. /** Defines the amplitude of the oscillations*/
  62975. springiness?: number);
  62976. /** @hidden */
  62977. easeInCore(gradient: number): number;
  62978. }
  62979. /**
  62980. * Easing function with an exponential shape (see link below).
  62981. * @see https://easings.net/#easeInExpo
  62982. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62983. */
  62984. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  62985. /** Defines the exponent of the function */
  62986. exponent: number;
  62987. /**
  62988. * Instantiates an exponential easing function
  62989. * @see https://easings.net/#easeInExpo
  62990. * @param exponent Defines the exponent of the function
  62991. */
  62992. constructor(
  62993. /** Defines the exponent of the function */
  62994. exponent?: number);
  62995. /** @hidden */
  62996. easeInCore(gradient: number): number;
  62997. }
  62998. /**
  62999. * Easing function with a power shape (see link below).
  63000. * @see https://easings.net/#easeInQuad
  63001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63002. */
  63003. export class PowerEase extends EasingFunction implements IEasingFunction {
  63004. /** Defines the power of the function */
  63005. power: number;
  63006. /**
  63007. * Instantiates an power base easing function
  63008. * @see https://easings.net/#easeInQuad
  63009. * @param power Defines the power of the function
  63010. */
  63011. constructor(
  63012. /** Defines the power of the function */
  63013. power?: number);
  63014. /** @hidden */
  63015. easeInCore(gradient: number): number;
  63016. }
  63017. /**
  63018. * Easing function with a power of 2 shape (see link below).
  63019. * @see https://easings.net/#easeInQuad
  63020. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63021. */
  63022. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63023. /** @hidden */
  63024. easeInCore(gradient: number): number;
  63025. }
  63026. /**
  63027. * Easing function with a power of 4 shape (see link below).
  63028. * @see https://easings.net/#easeInQuart
  63029. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63030. */
  63031. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63032. /** @hidden */
  63033. easeInCore(gradient: number): number;
  63034. }
  63035. /**
  63036. * Easing function with a power of 5 shape (see link below).
  63037. * @see https://easings.net/#easeInQuint
  63038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63039. */
  63040. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63041. /** @hidden */
  63042. easeInCore(gradient: number): number;
  63043. }
  63044. /**
  63045. * Easing function with a sin shape (see link below).
  63046. * @see https://easings.net/#easeInSine
  63047. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63048. */
  63049. export class SineEase extends EasingFunction implements IEasingFunction {
  63050. /** @hidden */
  63051. easeInCore(gradient: number): number;
  63052. }
  63053. /**
  63054. * Easing function with a bezier shape (see link below).
  63055. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63057. */
  63058. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63059. /** Defines the x component of the start tangent in the bezier curve */
  63060. x1: number;
  63061. /** Defines the y component of the start tangent in the bezier curve */
  63062. y1: number;
  63063. /** Defines the x component of the end tangent in the bezier curve */
  63064. x2: number;
  63065. /** Defines the y component of the end tangent in the bezier curve */
  63066. y2: number;
  63067. /**
  63068. * Instantiates a bezier function
  63069. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63070. * @param x1 Defines the x component of the start tangent in the bezier curve
  63071. * @param y1 Defines the y component of the start tangent in the bezier curve
  63072. * @param x2 Defines the x component of the end tangent in the bezier curve
  63073. * @param y2 Defines the y component of the end tangent in the bezier curve
  63074. */
  63075. constructor(
  63076. /** Defines the x component of the start tangent in the bezier curve */
  63077. x1?: number,
  63078. /** Defines the y component of the start tangent in the bezier curve */
  63079. y1?: number,
  63080. /** Defines the x component of the end tangent in the bezier curve */
  63081. x2?: number,
  63082. /** Defines the y component of the end tangent in the bezier curve */
  63083. y2?: number);
  63084. /** @hidden */
  63085. easeInCore(gradient: number): number;
  63086. }
  63087. }
  63088. declare module BABYLON {
  63089. /**
  63090. * Defines an interface which represents an animation key frame
  63091. */
  63092. export interface IAnimationKey {
  63093. /**
  63094. * Frame of the key frame
  63095. */
  63096. frame: number;
  63097. /**
  63098. * Value at the specifies key frame
  63099. */
  63100. value: any;
  63101. /**
  63102. * The input tangent for the cubic hermite spline
  63103. */
  63104. inTangent?: any;
  63105. /**
  63106. * The output tangent for the cubic hermite spline
  63107. */
  63108. outTangent?: any;
  63109. /**
  63110. * The animation interpolation type
  63111. */
  63112. interpolation?: AnimationKeyInterpolation;
  63113. }
  63114. /**
  63115. * Enum for the animation key frame interpolation type
  63116. */
  63117. export enum AnimationKeyInterpolation {
  63118. /**
  63119. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63120. */
  63121. STEP = 1
  63122. }
  63123. }
  63124. declare module BABYLON {
  63125. /**
  63126. * Represents the range of an animation
  63127. */
  63128. export class AnimationRange {
  63129. /**The name of the animation range**/
  63130. name: string;
  63131. /**The starting frame of the animation */
  63132. from: number;
  63133. /**The ending frame of the animation*/
  63134. to: number;
  63135. /**
  63136. * Initializes the range of an animation
  63137. * @param name The name of the animation range
  63138. * @param from The starting frame of the animation
  63139. * @param to The ending frame of the animation
  63140. */
  63141. constructor(
  63142. /**The name of the animation range**/
  63143. name: string,
  63144. /**The starting frame of the animation */
  63145. from: number,
  63146. /**The ending frame of the animation*/
  63147. to: number);
  63148. /**
  63149. * Makes a copy of the animation range
  63150. * @returns A copy of the animation range
  63151. */
  63152. clone(): AnimationRange;
  63153. }
  63154. }
  63155. declare module BABYLON {
  63156. /**
  63157. * Composed of a frame, and an action function
  63158. */
  63159. export class AnimationEvent {
  63160. /** The frame for which the event is triggered **/
  63161. frame: number;
  63162. /** The event to perform when triggered **/
  63163. action: (currentFrame: number) => void;
  63164. /** Specifies if the event should be triggered only once**/
  63165. onlyOnce?: boolean | undefined;
  63166. /**
  63167. * Specifies if the animation event is done
  63168. */
  63169. isDone: boolean;
  63170. /**
  63171. * Initializes the animation event
  63172. * @param frame The frame for which the event is triggered
  63173. * @param action The event to perform when triggered
  63174. * @param onlyOnce Specifies if the event should be triggered only once
  63175. */
  63176. constructor(
  63177. /** The frame for which the event is triggered **/
  63178. frame: number,
  63179. /** The event to perform when triggered **/
  63180. action: (currentFrame: number) => void,
  63181. /** Specifies if the event should be triggered only once**/
  63182. onlyOnce?: boolean | undefined);
  63183. /** @hidden */
  63184. _clone(): AnimationEvent;
  63185. }
  63186. }
  63187. declare module BABYLON {
  63188. /**
  63189. * Interface used to define a behavior
  63190. */
  63191. export interface Behavior<T> {
  63192. /** gets or sets behavior's name */
  63193. name: string;
  63194. /**
  63195. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63196. */
  63197. init(): void;
  63198. /**
  63199. * Called when the behavior is attached to a target
  63200. * @param target defines the target where the behavior is attached to
  63201. */
  63202. attach(target: T): void;
  63203. /**
  63204. * Called when the behavior is detached from its target
  63205. */
  63206. detach(): void;
  63207. }
  63208. /**
  63209. * Interface implemented by classes supporting behaviors
  63210. */
  63211. export interface IBehaviorAware<T> {
  63212. /**
  63213. * Attach a behavior
  63214. * @param behavior defines the behavior to attach
  63215. * @returns the current host
  63216. */
  63217. addBehavior(behavior: Behavior<T>): T;
  63218. /**
  63219. * Remove a behavior from the current object
  63220. * @param behavior defines the behavior to detach
  63221. * @returns the current host
  63222. */
  63223. removeBehavior(behavior: Behavior<T>): T;
  63224. /**
  63225. * Gets a behavior using its name to search
  63226. * @param name defines the name to search
  63227. * @returns the behavior or null if not found
  63228. */
  63229. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63230. }
  63231. }
  63232. declare module BABYLON {
  63233. /**
  63234. * Defines a runtime animation
  63235. */
  63236. export class RuntimeAnimation {
  63237. private _events;
  63238. /**
  63239. * The current frame of the runtime animation
  63240. */
  63241. private _currentFrame;
  63242. /**
  63243. * The animation used by the runtime animation
  63244. */
  63245. private _animation;
  63246. /**
  63247. * The target of the runtime animation
  63248. */
  63249. private _target;
  63250. /**
  63251. * The initiating animatable
  63252. */
  63253. private _host;
  63254. /**
  63255. * The original value of the runtime animation
  63256. */
  63257. private _originalValue;
  63258. /**
  63259. * The original blend value of the runtime animation
  63260. */
  63261. private _originalBlendValue;
  63262. /**
  63263. * The offsets cache of the runtime animation
  63264. */
  63265. private _offsetsCache;
  63266. /**
  63267. * The high limits cache of the runtime animation
  63268. */
  63269. private _highLimitsCache;
  63270. /**
  63271. * Specifies if the runtime animation has been stopped
  63272. */
  63273. private _stopped;
  63274. /**
  63275. * The blending factor of the runtime animation
  63276. */
  63277. private _blendingFactor;
  63278. /**
  63279. * The BabylonJS scene
  63280. */
  63281. private _scene;
  63282. /**
  63283. * The current value of the runtime animation
  63284. */
  63285. private _currentValue;
  63286. /** @hidden */
  63287. _workValue: any;
  63288. /**
  63289. * The active target of the runtime animation
  63290. */
  63291. private _activeTarget;
  63292. /**
  63293. * The target path of the runtime animation
  63294. */
  63295. private _targetPath;
  63296. /**
  63297. * The weight of the runtime animation
  63298. */
  63299. private _weight;
  63300. /**
  63301. * The ratio offset of the runtime animation
  63302. */
  63303. private _ratioOffset;
  63304. /**
  63305. * The previous delay of the runtime animation
  63306. */
  63307. private _previousDelay;
  63308. /**
  63309. * The previous ratio of the runtime animation
  63310. */
  63311. private _previousRatio;
  63312. /**
  63313. * Gets the current frame of the runtime animation
  63314. */
  63315. readonly currentFrame: number;
  63316. /**
  63317. * Gets the weight of the runtime animation
  63318. */
  63319. readonly weight: number;
  63320. /**
  63321. * Gets the current value of the runtime animation
  63322. */
  63323. readonly currentValue: any;
  63324. /**
  63325. * Gets the target path of the runtime animation
  63326. */
  63327. readonly targetPath: string;
  63328. /**
  63329. * Gets the actual target of the runtime animation
  63330. */
  63331. readonly target: any;
  63332. /**
  63333. * Create a new RuntimeAnimation object
  63334. * @param target defines the target of the animation
  63335. * @param animation defines the source animation object
  63336. * @param scene defines the hosting scene
  63337. * @param host defines the initiating Animatable
  63338. */
  63339. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  63340. /**
  63341. * Gets the animation from the runtime animation
  63342. */
  63343. readonly animation: Animation;
  63344. /**
  63345. * Resets the runtime animation to the beginning
  63346. * @param restoreOriginal defines whether to restore the target property to the original value
  63347. */
  63348. reset(restoreOriginal?: boolean): void;
  63349. /**
  63350. * Specifies if the runtime animation is stopped
  63351. * @returns Boolean specifying if the runtime animation is stopped
  63352. */
  63353. isStopped(): boolean;
  63354. /**
  63355. * Disposes of the runtime animation
  63356. */
  63357. dispose(): void;
  63358. /**
  63359. * Interpolates the animation from the current frame
  63360. * @param currentFrame The frame to interpolate the animation to
  63361. * @param repeatCount The number of times that the animation should loop
  63362. * @param loopMode The type of looping mode to use
  63363. * @param offsetValue Animation offset value
  63364. * @param highLimitValue The high limit value
  63365. * @returns The interpolated value
  63366. */
  63367. private _interpolate;
  63368. /**
  63369. * Apply the interpolated value to the target
  63370. * @param currentValue defines the value computed by the animation
  63371. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  63372. */
  63373. setValue(currentValue: any, weight?: number): void;
  63374. private _setValue;
  63375. /**
  63376. * Gets the loop pmode of the runtime animation
  63377. * @returns Loop Mode
  63378. */
  63379. private _getCorrectLoopMode;
  63380. /**
  63381. * Move the current animation to a given frame
  63382. * @param frame defines the frame to move to
  63383. */
  63384. goToFrame(frame: number): void;
  63385. /**
  63386. * @hidden Internal use only
  63387. */
  63388. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  63389. /**
  63390. * Execute the current animation
  63391. * @param delay defines the delay to add to the current frame
  63392. * @param from defines the lower bound of the animation range
  63393. * @param to defines the upper bound of the animation range
  63394. * @param loop defines if the current animation must loop
  63395. * @param speedRatio defines the current speed ratio
  63396. * @param weight defines the weight of the animation (default is -1 so no weight)
  63397. * @param onLoop optional callback called when animation loops
  63398. * @returns a boolean indicating if the animation is running
  63399. */
  63400. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  63401. }
  63402. }
  63403. declare module BABYLON {
  63404. /**
  63405. * @hidden
  63406. */
  63407. export class IntersectionInfo {
  63408. bu: Nullable<number>;
  63409. bv: Nullable<number>;
  63410. distance: number;
  63411. faceId: number;
  63412. subMeshId: number;
  63413. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63414. }
  63415. }
  63416. declare module BABYLON {
  63417. /**
  63418. * Class used to store bounding sphere information
  63419. */
  63420. export class BoundingSphere {
  63421. /**
  63422. * Gets the center of the bounding sphere in local space
  63423. */
  63424. readonly center: Vector3;
  63425. /**
  63426. * Radius of the bounding sphere in local space
  63427. */
  63428. radius: number;
  63429. /**
  63430. * Gets the center of the bounding sphere in world space
  63431. */
  63432. readonly centerWorld: Vector3;
  63433. /**
  63434. * Radius of the bounding sphere in world space
  63435. */
  63436. radiusWorld: number;
  63437. /**
  63438. * Gets the minimum vector in local space
  63439. */
  63440. readonly minimum: Vector3;
  63441. /**
  63442. * Gets the maximum vector in local space
  63443. */
  63444. readonly maximum: Vector3;
  63445. private _worldMatrix;
  63446. private static readonly TmpVector3;
  63447. /**
  63448. * Creates a new bounding sphere
  63449. * @param min defines the minimum vector (in local space)
  63450. * @param max defines the maximum vector (in local space)
  63451. * @param worldMatrix defines the new world matrix
  63452. */
  63453. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63454. /**
  63455. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63456. * @param min defines the new minimum vector (in local space)
  63457. * @param max defines the new maximum vector (in local space)
  63458. * @param worldMatrix defines the new world matrix
  63459. */
  63460. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63461. /**
  63462. * Scale the current bounding sphere by applying a scale factor
  63463. * @param factor defines the scale factor to apply
  63464. * @returns the current bounding box
  63465. */
  63466. scale(factor: number): BoundingSphere;
  63467. /**
  63468. * Gets the world matrix of the bounding box
  63469. * @returns a matrix
  63470. */
  63471. getWorldMatrix(): DeepImmutable<Matrix>;
  63472. /** @hidden */
  63473. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63474. /**
  63475. * Tests if the bounding sphere is intersecting the frustum planes
  63476. * @param frustumPlanes defines the frustum planes to test
  63477. * @returns true if there is an intersection
  63478. */
  63479. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63480. /**
  63481. * Tests if the bounding sphere center is in between the frustum planes.
  63482. * Used for optimistic fast inclusion.
  63483. * @param frustumPlanes defines the frustum planes to test
  63484. * @returns true if the sphere center is in between the frustum planes
  63485. */
  63486. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63487. /**
  63488. * Tests if a point is inside the bounding sphere
  63489. * @param point defines the point to test
  63490. * @returns true if the point is inside the bounding sphere
  63491. */
  63492. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63493. /**
  63494. * Checks if two sphere intersct
  63495. * @param sphere0 sphere 0
  63496. * @param sphere1 sphere 1
  63497. * @returns true if the speres intersect
  63498. */
  63499. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * Class used to store bounding box information
  63505. */
  63506. export class BoundingBox implements ICullable {
  63507. /**
  63508. * Gets the 8 vectors representing the bounding box in local space
  63509. */
  63510. readonly vectors: Vector3[];
  63511. /**
  63512. * Gets the center of the bounding box in local space
  63513. */
  63514. readonly center: Vector3;
  63515. /**
  63516. * Gets the center of the bounding box in world space
  63517. */
  63518. readonly centerWorld: Vector3;
  63519. /**
  63520. * Gets the extend size in local space
  63521. */
  63522. readonly extendSize: Vector3;
  63523. /**
  63524. * Gets the extend size in world space
  63525. */
  63526. readonly extendSizeWorld: Vector3;
  63527. /**
  63528. * Gets the OBB (object bounding box) directions
  63529. */
  63530. readonly directions: Vector3[];
  63531. /**
  63532. * Gets the 8 vectors representing the bounding box in world space
  63533. */
  63534. readonly vectorsWorld: Vector3[];
  63535. /**
  63536. * Gets the minimum vector in world space
  63537. */
  63538. readonly minimumWorld: Vector3;
  63539. /**
  63540. * Gets the maximum vector in world space
  63541. */
  63542. readonly maximumWorld: Vector3;
  63543. /**
  63544. * Gets the minimum vector in local space
  63545. */
  63546. readonly minimum: Vector3;
  63547. /**
  63548. * Gets the maximum vector in local space
  63549. */
  63550. readonly maximum: Vector3;
  63551. private _worldMatrix;
  63552. private static readonly TmpVector3;
  63553. /**
  63554. * @hidden
  63555. */
  63556. _tag: number;
  63557. /**
  63558. * Creates a new bounding box
  63559. * @param min defines the minimum vector (in local space)
  63560. * @param max defines the maximum vector (in local space)
  63561. * @param worldMatrix defines the new world matrix
  63562. */
  63563. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63564. /**
  63565. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63566. * @param min defines the new minimum vector (in local space)
  63567. * @param max defines the new maximum vector (in local space)
  63568. * @param worldMatrix defines the new world matrix
  63569. */
  63570. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63571. /**
  63572. * Scale the current bounding box by applying a scale factor
  63573. * @param factor defines the scale factor to apply
  63574. * @returns the current bounding box
  63575. */
  63576. scale(factor: number): BoundingBox;
  63577. /**
  63578. * Gets the world matrix of the bounding box
  63579. * @returns a matrix
  63580. */
  63581. getWorldMatrix(): DeepImmutable<Matrix>;
  63582. /** @hidden */
  63583. _update(world: DeepImmutable<Matrix>): void;
  63584. /**
  63585. * Tests if the bounding box is intersecting the frustum planes
  63586. * @param frustumPlanes defines the frustum planes to test
  63587. * @returns true if there is an intersection
  63588. */
  63589. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63590. /**
  63591. * Tests if the bounding box is entirely inside the frustum planes
  63592. * @param frustumPlanes defines the frustum planes to test
  63593. * @returns true if there is an inclusion
  63594. */
  63595. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63596. /**
  63597. * Tests if a point is inside the bounding box
  63598. * @param point defines the point to test
  63599. * @returns true if the point is inside the bounding box
  63600. */
  63601. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63602. /**
  63603. * Tests if the bounding box intersects with a bounding sphere
  63604. * @param sphere defines the sphere to test
  63605. * @returns true if there is an intersection
  63606. */
  63607. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63608. /**
  63609. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63610. * @param min defines the min vector to use
  63611. * @param max defines the max vector to use
  63612. * @returns true if there is an intersection
  63613. */
  63614. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63615. /**
  63616. * Tests if two bounding boxes are intersections
  63617. * @param box0 defines the first box to test
  63618. * @param box1 defines the second box to test
  63619. * @returns true if there is an intersection
  63620. */
  63621. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63622. /**
  63623. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63624. * @param minPoint defines the minimum vector of the bounding box
  63625. * @param maxPoint defines the maximum vector of the bounding box
  63626. * @param sphereCenter defines the sphere center
  63627. * @param sphereRadius defines the sphere radius
  63628. * @returns true if there is an intersection
  63629. */
  63630. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63631. /**
  63632. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63633. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63634. * @param frustumPlanes defines the frustum planes to test
  63635. * @return true if there is an inclusion
  63636. */
  63637. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63638. /**
  63639. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63640. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63641. * @param frustumPlanes defines the frustum planes to test
  63642. * @return true if there is an intersection
  63643. */
  63644. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63645. }
  63646. }
  63647. declare module BABYLON {
  63648. /** @hidden */
  63649. export class Collider {
  63650. /** Define if a collision was found */
  63651. collisionFound: boolean;
  63652. /**
  63653. * Define last intersection point in local space
  63654. */
  63655. intersectionPoint: Vector3;
  63656. /**
  63657. * Define last collided mesh
  63658. */
  63659. collidedMesh: Nullable<AbstractMesh>;
  63660. private _collisionPoint;
  63661. private _planeIntersectionPoint;
  63662. private _tempVector;
  63663. private _tempVector2;
  63664. private _tempVector3;
  63665. private _tempVector4;
  63666. private _edge;
  63667. private _baseToVertex;
  63668. private _destinationPoint;
  63669. private _slidePlaneNormal;
  63670. private _displacementVector;
  63671. /** @hidden */
  63672. _radius: Vector3;
  63673. /** @hidden */
  63674. _retry: number;
  63675. private _velocity;
  63676. private _basePoint;
  63677. private _epsilon;
  63678. /** @hidden */
  63679. _velocityWorldLength: number;
  63680. /** @hidden */
  63681. _basePointWorld: Vector3;
  63682. private _velocityWorld;
  63683. private _normalizedVelocity;
  63684. /** @hidden */
  63685. _initialVelocity: Vector3;
  63686. /** @hidden */
  63687. _initialPosition: Vector3;
  63688. private _nearestDistance;
  63689. private _collisionMask;
  63690. collisionMask: number;
  63691. /**
  63692. * Gets the plane normal used to compute the sliding response (in local space)
  63693. */
  63694. readonly slidePlaneNormal: Vector3;
  63695. /** @hidden */
  63696. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63697. /** @hidden */
  63698. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63699. /** @hidden */
  63700. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63701. /** @hidden */
  63702. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63703. /** @hidden */
  63704. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63705. /** @hidden */
  63706. _getResponse(pos: Vector3, vel: Vector3): void;
  63707. }
  63708. }
  63709. declare module BABYLON {
  63710. /**
  63711. * Interface for cullable objects
  63712. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63713. */
  63714. export interface ICullable {
  63715. /**
  63716. * Checks if the object or part of the object is in the frustum
  63717. * @param frustumPlanes Camera near/planes
  63718. * @returns true if the object is in frustum otherwise false
  63719. */
  63720. isInFrustum(frustumPlanes: Plane[]): boolean;
  63721. /**
  63722. * Checks if a cullable object (mesh...) is in the camera frustum
  63723. * Unlike isInFrustum this cheks the full bounding box
  63724. * @param frustumPlanes Camera near/planes
  63725. * @returns true if the object is in frustum otherwise false
  63726. */
  63727. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63728. }
  63729. /**
  63730. * Info for a bounding data of a mesh
  63731. */
  63732. export class BoundingInfo implements ICullable {
  63733. /**
  63734. * Bounding box for the mesh
  63735. */
  63736. readonly boundingBox: BoundingBox;
  63737. /**
  63738. * Bounding sphere for the mesh
  63739. */
  63740. readonly boundingSphere: BoundingSphere;
  63741. private _isLocked;
  63742. private static readonly TmpVector3;
  63743. /**
  63744. * Constructs bounding info
  63745. * @param minimum min vector of the bounding box/sphere
  63746. * @param maximum max vector of the bounding box/sphere
  63747. * @param worldMatrix defines the new world matrix
  63748. */
  63749. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63750. /**
  63751. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63752. * @param min defines the new minimum vector (in local space)
  63753. * @param max defines the new maximum vector (in local space)
  63754. * @param worldMatrix defines the new world matrix
  63755. */
  63756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63757. /**
  63758. * min vector of the bounding box/sphere
  63759. */
  63760. readonly minimum: Vector3;
  63761. /**
  63762. * max vector of the bounding box/sphere
  63763. */
  63764. readonly maximum: Vector3;
  63765. /**
  63766. * If the info is locked and won't be updated to avoid perf overhead
  63767. */
  63768. isLocked: boolean;
  63769. /**
  63770. * Updates the bounding sphere and box
  63771. * @param world world matrix to be used to update
  63772. */
  63773. update(world: DeepImmutable<Matrix>): void;
  63774. /**
  63775. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63776. * @param center New center of the bounding info
  63777. * @param extend New extend of the bounding info
  63778. * @returns the current bounding info
  63779. */
  63780. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63781. /**
  63782. * Scale the current bounding info by applying a scale factor
  63783. * @param factor defines the scale factor to apply
  63784. * @returns the current bounding info
  63785. */
  63786. scale(factor: number): BoundingInfo;
  63787. /**
  63788. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63789. * @param frustumPlanes defines the frustum to test
  63790. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63791. * @returns true if the bounding info is in the frustum planes
  63792. */
  63793. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63794. /**
  63795. * Gets the world distance between the min and max points of the bounding box
  63796. */
  63797. readonly diagonalLength: number;
  63798. /**
  63799. * Checks if a cullable object (mesh...) is in the camera frustum
  63800. * Unlike isInFrustum this cheks the full bounding box
  63801. * @param frustumPlanes Camera near/planes
  63802. * @returns true if the object is in frustum otherwise false
  63803. */
  63804. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63805. /** @hidden */
  63806. _checkCollision(collider: Collider): boolean;
  63807. /**
  63808. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63809. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63810. * @param point the point to check intersection with
  63811. * @returns if the point intersects
  63812. */
  63813. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63814. /**
  63815. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63816. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63817. * @param boundingInfo the bounding info to check intersection with
  63818. * @param precise if the intersection should be done using OBB
  63819. * @returns if the bounding info intersects
  63820. */
  63821. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63822. }
  63823. }
  63824. declare module BABYLON {
  63825. /**
  63826. * Defines an array and its length.
  63827. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63828. */
  63829. export interface ISmartArrayLike<T> {
  63830. /**
  63831. * The data of the array.
  63832. */
  63833. data: Array<T>;
  63834. /**
  63835. * The active length of the array.
  63836. */
  63837. length: number;
  63838. }
  63839. /**
  63840. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63841. */
  63842. export class SmartArray<T> implements ISmartArrayLike<T> {
  63843. /**
  63844. * The full set of data from the array.
  63845. */
  63846. data: Array<T>;
  63847. /**
  63848. * The active length of the array.
  63849. */
  63850. length: number;
  63851. protected _id: number;
  63852. /**
  63853. * Instantiates a Smart Array.
  63854. * @param capacity defines the default capacity of the array.
  63855. */
  63856. constructor(capacity: number);
  63857. /**
  63858. * Pushes a value at the end of the active data.
  63859. * @param value defines the object to push in the array.
  63860. */
  63861. push(value: T): void;
  63862. /**
  63863. * Iterates over the active data and apply the lambda to them.
  63864. * @param func defines the action to apply on each value.
  63865. */
  63866. forEach(func: (content: T) => void): void;
  63867. /**
  63868. * Sorts the full sets of data.
  63869. * @param compareFn defines the comparison function to apply.
  63870. */
  63871. sort(compareFn: (a: T, b: T) => number): void;
  63872. /**
  63873. * Resets the active data to an empty array.
  63874. */
  63875. reset(): void;
  63876. /**
  63877. * Releases all the data from the array as well as the array.
  63878. */
  63879. dispose(): void;
  63880. /**
  63881. * Concats the active data with a given array.
  63882. * @param array defines the data to concatenate with.
  63883. */
  63884. concat(array: any): void;
  63885. /**
  63886. * Returns the position of a value in the active data.
  63887. * @param value defines the value to find the index for
  63888. * @returns the index if found in the active data otherwise -1
  63889. */
  63890. indexOf(value: T): number;
  63891. /**
  63892. * Returns whether an element is part of the active data.
  63893. * @param value defines the value to look for
  63894. * @returns true if found in the active data otherwise false
  63895. */
  63896. contains(value: T): boolean;
  63897. private static _GlobalId;
  63898. }
  63899. /**
  63900. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63901. * The data in this array can only be present once
  63902. */
  63903. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  63904. private _duplicateId;
  63905. /**
  63906. * Pushes a value at the end of the active data.
  63907. * THIS DOES NOT PREVENT DUPPLICATE DATA
  63908. * @param value defines the object to push in the array.
  63909. */
  63910. push(value: T): void;
  63911. /**
  63912. * Pushes a value at the end of the active data.
  63913. * If the data is already present, it won t be added again
  63914. * @param value defines the object to push in the array.
  63915. * @returns true if added false if it was already present
  63916. */
  63917. pushNoDuplicate(value: T): boolean;
  63918. /**
  63919. * Resets the active data to an empty array.
  63920. */
  63921. reset(): void;
  63922. /**
  63923. * Concats the active data with a given array.
  63924. * This ensures no dupplicate will be present in the result.
  63925. * @param array defines the data to concatenate with.
  63926. */
  63927. concatWithNoDuplicate(array: any): void;
  63928. }
  63929. }
  63930. declare module BABYLON {
  63931. /**
  63932. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63933. * separate meshes. This can be use to improve performances.
  63934. * @see http://doc.babylonjs.com/how_to/multi_materials
  63935. */
  63936. export class MultiMaterial extends Material {
  63937. private _subMaterials;
  63938. /**
  63939. * Gets or Sets the list of Materials used within the multi material.
  63940. * They need to be ordered according to the submeshes order in the associated mesh
  63941. */
  63942. subMaterials: Nullable<Material>[];
  63943. /**
  63944. * Function used to align with Node.getChildren()
  63945. * @returns the list of Materials used within the multi material
  63946. */
  63947. getChildren(): Nullable<Material>[];
  63948. /**
  63949. * Instantiates a new Multi Material
  63950. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63951. * separate meshes. This can be use to improve performances.
  63952. * @see http://doc.babylonjs.com/how_to/multi_materials
  63953. * @param name Define the name in the scene
  63954. * @param scene Define the scene the material belongs to
  63955. */
  63956. constructor(name: string, scene: Scene);
  63957. private _hookArray;
  63958. /**
  63959. * Get one of the submaterial by its index in the submaterials array
  63960. * @param index The index to look the sub material at
  63961. * @returns The Material if the index has been defined
  63962. */
  63963. getSubMaterial(index: number): Nullable<Material>;
  63964. /**
  63965. * Get the list of active textures for the whole sub materials list.
  63966. * @returns All the textures that will be used during the rendering
  63967. */
  63968. getActiveTextures(): BaseTexture[];
  63969. /**
  63970. * Gets the current class name of the material e.g. "MultiMaterial"
  63971. * Mainly use in serialization.
  63972. * @returns the class name
  63973. */
  63974. getClassName(): string;
  63975. /**
  63976. * Checks if the material is ready to render the requested sub mesh
  63977. * @param mesh Define the mesh the submesh belongs to
  63978. * @param subMesh Define the sub mesh to look readyness for
  63979. * @param useInstances Define whether or not the material is used with instances
  63980. * @returns true if ready, otherwise false
  63981. */
  63982. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  63983. /**
  63984. * Clones the current material and its related sub materials
  63985. * @param name Define the name of the newly cloned material
  63986. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  63987. * @returns the cloned material
  63988. */
  63989. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  63990. /**
  63991. * Serializes the materials into a JSON representation.
  63992. * @returns the JSON representation
  63993. */
  63994. serialize(): any;
  63995. /**
  63996. * Dispose the material and release its associated resources
  63997. * @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)
  63998. * @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)
  63999. * @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)
  64000. */
  64001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64002. /**
  64003. * Creates a MultiMaterial from parsed MultiMaterial data.
  64004. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64005. * @param scene defines the hosting scene
  64006. * @returns a new MultiMaterial
  64007. */
  64008. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64009. }
  64010. }
  64011. declare module BABYLON {
  64012. /**
  64013. * Class used to represent data loading progression
  64014. */
  64015. export class SceneLoaderFlags {
  64016. private static _ForceFullSceneLoadingForIncremental;
  64017. private static _ShowLoadingScreen;
  64018. private static _CleanBoneMatrixWeights;
  64019. private static _loggingLevel;
  64020. /**
  64021. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64022. */
  64023. static ForceFullSceneLoadingForIncremental: boolean;
  64024. /**
  64025. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64026. */
  64027. static ShowLoadingScreen: boolean;
  64028. /**
  64029. * Defines the current logging level (while loading the scene)
  64030. * @ignorenaming
  64031. */
  64032. static loggingLevel: number;
  64033. /**
  64034. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64035. */
  64036. static CleanBoneMatrixWeights: boolean;
  64037. }
  64038. }
  64039. declare module BABYLON {
  64040. /**
  64041. * Class used to override all child animations of a given target
  64042. */
  64043. export class AnimationPropertiesOverride {
  64044. /**
  64045. * Gets or sets a value indicating if animation blending must be used
  64046. */
  64047. enableBlending: boolean;
  64048. /**
  64049. * Gets or sets the blending speed to use when enableBlending is true
  64050. */
  64051. blendingSpeed: number;
  64052. /**
  64053. * Gets or sets the default loop mode to use
  64054. */
  64055. loopMode: number;
  64056. }
  64057. }
  64058. declare module BABYLON {
  64059. /**
  64060. * Defines a target to use with MorphTargetManager
  64061. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  64062. */
  64063. export class MorphTarget implements IAnimatable {
  64064. /** defines the name of the target */
  64065. name: string;
  64066. /**
  64067. * Gets or sets the list of animations
  64068. */
  64069. animations: Animation[];
  64070. private _scene;
  64071. private _positions;
  64072. private _normals;
  64073. private _tangents;
  64074. private _influence;
  64075. /**
  64076. * Observable raised when the influence changes
  64077. */
  64078. onInfluenceChanged: Observable<boolean>;
  64079. /** @hidden */
  64080. _onDataLayoutChanged: Observable<void>;
  64081. /**
  64082. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  64083. */
  64084. influence: number;
  64085. /**
  64086. * Gets or sets the id of the morph Target
  64087. */
  64088. id: string;
  64089. private _animationPropertiesOverride;
  64090. /**
  64091. * Gets or sets the animation properties override
  64092. */
  64093. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  64094. /**
  64095. * Creates a new MorphTarget
  64096. * @param name defines the name of the target
  64097. * @param influence defines the influence to use
  64098. * @param scene defines the scene the morphtarget belongs to
  64099. */
  64100. constructor(
  64101. /** defines the name of the target */
  64102. name: string, influence?: number, scene?: Nullable<Scene>);
  64103. /**
  64104. * Gets a boolean defining if the target contains position data
  64105. */
  64106. readonly hasPositions: boolean;
  64107. /**
  64108. * Gets a boolean defining if the target contains normal data
  64109. */
  64110. readonly hasNormals: boolean;
  64111. /**
  64112. * Gets a boolean defining if the target contains tangent data
  64113. */
  64114. readonly hasTangents: boolean;
  64115. /**
  64116. * Affects position data to this target
  64117. * @param data defines the position data to use
  64118. */
  64119. setPositions(data: Nullable<FloatArray>): void;
  64120. /**
  64121. * Gets the position data stored in this target
  64122. * @returns a FloatArray containing the position data (or null if not present)
  64123. */
  64124. getPositions(): Nullable<FloatArray>;
  64125. /**
  64126. * Affects normal data to this target
  64127. * @param data defines the normal data to use
  64128. */
  64129. setNormals(data: Nullable<FloatArray>): void;
  64130. /**
  64131. * Gets the normal data stored in this target
  64132. * @returns a FloatArray containing the normal data (or null if not present)
  64133. */
  64134. getNormals(): Nullable<FloatArray>;
  64135. /**
  64136. * Affects tangent data to this target
  64137. * @param data defines the tangent data to use
  64138. */
  64139. setTangents(data: Nullable<FloatArray>): void;
  64140. /**
  64141. * Gets the tangent data stored in this target
  64142. * @returns a FloatArray containing the tangent data (or null if not present)
  64143. */
  64144. getTangents(): Nullable<FloatArray>;
  64145. /**
  64146. * Serializes the current target into a Serialization object
  64147. * @returns the serialized object
  64148. */
  64149. serialize(): any;
  64150. /**
  64151. * Returns the string "MorphTarget"
  64152. * @returns "MorphTarget"
  64153. */
  64154. getClassName(): string;
  64155. /**
  64156. * Creates a new target from serialized data
  64157. * @param serializationObject defines the serialized data to use
  64158. * @returns a new MorphTarget
  64159. */
  64160. static Parse(serializationObject: any): MorphTarget;
  64161. /**
  64162. * Creates a MorphTarget from mesh data
  64163. * @param mesh defines the source mesh
  64164. * @param name defines the name to use for the new target
  64165. * @param influence defines the influence to attach to the target
  64166. * @returns a new MorphTarget
  64167. */
  64168. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  64169. }
  64170. }
  64171. declare module BABYLON {
  64172. /**
  64173. * This class is used to deform meshes using morphing between different targets
  64174. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  64175. */
  64176. export class MorphTargetManager {
  64177. private _targets;
  64178. private _targetInfluenceChangedObservers;
  64179. private _targetDataLayoutChangedObservers;
  64180. private _activeTargets;
  64181. private _scene;
  64182. private _influences;
  64183. private _supportsNormals;
  64184. private _supportsTangents;
  64185. private _vertexCount;
  64186. private _uniqueId;
  64187. private _tempInfluences;
  64188. /**
  64189. * Creates a new MorphTargetManager
  64190. * @param scene defines the current scene
  64191. */
  64192. constructor(scene?: Nullable<Scene>);
  64193. /**
  64194. * Gets the unique ID of this manager
  64195. */
  64196. readonly uniqueId: number;
  64197. /**
  64198. * Gets the number of vertices handled by this manager
  64199. */
  64200. readonly vertexCount: number;
  64201. /**
  64202. * Gets a boolean indicating if this manager supports morphing of normals
  64203. */
  64204. readonly supportsNormals: boolean;
  64205. /**
  64206. * Gets a boolean indicating if this manager supports morphing of tangents
  64207. */
  64208. readonly supportsTangents: boolean;
  64209. /**
  64210. * Gets the number of targets stored in this manager
  64211. */
  64212. readonly numTargets: number;
  64213. /**
  64214. * Gets the number of influencers (ie. the number of targets with influences > 0)
  64215. */
  64216. readonly numInfluencers: number;
  64217. /**
  64218. * Gets the list of influences (one per target)
  64219. */
  64220. readonly influences: Float32Array;
  64221. /**
  64222. * Gets the active target at specified index. An active target is a target with an influence > 0
  64223. * @param index defines the index to check
  64224. * @returns the requested target
  64225. */
  64226. getActiveTarget(index: number): MorphTarget;
  64227. /**
  64228. * Gets the target at specified index
  64229. * @param index defines the index to check
  64230. * @returns the requested target
  64231. */
  64232. getTarget(index: number): MorphTarget;
  64233. /**
  64234. * Add a new target to this manager
  64235. * @param target defines the target to add
  64236. */
  64237. addTarget(target: MorphTarget): void;
  64238. /**
  64239. * Removes a target from the manager
  64240. * @param target defines the target to remove
  64241. */
  64242. removeTarget(target: MorphTarget): void;
  64243. /**
  64244. * Serializes the current manager into a Serialization object
  64245. * @returns the serialized object
  64246. */
  64247. serialize(): any;
  64248. private _syncActiveTargets;
  64249. /**
  64250. * Syncrhonize the targets with all the meshes using this morph target manager
  64251. */
  64252. synchronize(): void;
  64253. /**
  64254. * Creates a new MorphTargetManager from serialized data
  64255. * @param serializationObject defines the serialized data
  64256. * @param scene defines the hosting scene
  64257. * @returns the new MorphTargetManager
  64258. */
  64259. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * Creates an instance based on a source mesh.
  64265. */
  64266. export class InstancedMesh extends AbstractMesh {
  64267. private _sourceMesh;
  64268. private _currentLOD;
  64269. /** @hidden */
  64270. _indexInSourceMeshInstanceArray: number;
  64271. constructor(name: string, source: Mesh);
  64272. /**
  64273. * Returns the string "InstancedMesh".
  64274. */
  64275. getClassName(): string;
  64276. /**
  64277. * If the source mesh receives shadows
  64278. */
  64279. readonly receiveShadows: boolean;
  64280. /**
  64281. * The material of the source mesh
  64282. */
  64283. readonly material: Nullable<Material>;
  64284. /**
  64285. * Visibility of the source mesh
  64286. */
  64287. readonly visibility: number;
  64288. /**
  64289. * Skeleton of the source mesh
  64290. */
  64291. readonly skeleton: Nullable<Skeleton>;
  64292. /**
  64293. * Rendering ground id of the source mesh
  64294. */
  64295. renderingGroupId: number;
  64296. /**
  64297. * Returns the total number of vertices (integer).
  64298. */
  64299. getTotalVertices(): number;
  64300. /**
  64301. * Returns a positive integer : the total number of indices in this mesh geometry.
  64302. * @returns the numner of indices or zero if the mesh has no geometry.
  64303. */
  64304. getTotalIndices(): number;
  64305. /**
  64306. * The source mesh of the instance
  64307. */
  64308. readonly sourceMesh: Mesh;
  64309. /**
  64310. * Is this node ready to be used/rendered
  64311. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  64312. * @return {boolean} is it ready
  64313. */
  64314. isReady(completeCheck?: boolean): boolean;
  64315. /**
  64316. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  64317. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  64318. * @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.
  64319. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  64320. */
  64321. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  64322. /**
  64323. * Sets the vertex data of the mesh geometry for the requested `kind`.
  64324. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  64325. * The `data` are either a numeric array either a Float32Array.
  64326. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  64327. * 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).
  64328. * Note that a new underlying VertexBuffer object is created each call.
  64329. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  64330. *
  64331. * Possible `kind` values :
  64332. * - VertexBuffer.PositionKind
  64333. * - VertexBuffer.UVKind
  64334. * - VertexBuffer.UV2Kind
  64335. * - VertexBuffer.UV3Kind
  64336. * - VertexBuffer.UV4Kind
  64337. * - VertexBuffer.UV5Kind
  64338. * - VertexBuffer.UV6Kind
  64339. * - VertexBuffer.ColorKind
  64340. * - VertexBuffer.MatricesIndicesKind
  64341. * - VertexBuffer.MatricesIndicesExtraKind
  64342. * - VertexBuffer.MatricesWeightsKind
  64343. * - VertexBuffer.MatricesWeightsExtraKind
  64344. *
  64345. * Returns the Mesh.
  64346. */
  64347. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  64348. /**
  64349. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  64350. * If the mesh has no geometry, it is simply returned as it is.
  64351. * The `data` are either a numeric array either a Float32Array.
  64352. * No new underlying VertexBuffer object is created.
  64353. * 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.
  64354. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  64355. *
  64356. * Possible `kind` values :
  64357. * - VertexBuffer.PositionKind
  64358. * - VertexBuffer.UVKind
  64359. * - VertexBuffer.UV2Kind
  64360. * - VertexBuffer.UV3Kind
  64361. * - VertexBuffer.UV4Kind
  64362. * - VertexBuffer.UV5Kind
  64363. * - VertexBuffer.UV6Kind
  64364. * - VertexBuffer.ColorKind
  64365. * - VertexBuffer.MatricesIndicesKind
  64366. * - VertexBuffer.MatricesIndicesExtraKind
  64367. * - VertexBuffer.MatricesWeightsKind
  64368. * - VertexBuffer.MatricesWeightsExtraKind
  64369. *
  64370. * Returns the Mesh.
  64371. */
  64372. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  64373. /**
  64374. * Sets the mesh indices.
  64375. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  64376. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  64377. * This method creates a new index buffer each call.
  64378. * Returns the Mesh.
  64379. */
  64380. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  64381. /**
  64382. * Boolean : True if the mesh owns the requested kind of data.
  64383. */
  64384. isVerticesDataPresent(kind: string): boolean;
  64385. /**
  64386. * Returns an array of indices (IndicesArray).
  64387. */
  64388. getIndices(): Nullable<IndicesArray>;
  64389. readonly _positions: Nullable<Vector3[]>;
  64390. /**
  64391. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  64392. * This means the mesh underlying bounding box and sphere are recomputed.
  64393. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  64394. * @returns the current mesh
  64395. */
  64396. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  64397. /** @hidden */
  64398. _preActivate(): InstancedMesh;
  64399. /** @hidden */
  64400. _activate(renderId: number): InstancedMesh;
  64401. /**
  64402. * Returns the current associated LOD AbstractMesh.
  64403. */
  64404. getLOD(camera: Camera): AbstractMesh;
  64405. /** @hidden */
  64406. _syncSubMeshes(): InstancedMesh;
  64407. /** @hidden */
  64408. _generatePointsArray(): boolean;
  64409. /**
  64410. * Creates a new InstancedMesh from the current mesh.
  64411. * - name (string) : the cloned mesh name
  64412. * - newParent (optional Node) : the optional Node to parent the clone to.
  64413. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  64414. *
  64415. * Returns the clone.
  64416. */
  64417. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  64418. /**
  64419. * Disposes the InstancedMesh.
  64420. * Returns nothing.
  64421. */
  64422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64423. }
  64424. }
  64425. declare module BABYLON {
  64426. /**
  64427. * Class for creating a cube texture
  64428. */
  64429. export class CubeTexture extends BaseTexture {
  64430. private _delayedOnLoad;
  64431. /**
  64432. * The url of the texture
  64433. */
  64434. url: string;
  64435. /**
  64436. * Gets or sets the center of the bounding box associated with the cube texture.
  64437. * It must define where the camera used to render the texture was set
  64438. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64439. */
  64440. boundingBoxPosition: Vector3;
  64441. private _boundingBoxSize;
  64442. /**
  64443. * Gets or sets the size of the bounding box associated with the cube texture
  64444. * When defined, the cubemap will switch to local mode
  64445. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64446. * @example https://www.babylonjs-playground.com/#RNASML
  64447. */
  64448. /**
  64449. * Returns the bounding box size
  64450. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64451. */
  64452. boundingBoxSize: Vector3;
  64453. protected _rotationY: number;
  64454. /**
  64455. * Sets texture matrix rotation angle around Y axis in radians.
  64456. */
  64457. /**
  64458. * Gets texture matrix rotation angle around Y axis radians.
  64459. */
  64460. rotationY: number;
  64461. /**
  64462. * Are mip maps generated for this texture or not.
  64463. */
  64464. readonly noMipmap: boolean;
  64465. private _noMipmap;
  64466. private _files;
  64467. private _extensions;
  64468. private _textureMatrix;
  64469. private _format;
  64470. private _createPolynomials;
  64471. /** @hidden */
  64472. _prefiltered: boolean;
  64473. /**
  64474. * Creates a cube texture from an array of image urls
  64475. * @param files defines an array of image urls
  64476. * @param scene defines the hosting scene
  64477. * @param noMipmap specifies if mip maps are not used
  64478. * @returns a cube texture
  64479. */
  64480. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  64481. /**
  64482. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  64483. * @param url defines the url of the prefiltered texture
  64484. * @param scene defines the scene the texture is attached to
  64485. * @param forcedExtension defines the extension of the file if different from the url
  64486. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64487. * @return the prefiltered texture
  64488. */
  64489. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  64490. /**
  64491. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  64492. * as prefiltered data.
  64493. * @param rootUrl defines the url of the texture or the root name of the six images
  64494. * @param scene defines the scene the texture is attached to
  64495. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  64496. * @param noMipmap defines if mipmaps should be created or not
  64497. * @param files defines the six files to load for the different faces
  64498. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  64499. * @param onError defines a callback triggered in case of error during load
  64500. * @param format defines the internal format to use for the texture once loaded
  64501. * @param prefiltered defines whether or not the texture is created from prefiltered data
  64502. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  64503. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64504. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64505. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64506. * @return the cube texture
  64507. */
  64508. 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);
  64509. /**
  64510. * Get the current class name of the texture useful for serialization or dynamic coding.
  64511. * @returns "CubeTexture"
  64512. */
  64513. getClassName(): string;
  64514. /**
  64515. * Update the url (and optional buffer) of this texture if url was null during construction.
  64516. * @param url the url of the texture
  64517. * @param forcedExtension defines the extension to use
  64518. * @param onLoad callback called when the texture is loaded (defaults to null)
  64519. */
  64520. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  64521. /**
  64522. * Delays loading of the cube texture
  64523. * @param forcedExtension defines the extension to use
  64524. */
  64525. delayLoad(forcedExtension?: string): void;
  64526. /**
  64527. * Returns the reflection texture matrix
  64528. * @returns the reflection texture matrix
  64529. */
  64530. getReflectionTextureMatrix(): Matrix;
  64531. /**
  64532. * Sets the reflection texture matrix
  64533. * @param value Reflection texture matrix
  64534. */
  64535. setReflectionTextureMatrix(value: Matrix): void;
  64536. /**
  64537. * Parses text to create a cube texture
  64538. * @param parsedTexture define the serialized text to read from
  64539. * @param scene defines the hosting scene
  64540. * @param rootUrl defines the root url of the cube texture
  64541. * @returns a cube texture
  64542. */
  64543. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  64544. /**
  64545. * Makes a clone, or deep copy, of the cube texture
  64546. * @returns a new cube texture
  64547. */
  64548. clone(): CubeTexture;
  64549. }
  64550. }
  64551. declare module BABYLON {
  64552. /** @hidden */
  64553. export var postprocessVertexShader: {
  64554. name: string;
  64555. shader: string;
  64556. };
  64557. }
  64558. declare module BABYLON {
  64559. /**
  64560. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  64561. * This is the base of the follow, arc rotate cameras and Free camera
  64562. * @see http://doc.babylonjs.com/features/cameras
  64563. */
  64564. export class TargetCamera extends Camera {
  64565. private static _RigCamTransformMatrix;
  64566. private static _TargetTransformMatrix;
  64567. private static _TargetFocalPoint;
  64568. /**
  64569. * Define the current direction the camera is moving to
  64570. */
  64571. cameraDirection: Vector3;
  64572. /**
  64573. * Define the current rotation the camera is rotating to
  64574. */
  64575. cameraRotation: Vector2;
  64576. /**
  64577. * When set, the up vector of the camera will be updated by the rotation of the camera
  64578. */
  64579. updateUpVectorFromRotation: boolean;
  64580. private _tmpQuaternion;
  64581. /**
  64582. * Define the current rotation of the camera
  64583. */
  64584. rotation: Vector3;
  64585. /**
  64586. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  64587. */
  64588. rotationQuaternion: Quaternion;
  64589. /**
  64590. * Define the current speed of the camera
  64591. */
  64592. speed: number;
  64593. /**
  64594. * Add cconstraint to the camera to prevent it to move freely in all directions and
  64595. * around all axis.
  64596. */
  64597. noRotationConstraint: boolean;
  64598. /**
  64599. * Define the current target of the camera as an object or a position.
  64600. */
  64601. lockedTarget: any;
  64602. /** @hidden */
  64603. _currentTarget: Vector3;
  64604. /** @hidden */
  64605. _initialFocalDistance: number;
  64606. /** @hidden */
  64607. _viewMatrix: Matrix;
  64608. /** @hidden */
  64609. _camMatrix: Matrix;
  64610. /** @hidden */
  64611. _cameraTransformMatrix: Matrix;
  64612. /** @hidden */
  64613. _cameraRotationMatrix: Matrix;
  64614. /** @hidden */
  64615. _referencePoint: Vector3;
  64616. /** @hidden */
  64617. _transformedReferencePoint: Vector3;
  64618. protected _globalCurrentTarget: Vector3;
  64619. protected _globalCurrentUpVector: Vector3;
  64620. /** @hidden */
  64621. _reset: () => void;
  64622. private _defaultUp;
  64623. /**
  64624. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  64625. * This is the base of the follow, arc rotate cameras and Free camera
  64626. * @see http://doc.babylonjs.com/features/cameras
  64627. * @param name Defines the name of the camera in the scene
  64628. * @param position Defines the start position of the camera in the scene
  64629. * @param scene Defines the scene the camera belongs to
  64630. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64631. */
  64632. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64633. /**
  64634. * Gets the position in front of the camera at a given distance.
  64635. * @param distance The distance from the camera we want the position to be
  64636. * @returns the position
  64637. */
  64638. getFrontPosition(distance: number): Vector3;
  64639. /** @hidden */
  64640. _getLockedTargetPosition(): Nullable<Vector3>;
  64641. private _storedPosition;
  64642. private _storedRotation;
  64643. private _storedRotationQuaternion;
  64644. /**
  64645. * Store current camera state of the camera (fov, position, rotation, etc..)
  64646. * @returns the camera
  64647. */
  64648. storeState(): Camera;
  64649. /**
  64650. * Restored camera state. You must call storeState() first
  64651. * @returns whether it was successful or not
  64652. * @hidden
  64653. */
  64654. _restoreStateValues(): boolean;
  64655. /** @hidden */
  64656. _initCache(): void;
  64657. /** @hidden */
  64658. _updateCache(ignoreParentClass?: boolean): void;
  64659. /** @hidden */
  64660. _isSynchronizedViewMatrix(): boolean;
  64661. /** @hidden */
  64662. _computeLocalCameraSpeed(): number;
  64663. /** @hidden */
  64664. setTarget(target: Vector3): void;
  64665. /**
  64666. * Return the current target position of the camera. This value is expressed in local space.
  64667. * @returns the target position
  64668. */
  64669. getTarget(): Vector3;
  64670. /** @hidden */
  64671. _decideIfNeedsToMove(): boolean;
  64672. /** @hidden */
  64673. _updatePosition(): void;
  64674. /** @hidden */
  64675. _checkInputs(): void;
  64676. protected _updateCameraRotationMatrix(): void;
  64677. /**
  64678. * 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)
  64679. * @returns the current camera
  64680. */
  64681. private _rotateUpVectorWithCameraRotationMatrix;
  64682. private _cachedRotationZ;
  64683. private _cachedQuaternionRotationZ;
  64684. /** @hidden */
  64685. _getViewMatrix(): Matrix;
  64686. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  64687. /**
  64688. * @hidden
  64689. */
  64690. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  64691. /**
  64692. * @hidden
  64693. */
  64694. _updateRigCameras(): void;
  64695. private _getRigCamPositionAndTarget;
  64696. /**
  64697. * Gets the current object class name.
  64698. * @return the class name
  64699. */
  64700. getClassName(): string;
  64701. }
  64702. }
  64703. declare module BABYLON {
  64704. /**
  64705. * @ignore
  64706. * This is a list of all the different input types that are available in the application.
  64707. * Fo instance: ArcRotateCameraGamepadInput...
  64708. */
  64709. export var CameraInputTypes: {};
  64710. /**
  64711. * This is the contract to implement in order to create a new input class.
  64712. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  64713. */
  64714. export interface ICameraInput<TCamera extends Camera> {
  64715. /**
  64716. * Defines the camera the input is attached to.
  64717. */
  64718. camera: Nullable<TCamera>;
  64719. /**
  64720. * Gets the class name of the current intput.
  64721. * @returns the class name
  64722. */
  64723. getClassName(): string;
  64724. /**
  64725. * Get the friendly name associated with the input class.
  64726. * @returns the input friendly name
  64727. */
  64728. getSimpleName(): string;
  64729. /**
  64730. * Attach the input controls to a specific dom element to get the input from.
  64731. * @param element Defines the element the controls should be listened from
  64732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64733. */
  64734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64735. /**
  64736. * Detach the current controls from the specified dom element.
  64737. * @param element Defines the element to stop listening the inputs from
  64738. */
  64739. detachControl(element: Nullable<HTMLElement>): void;
  64740. /**
  64741. * Update the current camera state depending on the inputs that have been used this frame.
  64742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64743. */
  64744. checkInputs?: () => void;
  64745. }
  64746. /**
  64747. * Represents a map of input types to input instance or input index to input instance.
  64748. */
  64749. export interface CameraInputsMap<TCamera extends Camera> {
  64750. /**
  64751. * Accessor to the input by input type.
  64752. */
  64753. [name: string]: ICameraInput<TCamera>;
  64754. /**
  64755. * Accessor to the input by input index.
  64756. */
  64757. [idx: number]: ICameraInput<TCamera>;
  64758. }
  64759. /**
  64760. * This represents the input manager used within a camera.
  64761. * It helps dealing with all the different kind of input attached to a camera.
  64762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64763. */
  64764. export class CameraInputsManager<TCamera extends Camera> {
  64765. /**
  64766. * Defines the list of inputs attahed to the camera.
  64767. */
  64768. attached: CameraInputsMap<TCamera>;
  64769. /**
  64770. * Defines the dom element the camera is collecting inputs from.
  64771. * This is null if the controls have not been attached.
  64772. */
  64773. attachedElement: Nullable<HTMLElement>;
  64774. /**
  64775. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64776. */
  64777. noPreventDefault: boolean;
  64778. /**
  64779. * Defined the camera the input manager belongs to.
  64780. */
  64781. camera: TCamera;
  64782. /**
  64783. * Update the current camera state depending on the inputs that have been used this frame.
  64784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64785. */
  64786. checkInputs: () => void;
  64787. /**
  64788. * Instantiate a new Camera Input Manager.
  64789. * @param camera Defines the camera the input manager blongs to
  64790. */
  64791. constructor(camera: TCamera);
  64792. /**
  64793. * Add an input method to a camera
  64794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64795. * @param input camera input method
  64796. */
  64797. add(input: ICameraInput<TCamera>): void;
  64798. /**
  64799. * Remove a specific input method from a camera
  64800. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  64801. * @param inputToRemove camera input method
  64802. */
  64803. remove(inputToRemove: ICameraInput<TCamera>): void;
  64804. /**
  64805. * Remove a specific input type from a camera
  64806. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  64807. * @param inputType the type of the input to remove
  64808. */
  64809. removeByType(inputType: string): void;
  64810. private _addCheckInputs;
  64811. /**
  64812. * Attach the input controls to the currently attached dom element to listen the events from.
  64813. * @param input Defines the input to attach
  64814. */
  64815. attachInput(input: ICameraInput<TCamera>): void;
  64816. /**
  64817. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  64818. * @param element Defines the dom element to collect the events from
  64819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64820. */
  64821. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  64822. /**
  64823. * Detach the current manager inputs controls from a specific dom element.
  64824. * @param element Defines the dom element to collect the events from
  64825. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  64826. */
  64827. detachElement(element: HTMLElement, disconnect?: boolean): void;
  64828. /**
  64829. * Rebuild the dynamic inputCheck function from the current list of
  64830. * defined inputs in the manager.
  64831. */
  64832. rebuildInputCheck(): void;
  64833. /**
  64834. * Remove all attached input methods from a camera
  64835. */
  64836. clear(): void;
  64837. /**
  64838. * Serialize the current input manager attached to a camera.
  64839. * This ensures than once parsed,
  64840. * the input associated to the camera will be identical to the current ones
  64841. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  64842. */
  64843. serialize(serializedCamera: any): void;
  64844. /**
  64845. * Parses an input manager serialized JSON to restore the previous list of inputs
  64846. * and states associated to a camera.
  64847. * @param parsedCamera Defines the JSON to parse
  64848. */
  64849. parse(parsedCamera: any): void;
  64850. }
  64851. }
  64852. declare module BABYLON {
  64853. /**
  64854. * Gather the list of keyboard event types as constants.
  64855. */
  64856. export class KeyboardEventTypes {
  64857. /**
  64858. * The keydown event is fired when a key becomes active (pressed).
  64859. */
  64860. static readonly KEYDOWN: number;
  64861. /**
  64862. * The keyup event is fired when a key has been released.
  64863. */
  64864. static readonly KEYUP: number;
  64865. }
  64866. /**
  64867. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64868. */
  64869. export class KeyboardInfo {
  64870. /**
  64871. * Defines the type of event (KeyboardEventTypes)
  64872. */
  64873. type: number;
  64874. /**
  64875. * Defines the related dom event
  64876. */
  64877. event: KeyboardEvent;
  64878. /**
  64879. * Instantiates a new keyboard info.
  64880. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64881. * @param type Defines the type of event (KeyboardEventTypes)
  64882. * @param event Defines the related dom event
  64883. */
  64884. constructor(
  64885. /**
  64886. * Defines the type of event (KeyboardEventTypes)
  64887. */
  64888. type: number,
  64889. /**
  64890. * Defines the related dom event
  64891. */
  64892. event: KeyboardEvent);
  64893. }
  64894. /**
  64895. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64896. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  64897. */
  64898. export class KeyboardInfoPre extends KeyboardInfo {
  64899. /**
  64900. * Defines the type of event (KeyboardEventTypes)
  64901. */
  64902. type: number;
  64903. /**
  64904. * Defines the related dom event
  64905. */
  64906. event: KeyboardEvent;
  64907. /**
  64908. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  64909. */
  64910. skipOnPointerObservable: boolean;
  64911. /**
  64912. * Instantiates a new keyboard pre info.
  64913. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64914. * @param type Defines the type of event (KeyboardEventTypes)
  64915. * @param event Defines the related dom event
  64916. */
  64917. constructor(
  64918. /**
  64919. * Defines the type of event (KeyboardEventTypes)
  64920. */
  64921. type: number,
  64922. /**
  64923. * Defines the related dom event
  64924. */
  64925. event: KeyboardEvent);
  64926. }
  64927. }
  64928. declare module BABYLON {
  64929. /**
  64930. * Manage the keyboard inputs to control the movement of a free camera.
  64931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64932. */
  64933. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  64934. /**
  64935. * Defines the camera the input is attached to.
  64936. */
  64937. camera: FreeCamera;
  64938. /**
  64939. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64940. */
  64941. keysUp: number[];
  64942. /**
  64943. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64944. */
  64945. keysDown: number[];
  64946. /**
  64947. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64948. */
  64949. keysLeft: number[];
  64950. /**
  64951. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64952. */
  64953. keysRight: number[];
  64954. private _keys;
  64955. private _onCanvasBlurObserver;
  64956. private _onKeyboardObserver;
  64957. private _engine;
  64958. private _scene;
  64959. /**
  64960. * Attach the input controls to a specific dom element to get the input from.
  64961. * @param element Defines the element the controls should be listened from
  64962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64963. */
  64964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64965. /**
  64966. * Detach the current controls from the specified dom element.
  64967. * @param element Defines the element to stop listening the inputs from
  64968. */
  64969. detachControl(element: Nullable<HTMLElement>): void;
  64970. /**
  64971. * Update the current camera state depending on the inputs that have been used this frame.
  64972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64973. */
  64974. checkInputs(): void;
  64975. /**
  64976. * Gets the class name of the current intput.
  64977. * @returns the class name
  64978. */
  64979. getClassName(): string;
  64980. /** @hidden */
  64981. _onLostFocus(): void;
  64982. /**
  64983. * Get the friendly name associated with the input class.
  64984. * @returns the input friendly name
  64985. */
  64986. getSimpleName(): string;
  64987. }
  64988. }
  64989. declare module BABYLON {
  64990. /**
  64991. * Interface used to define ActionEvent
  64992. */
  64993. export interface IActionEvent {
  64994. /** The mesh or sprite that triggered the action */
  64995. source: any;
  64996. /** The X mouse cursor position at the time of the event */
  64997. pointerX: number;
  64998. /** The Y mouse cursor position at the time of the event */
  64999. pointerY: number;
  65000. /** The mesh that is currently pointed at (can be null) */
  65001. meshUnderPointer: Nullable<AbstractMesh>;
  65002. /** the original (browser) event that triggered the ActionEvent */
  65003. sourceEvent?: any;
  65004. /** additional data for the event */
  65005. additionalData?: any;
  65006. }
  65007. /**
  65008. * ActionEvent is the event being sent when an action is triggered.
  65009. */
  65010. export class ActionEvent implements IActionEvent {
  65011. /** The mesh or sprite that triggered the action */
  65012. source: any;
  65013. /** The X mouse cursor position at the time of the event */
  65014. pointerX: number;
  65015. /** The Y mouse cursor position at the time of the event */
  65016. pointerY: number;
  65017. /** The mesh that is currently pointed at (can be null) */
  65018. meshUnderPointer: Nullable<AbstractMesh>;
  65019. /** the original (browser) event that triggered the ActionEvent */
  65020. sourceEvent?: any;
  65021. /** additional data for the event */
  65022. additionalData?: any;
  65023. /**
  65024. * Creates a new ActionEvent
  65025. * @param source The mesh or sprite that triggered the action
  65026. * @param pointerX The X mouse cursor position at the time of the event
  65027. * @param pointerY The Y mouse cursor position at the time of the event
  65028. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  65029. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  65030. * @param additionalData additional data for the event
  65031. */
  65032. constructor(
  65033. /** The mesh or sprite that triggered the action */
  65034. source: any,
  65035. /** The X mouse cursor position at the time of the event */
  65036. pointerX: number,
  65037. /** The Y mouse cursor position at the time of the event */
  65038. pointerY: number,
  65039. /** The mesh that is currently pointed at (can be null) */
  65040. meshUnderPointer: Nullable<AbstractMesh>,
  65041. /** the original (browser) event that triggered the ActionEvent */
  65042. sourceEvent?: any,
  65043. /** additional data for the event */
  65044. additionalData?: any);
  65045. /**
  65046. * Helper function to auto-create an ActionEvent from a source mesh.
  65047. * @param source The source mesh that triggered the event
  65048. * @param evt The original (browser) event
  65049. * @param additionalData additional data for the event
  65050. * @returns the new ActionEvent
  65051. */
  65052. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  65053. /**
  65054. * Helper function to auto-create an ActionEvent from a source sprite
  65055. * @param source The source sprite that triggered the event
  65056. * @param scene Scene associated with the sprite
  65057. * @param evt The original (browser) event
  65058. * @param additionalData additional data for the event
  65059. * @returns the new ActionEvent
  65060. */
  65061. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  65062. /**
  65063. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  65064. * @param scene the scene where the event occurred
  65065. * @param evt The original (browser) event
  65066. * @returns the new ActionEvent
  65067. */
  65068. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  65069. /**
  65070. * Helper function to auto-create an ActionEvent from a primitive
  65071. * @param prim defines the target primitive
  65072. * @param pointerPos defines the pointer position
  65073. * @param evt The original (browser) event
  65074. * @param additionalData additional data for the event
  65075. * @returns the new ActionEvent
  65076. */
  65077. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  65078. }
  65079. }
  65080. declare module BABYLON {
  65081. /**
  65082. * Interface describing all the common properties and methods a shadow light needs to implement.
  65083. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  65084. * as well as binding the different shadow properties to the effects.
  65085. */
  65086. export interface IShadowLight extends Light {
  65087. /**
  65088. * The light id in the scene (used in scene.findLighById for instance)
  65089. */
  65090. id: string;
  65091. /**
  65092. * The position the shdow will be casted from.
  65093. */
  65094. position: Vector3;
  65095. /**
  65096. * In 2d mode (needCube being false), the direction used to cast the shadow.
  65097. */
  65098. direction: Vector3;
  65099. /**
  65100. * The transformed position. Position of the light in world space taking parenting in account.
  65101. */
  65102. transformedPosition: Vector3;
  65103. /**
  65104. * The transformed direction. Direction of the light in world space taking parenting in account.
  65105. */
  65106. transformedDirection: Vector3;
  65107. /**
  65108. * The friendly name of the light in the scene.
  65109. */
  65110. name: string;
  65111. /**
  65112. * Defines the shadow projection clipping minimum z value.
  65113. */
  65114. shadowMinZ: number;
  65115. /**
  65116. * Defines the shadow projection clipping maximum z value.
  65117. */
  65118. shadowMaxZ: number;
  65119. /**
  65120. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65121. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65122. */
  65123. computeTransformedInformation(): boolean;
  65124. /**
  65125. * Gets the scene the light belongs to.
  65126. * @returns The scene
  65127. */
  65128. getScene(): Scene;
  65129. /**
  65130. * Callback defining a custom Projection Matrix Builder.
  65131. * This can be used to override the default projection matrix computation.
  65132. */
  65133. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65134. /**
  65135. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65136. * @param matrix The materix to updated with the projection information
  65137. * @param viewMatrix The transform matrix of the light
  65138. * @param renderList The list of mesh to render in the map
  65139. * @returns The current light
  65140. */
  65141. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65142. /**
  65143. * Gets the current depth scale used in ESM.
  65144. * @returns The scale
  65145. */
  65146. getDepthScale(): number;
  65147. /**
  65148. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65149. * @returns true if a cube texture needs to be use
  65150. */
  65151. needCube(): boolean;
  65152. /**
  65153. * Detects if the projection matrix requires to be recomputed this frame.
  65154. * @returns true if it requires to be recomputed otherwise, false.
  65155. */
  65156. needProjectionMatrixCompute(): boolean;
  65157. /**
  65158. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65159. */
  65160. forceProjectionMatrixCompute(): void;
  65161. /**
  65162. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65163. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65164. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65165. */
  65166. getShadowDirection(faceIndex?: number): Vector3;
  65167. /**
  65168. * Gets the minZ used for shadow according to both the scene and the light.
  65169. * @param activeCamera The camera we are returning the min for
  65170. * @returns the depth min z
  65171. */
  65172. getDepthMinZ(activeCamera: Camera): number;
  65173. /**
  65174. * Gets the maxZ used for shadow according to both the scene and the light.
  65175. * @param activeCamera The camera we are returning the max for
  65176. * @returns the depth max z
  65177. */
  65178. getDepthMaxZ(activeCamera: Camera): number;
  65179. }
  65180. /**
  65181. * Base implementation IShadowLight
  65182. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65183. */
  65184. export abstract class ShadowLight extends Light implements IShadowLight {
  65185. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65186. protected _position: Vector3;
  65187. protected _setPosition(value: Vector3): void;
  65188. /**
  65189. * Sets the position the shadow will be casted from. Also use as the light position for both
  65190. * point and spot lights.
  65191. */
  65192. /**
  65193. * Sets the position the shadow will be casted from. Also use as the light position for both
  65194. * point and spot lights.
  65195. */
  65196. position: Vector3;
  65197. protected _direction: Vector3;
  65198. protected _setDirection(value: Vector3): void;
  65199. /**
  65200. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65201. * Also use as the light direction on spot and directional lights.
  65202. */
  65203. /**
  65204. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65205. * Also use as the light direction on spot and directional lights.
  65206. */
  65207. direction: Vector3;
  65208. private _shadowMinZ;
  65209. /**
  65210. * Gets the shadow projection clipping minimum z value.
  65211. */
  65212. /**
  65213. * Sets the shadow projection clipping minimum z value.
  65214. */
  65215. shadowMinZ: number;
  65216. private _shadowMaxZ;
  65217. /**
  65218. * Sets the shadow projection clipping maximum z value.
  65219. */
  65220. /**
  65221. * Gets the shadow projection clipping maximum z value.
  65222. */
  65223. shadowMaxZ: number;
  65224. /**
  65225. * Callback defining a custom Projection Matrix Builder.
  65226. * This can be used to override the default projection matrix computation.
  65227. */
  65228. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65229. /**
  65230. * The transformed position. Position of the light in world space taking parenting in account.
  65231. */
  65232. transformedPosition: Vector3;
  65233. /**
  65234. * The transformed direction. Direction of the light in world space taking parenting in account.
  65235. */
  65236. transformedDirection: Vector3;
  65237. private _needProjectionMatrixCompute;
  65238. /**
  65239. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65240. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65241. */
  65242. computeTransformedInformation(): boolean;
  65243. /**
  65244. * Return the depth scale used for the shadow map.
  65245. * @returns the depth scale.
  65246. */
  65247. getDepthScale(): number;
  65248. /**
  65249. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65250. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65251. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65252. */
  65253. getShadowDirection(faceIndex?: number): Vector3;
  65254. /**
  65255. * Returns the ShadowLight absolute position in the World.
  65256. * @returns the position vector in world space
  65257. */
  65258. getAbsolutePosition(): Vector3;
  65259. /**
  65260. * Sets the ShadowLight direction toward the passed target.
  65261. * @param target The point to target in local space
  65262. * @returns the updated ShadowLight direction
  65263. */
  65264. setDirectionToTarget(target: Vector3): Vector3;
  65265. /**
  65266. * Returns the light rotation in euler definition.
  65267. * @returns the x y z rotation in local space.
  65268. */
  65269. getRotation(): Vector3;
  65270. /**
  65271. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65272. * @returns true if a cube texture needs to be use
  65273. */
  65274. needCube(): boolean;
  65275. /**
  65276. * Detects if the projection matrix requires to be recomputed this frame.
  65277. * @returns true if it requires to be recomputed otherwise, false.
  65278. */
  65279. needProjectionMatrixCompute(): boolean;
  65280. /**
  65281. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65282. */
  65283. forceProjectionMatrixCompute(): void;
  65284. /** @hidden */
  65285. _initCache(): void;
  65286. /** @hidden */
  65287. _isSynchronized(): boolean;
  65288. /**
  65289. * Computes the world matrix of the node
  65290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65291. * @returns the world matrix
  65292. */
  65293. computeWorldMatrix(force?: boolean): Matrix;
  65294. /**
  65295. * Gets the minZ used for shadow according to both the scene and the light.
  65296. * @param activeCamera The camera we are returning the min for
  65297. * @returns the depth min z
  65298. */
  65299. getDepthMinZ(activeCamera: Camera): number;
  65300. /**
  65301. * Gets the maxZ used for shadow according to both the scene and the light.
  65302. * @param activeCamera The camera we are returning the max for
  65303. * @returns the depth max z
  65304. */
  65305. getDepthMaxZ(activeCamera: Camera): number;
  65306. /**
  65307. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65308. * @param matrix The materix to updated with the projection information
  65309. * @param viewMatrix The transform matrix of the light
  65310. * @param renderList The list of mesh to render in the map
  65311. * @returns The current light
  65312. */
  65313. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65314. }
  65315. }
  65316. declare module BABYLON {
  65317. /**
  65318. * "Static Class" containing the most commonly used helper while dealing with material for
  65319. * rendering purpose.
  65320. *
  65321. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65322. *
  65323. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65324. */
  65325. export class MaterialHelper {
  65326. /**
  65327. * Bind the current view position to an effect.
  65328. * @param effect The effect to be bound
  65329. * @param scene The scene the eyes position is used from
  65330. */
  65331. static BindEyePosition(effect: Effect, scene: Scene): void;
  65332. /**
  65333. * Helps preparing the defines values about the UVs in used in the effect.
  65334. * UVs are shared as much as we can accross channels in the shaders.
  65335. * @param texture The texture we are preparing the UVs for
  65336. * @param defines The defines to update
  65337. * @param key The channel key "diffuse", "specular"... used in the shader
  65338. */
  65339. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  65340. /**
  65341. * Binds a texture matrix value to its corrsponding uniform
  65342. * @param texture The texture to bind the matrix for
  65343. * @param uniformBuffer The uniform buffer receivin the data
  65344. * @param key The channel key "diffuse", "specular"... used in the shader
  65345. */
  65346. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  65347. /**
  65348. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65349. * @param mesh defines the current mesh
  65350. * @param scene defines the current scene
  65351. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65352. * @param pointsCloud defines if point cloud rendering has to be turned on
  65353. * @param fogEnabled defines if fog has to be turned on
  65354. * @param alphaTest defines if alpha testing has to be turned on
  65355. * @param defines defines the current list of defines
  65356. */
  65357. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  65358. /**
  65359. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65360. * @param scene defines the current scene
  65361. * @param engine defines the current engine
  65362. * @param defines specifies the list of active defines
  65363. * @param useInstances defines if instances have to be turned on
  65364. * @param useClipPlane defines if clip plane have to be turned on
  65365. */
  65366. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  65367. /**
  65368. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65369. * @param mesh The mesh containing the geometry data we will draw
  65370. * @param defines The defines to update
  65371. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65372. * @param useBones Precise whether bones should be used or not (override mesh info)
  65373. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65374. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65375. * @returns false if defines are considered not dirty and have not been checked
  65376. */
  65377. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  65378. /**
  65379. * Prepares the defines related to the light information passed in parameter
  65380. * @param scene The scene we are intending to draw
  65381. * @param mesh The mesh the effect is compiling for
  65382. * @param defines The defines to update
  65383. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65384. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65385. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65386. * @returns true if normals will be required for the rest of the effect
  65387. */
  65388. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  65389. /**
  65390. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65391. * that won t be acctive due to defines being turned off.
  65392. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65393. * @param samplersList The samplers list
  65394. * @param defines The defines helping in the list generation
  65395. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65396. */
  65397. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  65398. /**
  65399. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65400. * @param defines The defines to update while falling back
  65401. * @param fallbacks The authorized effect fallbacks
  65402. * @param maxSimultaneousLights The maximum number of lights allowed
  65403. * @param rank the current rank of the Effect
  65404. * @returns The newly affected rank
  65405. */
  65406. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  65407. /**
  65408. * Prepares the list of attributes required for morph targets according to the effect defines.
  65409. * @param attribs The current list of supported attribs
  65410. * @param mesh The mesh to prepare the morph targets attributes for
  65411. * @param defines The current Defines of the effect
  65412. */
  65413. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  65414. /**
  65415. * Prepares the list of attributes required for bones according to the effect defines.
  65416. * @param attribs The current list of supported attribs
  65417. * @param mesh The mesh to prepare the bones attributes for
  65418. * @param defines The current Defines of the effect
  65419. * @param fallbacks The current efffect fallback strategy
  65420. */
  65421. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  65422. /**
  65423. * Prepares the list of attributes required for instances according to the effect defines.
  65424. * @param attribs The current list of supported attribs
  65425. * @param defines The current Defines of the effect
  65426. */
  65427. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  65428. /**
  65429. * Binds the light shadow information to the effect for the given mesh.
  65430. * @param light The light containing the generator
  65431. * @param scene The scene the lights belongs to
  65432. * @param mesh The mesh we are binding the information to render
  65433. * @param lightIndex The light index in the effect used to render the mesh
  65434. * @param effect The effect we are binding the data to
  65435. */
  65436. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  65437. /**
  65438. * Binds the light information to the effect.
  65439. * @param light The light containing the generator
  65440. * @param effect The effect we are binding the data to
  65441. * @param lightIndex The light index in the effect used to render
  65442. */
  65443. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  65444. /**
  65445. * Binds the lights information from the scene to the effect for the given mesh.
  65446. * @param scene The scene the lights belongs to
  65447. * @param mesh The mesh we are binding the information to render
  65448. * @param effect The effect we are binding the data to
  65449. * @param defines The generated defines for the effect
  65450. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  65451. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  65452. */
  65453. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  65454. private static _tempFogColor;
  65455. /**
  65456. * Binds the fog information from the scene to the effect for the given mesh.
  65457. * @param scene The scene the lights belongs to
  65458. * @param mesh The mesh we are binding the information to render
  65459. * @param effect The effect we are binding the data to
  65460. * @param linearSpace Defines if the fog effect is applied in linear space
  65461. */
  65462. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  65463. /**
  65464. * Binds the bones information from the mesh to the effect.
  65465. * @param mesh The mesh we are binding the information to render
  65466. * @param effect The effect we are binding the data to
  65467. */
  65468. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  65469. /**
  65470. * Binds the morph targets information from the mesh to the effect.
  65471. * @param abstractMesh The mesh we are binding the information to render
  65472. * @param effect The effect we are binding the data to
  65473. */
  65474. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  65475. /**
  65476. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  65477. * @param defines The generated defines used in the effect
  65478. * @param effect The effect we are binding the data to
  65479. * @param scene The scene we are willing to render with logarithmic scale for
  65480. */
  65481. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  65482. /**
  65483. * Binds the clip plane information from the scene to the effect.
  65484. * @param scene The scene the clip plane information are extracted from
  65485. * @param effect The effect we are binding the data to
  65486. */
  65487. static BindClipPlane(effect: Effect, scene: Scene): void;
  65488. }
  65489. }
  65490. declare module BABYLON {
  65491. /** @hidden */
  65492. export var kernelBlurVaryingDeclaration: {
  65493. name: string;
  65494. shader: string;
  65495. };
  65496. }
  65497. declare module BABYLON {
  65498. /** @hidden */
  65499. export var kernelBlurFragment: {
  65500. name: string;
  65501. shader: string;
  65502. };
  65503. }
  65504. declare module BABYLON {
  65505. /** @hidden */
  65506. export var kernelBlurFragment2: {
  65507. name: string;
  65508. shader: string;
  65509. };
  65510. }
  65511. declare module BABYLON {
  65512. /** @hidden */
  65513. export var kernelBlurPixelShader: {
  65514. name: string;
  65515. shader: string;
  65516. };
  65517. }
  65518. declare module BABYLON {
  65519. /** @hidden */
  65520. export var kernelBlurVertex: {
  65521. name: string;
  65522. shader: string;
  65523. };
  65524. }
  65525. declare module BABYLON {
  65526. /** @hidden */
  65527. export var kernelBlurVertexShader: {
  65528. name: string;
  65529. shader: string;
  65530. };
  65531. }
  65532. declare module BABYLON {
  65533. /**
  65534. * The Blur Post Process which blurs an image based on a kernel and direction.
  65535. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  65536. */
  65537. export class BlurPostProcess extends PostProcess {
  65538. /** The direction in which to blur the image. */
  65539. direction: Vector2;
  65540. private blockCompilation;
  65541. protected _kernel: number;
  65542. protected _idealKernel: number;
  65543. protected _packedFloat: boolean;
  65544. private _staticDefines;
  65545. /**
  65546. * Sets the length in pixels of the blur sample region
  65547. */
  65548. /**
  65549. * Gets the length in pixels of the blur sample region
  65550. */
  65551. kernel: number;
  65552. /**
  65553. * Sets wether or not the blur needs to unpack/repack floats
  65554. */
  65555. /**
  65556. * Gets wether or not the blur is unpacking/repacking floats
  65557. */
  65558. packedFloat: boolean;
  65559. /**
  65560. * Creates a new instance BlurPostProcess
  65561. * @param name The name of the effect.
  65562. * @param direction The direction in which to blur the image.
  65563. * @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.
  65564. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  65565. * @param camera The camera to apply the render pass to.
  65566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65567. * @param engine The engine which the post process will be applied. (default: current engine)
  65568. * @param reusable If the post process can be reused on the same frame. (default: false)
  65569. * @param textureType Type of textures used when performing the post process. (default: 0)
  65570. * @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)
  65571. */
  65572. constructor(name: string,
  65573. /** The direction in which to blur the image. */
  65574. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  65575. /**
  65576. * Updates the effect with the current post process compile time values and recompiles the shader.
  65577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65580. * @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
  65581. * @param onCompiled Called when the shader has been compiled.
  65582. * @param onError Called if there is an error when compiling a shader.
  65583. */
  65584. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65585. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65586. /**
  65587. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  65588. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  65589. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  65590. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  65591. * The gaps between physical kernels are compensated for in the weighting of the samples
  65592. * @param idealKernel Ideal blur kernel.
  65593. * @return Nearest best kernel.
  65594. */
  65595. protected _nearestBestKernel(idealKernel: number): number;
  65596. /**
  65597. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  65598. * @param x The point on the Gaussian distribution to sample.
  65599. * @return the value of the Gaussian function at x.
  65600. */
  65601. protected _gaussianWeight(x: number): number;
  65602. /**
  65603. * Generates a string that can be used as a floating point number in GLSL.
  65604. * @param x Value to print.
  65605. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  65606. * @return GLSL float string.
  65607. */
  65608. protected _glslFloat(x: number, decimalFigures?: number): string;
  65609. }
  65610. }
  65611. declare module BABYLON {
  65612. /** @hidden */
  65613. export var shadowMapPixelShader: {
  65614. name: string;
  65615. shader: string;
  65616. };
  65617. }
  65618. declare module BABYLON {
  65619. /** @hidden */
  65620. export var bonesDeclaration: {
  65621. name: string;
  65622. shader: string;
  65623. };
  65624. }
  65625. declare module BABYLON {
  65626. /** @hidden */
  65627. export var morphTargetsVertexGlobalDeclaration: {
  65628. name: string;
  65629. shader: string;
  65630. };
  65631. }
  65632. declare module BABYLON {
  65633. /** @hidden */
  65634. export var morphTargetsVertexDeclaration: {
  65635. name: string;
  65636. shader: string;
  65637. };
  65638. }
  65639. declare module BABYLON {
  65640. /** @hidden */
  65641. export var instancesDeclaration: {
  65642. name: string;
  65643. shader: string;
  65644. };
  65645. }
  65646. declare module BABYLON {
  65647. /** @hidden */
  65648. export var helperFunctions: {
  65649. name: string;
  65650. shader: string;
  65651. };
  65652. }
  65653. declare module BABYLON {
  65654. /** @hidden */
  65655. export var morphTargetsVertex: {
  65656. name: string;
  65657. shader: string;
  65658. };
  65659. }
  65660. declare module BABYLON {
  65661. /** @hidden */
  65662. export var instancesVertex: {
  65663. name: string;
  65664. shader: string;
  65665. };
  65666. }
  65667. declare module BABYLON {
  65668. /** @hidden */
  65669. export var bonesVertex: {
  65670. name: string;
  65671. shader: string;
  65672. };
  65673. }
  65674. declare module BABYLON {
  65675. /** @hidden */
  65676. export var shadowMapVertexShader: {
  65677. name: string;
  65678. shader: string;
  65679. };
  65680. }
  65681. declare module BABYLON {
  65682. /** @hidden */
  65683. export var depthBoxBlurPixelShader: {
  65684. name: string;
  65685. shader: string;
  65686. };
  65687. }
  65688. declare module BABYLON {
  65689. /**
  65690. * Defines the options associated with the creation of a custom shader for a shadow generator.
  65691. */
  65692. export interface ICustomShaderOptions {
  65693. /**
  65694. * Gets or sets the custom shader name to use
  65695. */
  65696. shaderName: string;
  65697. /**
  65698. * The list of attribute names used in the shader
  65699. */
  65700. attributes?: string[];
  65701. /**
  65702. * The list of unifrom names used in the shader
  65703. */
  65704. uniforms?: string[];
  65705. /**
  65706. * The list of sampler names used in the shader
  65707. */
  65708. samplers?: string[];
  65709. /**
  65710. * The list of defines used in the shader
  65711. */
  65712. defines?: string[];
  65713. }
  65714. /**
  65715. * Interface to implement to create a shadow generator compatible with BJS.
  65716. */
  65717. export interface IShadowGenerator {
  65718. /**
  65719. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  65720. * @returns The render target texture if present otherwise, null
  65721. */
  65722. getShadowMap(): Nullable<RenderTargetTexture>;
  65723. /**
  65724. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  65725. * @returns The render target texture if the shadow map is present otherwise, null
  65726. */
  65727. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  65728. /**
  65729. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  65730. * @param subMesh The submesh we want to render in the shadow map
  65731. * @param useInstances Defines wether will draw in the map using instances
  65732. * @returns true if ready otherwise, false
  65733. */
  65734. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65735. /**
  65736. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  65737. * @param defines Defines of the material we want to update
  65738. * @param lightIndex Index of the light in the enabled light list of the material
  65739. */
  65740. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  65741. /**
  65742. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  65743. * defined in the generator but impacting the effect).
  65744. * It implies the unifroms available on the materials are the standard BJS ones.
  65745. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  65746. * @param effect The effect we are binfing the information for
  65747. */
  65748. bindShadowLight(lightIndex: string, effect: Effect): void;
  65749. /**
  65750. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  65751. * (eq to shadow prjection matrix * light transform matrix)
  65752. * @returns The transform matrix used to create the shadow map
  65753. */
  65754. getTransformMatrix(): Matrix;
  65755. /**
  65756. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  65757. * Cube and 2D textures for instance.
  65758. */
  65759. recreateShadowMap(): void;
  65760. /**
  65761. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65762. * @param onCompiled Callback triggered at the and of the effects compilation
  65763. * @param options Sets of optional options forcing the compilation with different modes
  65764. */
  65765. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  65766. useInstances: boolean;
  65767. }>): void;
  65768. /**
  65769. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65770. * @param options Sets of optional options forcing the compilation with different modes
  65771. * @returns A promise that resolves when the compilation completes
  65772. */
  65773. forceCompilationAsync(options?: Partial<{
  65774. useInstances: boolean;
  65775. }>): Promise<void>;
  65776. /**
  65777. * Serializes the shadow generator setup to a json object.
  65778. * @returns The serialized JSON object
  65779. */
  65780. serialize(): any;
  65781. /**
  65782. * Disposes the Shadow map and related Textures and effects.
  65783. */
  65784. dispose(): void;
  65785. }
  65786. /**
  65787. * Default implementation IShadowGenerator.
  65788. * This is the main object responsible of generating shadows in the framework.
  65789. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  65790. */
  65791. export class ShadowGenerator implements IShadowGenerator {
  65792. /**
  65793. * Shadow generator mode None: no filtering applied.
  65794. */
  65795. static readonly FILTER_NONE: number;
  65796. /**
  65797. * Shadow generator mode ESM: Exponential Shadow Mapping.
  65798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65799. */
  65800. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  65801. /**
  65802. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  65803. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  65804. */
  65805. static readonly FILTER_POISSONSAMPLING: number;
  65806. /**
  65807. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  65808. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65809. */
  65810. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  65811. /**
  65812. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  65813. * edge artifacts on steep falloff.
  65814. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65815. */
  65816. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  65817. /**
  65818. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  65819. * edge artifacts on steep falloff.
  65820. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65821. */
  65822. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  65823. /**
  65824. * Shadow generator mode PCF: Percentage Closer Filtering
  65825. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65826. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  65827. */
  65828. static readonly FILTER_PCF: number;
  65829. /**
  65830. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  65831. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65832. * Contact Hardening
  65833. */
  65834. static readonly FILTER_PCSS: number;
  65835. /**
  65836. * Reserved for PCF and PCSS
  65837. * Highest Quality.
  65838. *
  65839. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  65840. *
  65841. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  65842. */
  65843. static readonly QUALITY_HIGH: number;
  65844. /**
  65845. * Reserved for PCF and PCSS
  65846. * Good tradeoff for quality/perf cross devices
  65847. *
  65848. * Execute PCF on a 3*3 kernel.
  65849. *
  65850. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  65851. */
  65852. static readonly QUALITY_MEDIUM: number;
  65853. /**
  65854. * Reserved for PCF and PCSS
  65855. * The lowest quality but the fastest.
  65856. *
  65857. * Execute PCF on a 1*1 kernel.
  65858. *
  65859. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  65860. */
  65861. static readonly QUALITY_LOW: number;
  65862. /** Gets or sets the custom shader name to use */
  65863. customShaderOptions: ICustomShaderOptions;
  65864. /**
  65865. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  65866. */
  65867. onBeforeShadowMapRenderObservable: Observable<Effect>;
  65868. private _bias;
  65869. /**
  65870. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  65871. */
  65872. /**
  65873. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  65874. */
  65875. bias: number;
  65876. private _normalBias;
  65877. /**
  65878. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65879. */
  65880. /**
  65881. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65882. */
  65883. normalBias: number;
  65884. private _blurBoxOffset;
  65885. /**
  65886. * Gets the blur box offset: offset applied during the blur pass.
  65887. * Only useful if useKernelBlur = false
  65888. */
  65889. /**
  65890. * Sets the blur box offset: offset applied during the blur pass.
  65891. * Only useful if useKernelBlur = false
  65892. */
  65893. blurBoxOffset: number;
  65894. private _blurScale;
  65895. /**
  65896. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  65897. * 2 means half of the size.
  65898. */
  65899. /**
  65900. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  65901. * 2 means half of the size.
  65902. */
  65903. blurScale: number;
  65904. private _blurKernel;
  65905. /**
  65906. * Gets the blur kernel: kernel size of the blur pass.
  65907. * Only useful if useKernelBlur = true
  65908. */
  65909. /**
  65910. * Sets the blur kernel: kernel size of the blur pass.
  65911. * Only useful if useKernelBlur = true
  65912. */
  65913. blurKernel: number;
  65914. private _useKernelBlur;
  65915. /**
  65916. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  65917. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65918. */
  65919. /**
  65920. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  65921. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65922. */
  65923. useKernelBlur: boolean;
  65924. private _depthScale;
  65925. /**
  65926. * Gets the depth scale used in ESM mode.
  65927. */
  65928. /**
  65929. * Sets the depth scale used in ESM mode.
  65930. * This can override the scale stored on the light.
  65931. */
  65932. depthScale: number;
  65933. private _filter;
  65934. /**
  65935. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  65936. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65937. */
  65938. /**
  65939. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  65940. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65941. */
  65942. filter: number;
  65943. /**
  65944. * Gets if the current filter is set to Poisson Sampling.
  65945. */
  65946. /**
  65947. * Sets the current filter to Poisson Sampling.
  65948. */
  65949. usePoissonSampling: boolean;
  65950. /**
  65951. * Gets if the current filter is set to ESM.
  65952. */
  65953. /**
  65954. * Sets the current filter is to ESM.
  65955. */
  65956. useExponentialShadowMap: boolean;
  65957. /**
  65958. * Gets if the current filter is set to filtered ESM.
  65959. */
  65960. /**
  65961. * Gets if the current filter is set to filtered ESM.
  65962. */
  65963. useBlurExponentialShadowMap: boolean;
  65964. /**
  65965. * Gets if the current filter is set to "close ESM" (using the inverse of the
  65966. * exponential to prevent steep falloff artifacts).
  65967. */
  65968. /**
  65969. * Sets the current filter to "close ESM" (using the inverse of the
  65970. * exponential to prevent steep falloff artifacts).
  65971. */
  65972. useCloseExponentialShadowMap: boolean;
  65973. /**
  65974. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  65975. * exponential to prevent steep falloff artifacts).
  65976. */
  65977. /**
  65978. * Sets the current filter to filtered "close ESM" (using the inverse of the
  65979. * exponential to prevent steep falloff artifacts).
  65980. */
  65981. useBlurCloseExponentialShadowMap: boolean;
  65982. /**
  65983. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  65984. */
  65985. /**
  65986. * Sets the current filter to "PCF" (percentage closer filtering).
  65987. */
  65988. usePercentageCloserFiltering: boolean;
  65989. private _filteringQuality;
  65990. /**
  65991. * Gets the PCF or PCSS Quality.
  65992. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  65993. */
  65994. /**
  65995. * Sets the PCF or PCSS Quality.
  65996. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  65997. */
  65998. filteringQuality: number;
  65999. /**
  66000. * Gets if the current filter is set to "PCSS" (contact hardening).
  66001. */
  66002. /**
  66003. * Sets the current filter to "PCSS" (contact hardening).
  66004. */
  66005. useContactHardeningShadow: boolean;
  66006. private _contactHardeningLightSizeUVRatio;
  66007. /**
  66008. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66009. * Using a ratio helps keeping shape stability independently of the map size.
  66010. *
  66011. * It does not account for the light projection as it was having too much
  66012. * instability during the light setup or during light position changes.
  66013. *
  66014. * Only valid if useContactHardeningShadow is true.
  66015. */
  66016. /**
  66017. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66018. * Using a ratio helps keeping shape stability independently of the map size.
  66019. *
  66020. * It does not account for the light projection as it was having too much
  66021. * instability during the light setup or during light position changes.
  66022. *
  66023. * Only valid if useContactHardeningShadow is true.
  66024. */
  66025. contactHardeningLightSizeUVRatio: number;
  66026. private _darkness;
  66027. /**
  66028. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  66029. * 0 means strongest and 1 would means no shadow.
  66030. * @returns the darkness.
  66031. */
  66032. getDarkness(): number;
  66033. /**
  66034. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  66035. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66036. * @returns the shadow generator allowing fluent coding.
  66037. */
  66038. setDarkness(darkness: number): ShadowGenerator;
  66039. private _transparencyShadow;
  66040. /**
  66041. * Sets the ability to have transparent shadow (boolean).
  66042. * @param transparent True if transparent else False
  66043. * @returns the shadow generator allowing fluent coding
  66044. */
  66045. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66046. private _shadowMap;
  66047. private _shadowMap2;
  66048. /**
  66049. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66050. * @returns The render target texture if present otherwise, null
  66051. */
  66052. getShadowMap(): Nullable<RenderTargetTexture>;
  66053. /**
  66054. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66055. * @returns The render target texture if the shadow map is present otherwise, null
  66056. */
  66057. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66058. /**
  66059. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66060. * @param mesh Mesh to add
  66061. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66062. * @returns the Shadow Generator itself
  66063. */
  66064. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66065. /**
  66066. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66067. * @param mesh Mesh to remove
  66068. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66069. * @returns the Shadow Generator itself
  66070. */
  66071. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66072. /**
  66073. * Controls the extent to which the shadows fade out at the edge of the frustum
  66074. * Used only by directionals and spots
  66075. */
  66076. frustumEdgeFalloff: number;
  66077. private _light;
  66078. /**
  66079. * Returns the associated light object.
  66080. * @returns the light generating the shadow
  66081. */
  66082. getLight(): IShadowLight;
  66083. /**
  66084. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66085. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66086. * It might on the other hand introduce peter panning.
  66087. */
  66088. forceBackFacesOnly: boolean;
  66089. private _scene;
  66090. private _lightDirection;
  66091. private _effect;
  66092. private _viewMatrix;
  66093. private _projectionMatrix;
  66094. private _transformMatrix;
  66095. private _cachedPosition;
  66096. private _cachedDirection;
  66097. private _cachedDefines;
  66098. private _currentRenderID;
  66099. private _boxBlurPostprocess;
  66100. private _kernelBlurXPostprocess;
  66101. private _kernelBlurYPostprocess;
  66102. private _blurPostProcesses;
  66103. private _mapSize;
  66104. private _currentFaceIndex;
  66105. private _currentFaceIndexCache;
  66106. private _textureType;
  66107. private _defaultTextureMatrix;
  66108. /** @hidden */
  66109. static _SceneComponentInitialization: (scene: Scene) => void;
  66110. /**
  66111. * Creates a ShadowGenerator object.
  66112. * A ShadowGenerator is the required tool to use the shadows.
  66113. * Each light casting shadows needs to use its own ShadowGenerator.
  66114. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66115. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66116. * @param light The light object generating the shadows.
  66117. * @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.
  66118. */
  66119. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66120. private _initializeGenerator;
  66121. private _initializeShadowMap;
  66122. private _initializeBlurRTTAndPostProcesses;
  66123. private _renderForShadowMap;
  66124. private _renderSubMeshForShadowMap;
  66125. private _applyFilterValues;
  66126. /**
  66127. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66128. * @param onCompiled Callback triggered at the and of the effects compilation
  66129. * @param options Sets of optional options forcing the compilation with different modes
  66130. */
  66131. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66132. useInstances: boolean;
  66133. }>): void;
  66134. /**
  66135. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66136. * @param options Sets of optional options forcing the compilation with different modes
  66137. * @returns A promise that resolves when the compilation completes
  66138. */
  66139. forceCompilationAsync(options?: Partial<{
  66140. useInstances: boolean;
  66141. }>): Promise<void>;
  66142. /**
  66143. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66144. * @param subMesh The submesh we want to render in the shadow map
  66145. * @param useInstances Defines wether will draw in the map using instances
  66146. * @returns true if ready otherwise, false
  66147. */
  66148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66149. /**
  66150. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66151. * @param defines Defines of the material we want to update
  66152. * @param lightIndex Index of the light in the enabled light list of the material
  66153. */
  66154. prepareDefines(defines: any, lightIndex: number): void;
  66155. /**
  66156. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66157. * defined in the generator but impacting the effect).
  66158. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66159. * @param effect The effect we are binfing the information for
  66160. */
  66161. bindShadowLight(lightIndex: string, effect: Effect): void;
  66162. /**
  66163. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66164. * (eq to shadow prjection matrix * light transform matrix)
  66165. * @returns The transform matrix used to create the shadow map
  66166. */
  66167. getTransformMatrix(): Matrix;
  66168. /**
  66169. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66170. * Cube and 2D textures for instance.
  66171. */
  66172. recreateShadowMap(): void;
  66173. private _disposeBlurPostProcesses;
  66174. private _disposeRTTandPostProcesses;
  66175. /**
  66176. * Disposes the ShadowGenerator.
  66177. * Returns nothing.
  66178. */
  66179. dispose(): void;
  66180. /**
  66181. * Serializes the shadow generator setup to a json object.
  66182. * @returns The serialized JSON object
  66183. */
  66184. serialize(): any;
  66185. /**
  66186. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66187. * @param parsedShadowGenerator The JSON object to parse
  66188. * @param scene The scene to create the shadow map for
  66189. * @returns The parsed shadow generator
  66190. */
  66191. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66192. }
  66193. }
  66194. declare module BABYLON {
  66195. /**
  66196. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66197. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66198. * 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.
  66199. */
  66200. export abstract class Light extends Node {
  66201. /**
  66202. * Falloff Default: light is falling off following the material specification:
  66203. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66204. */
  66205. static readonly FALLOFF_DEFAULT: number;
  66206. /**
  66207. * Falloff Physical: light is falling off following the inverse squared distance law.
  66208. */
  66209. static readonly FALLOFF_PHYSICAL: number;
  66210. /**
  66211. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66212. * to enhance interoperability with other engines.
  66213. */
  66214. static readonly FALLOFF_GLTF: number;
  66215. /**
  66216. * Falloff Standard: light is falling off like in the standard material
  66217. * to enhance interoperability with other materials.
  66218. */
  66219. static readonly FALLOFF_STANDARD: number;
  66220. /**
  66221. * If every light affecting the material is in this lightmapMode,
  66222. * material.lightmapTexture adds or multiplies
  66223. * (depends on material.useLightmapAsShadowmap)
  66224. * after every other light calculations.
  66225. */
  66226. static readonly LIGHTMAP_DEFAULT: number;
  66227. /**
  66228. * material.lightmapTexture as only diffuse lighting from this light
  66229. * adds only specular lighting from this light
  66230. * adds dynamic shadows
  66231. */
  66232. static readonly LIGHTMAP_SPECULAR: number;
  66233. /**
  66234. * material.lightmapTexture as only lighting
  66235. * no light calculation from this light
  66236. * only adds dynamic shadows from this light
  66237. */
  66238. static readonly LIGHTMAP_SHADOWSONLY: number;
  66239. /**
  66240. * Each light type uses the default quantity according to its type:
  66241. * point/spot lights use luminous intensity
  66242. * directional lights use illuminance
  66243. */
  66244. static readonly INTENSITYMODE_AUTOMATIC: number;
  66245. /**
  66246. * lumen (lm)
  66247. */
  66248. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66249. /**
  66250. * candela (lm/sr)
  66251. */
  66252. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66253. /**
  66254. * lux (lm/m^2)
  66255. */
  66256. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66257. /**
  66258. * nit (cd/m^2)
  66259. */
  66260. static readonly INTENSITYMODE_LUMINANCE: number;
  66261. /**
  66262. * Light type const id of the point light.
  66263. */
  66264. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66265. /**
  66266. * Light type const id of the directional light.
  66267. */
  66268. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66269. /**
  66270. * Light type const id of the spot light.
  66271. */
  66272. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66273. /**
  66274. * Light type const id of the hemispheric light.
  66275. */
  66276. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66277. /**
  66278. * Diffuse gives the basic color to an object.
  66279. */
  66280. diffuse: Color3;
  66281. /**
  66282. * Specular produces a highlight color on an object.
  66283. * Note: This is note affecting PBR materials.
  66284. */
  66285. specular: Color3;
  66286. /**
  66287. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66288. * falling off base on range or angle.
  66289. * This can be set to any values in Light.FALLOFF_x.
  66290. *
  66291. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66292. * other types of materials.
  66293. */
  66294. falloffType: number;
  66295. /**
  66296. * Strength of the light.
  66297. * Note: By default it is define in the framework own unit.
  66298. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66299. */
  66300. intensity: number;
  66301. private _range;
  66302. protected _inverseSquaredRange: number;
  66303. /**
  66304. * Defines how far from the source the light is impacting in scene units.
  66305. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66306. */
  66307. /**
  66308. * Defines how far from the source the light is impacting in scene units.
  66309. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66310. */
  66311. range: number;
  66312. /**
  66313. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66314. * of light.
  66315. */
  66316. private _photometricScale;
  66317. private _intensityMode;
  66318. /**
  66319. * Gets the photometric scale used to interpret the intensity.
  66320. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66321. */
  66322. /**
  66323. * Sets the photometric scale used to interpret the intensity.
  66324. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66325. */
  66326. intensityMode: number;
  66327. private _radius;
  66328. /**
  66329. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66330. */
  66331. /**
  66332. * sets the light radius used by PBR Materials to simulate soft area lights.
  66333. */
  66334. radius: number;
  66335. private _renderPriority;
  66336. /**
  66337. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66338. * exceeding the number allowed of the materials.
  66339. */
  66340. renderPriority: number;
  66341. private _shadowEnabled;
  66342. /**
  66343. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66344. * the current shadow generator.
  66345. */
  66346. /**
  66347. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66348. * the current shadow generator.
  66349. */
  66350. shadowEnabled: boolean;
  66351. private _includedOnlyMeshes;
  66352. /**
  66353. * Gets the only meshes impacted by this light.
  66354. */
  66355. /**
  66356. * Sets the only meshes impacted by this light.
  66357. */
  66358. includedOnlyMeshes: AbstractMesh[];
  66359. private _excludedMeshes;
  66360. /**
  66361. * Gets the meshes not impacted by this light.
  66362. */
  66363. /**
  66364. * Sets the meshes not impacted by this light.
  66365. */
  66366. excludedMeshes: AbstractMesh[];
  66367. private _excludeWithLayerMask;
  66368. /**
  66369. * Gets the layer id use to find what meshes are not impacted by the light.
  66370. * Inactive if 0
  66371. */
  66372. /**
  66373. * Sets the layer id use to find what meshes are not impacted by the light.
  66374. * Inactive if 0
  66375. */
  66376. excludeWithLayerMask: number;
  66377. private _includeOnlyWithLayerMask;
  66378. /**
  66379. * Gets the layer id use to find what meshes are impacted by the light.
  66380. * Inactive if 0
  66381. */
  66382. /**
  66383. * Sets the layer id use to find what meshes are impacted by the light.
  66384. * Inactive if 0
  66385. */
  66386. includeOnlyWithLayerMask: number;
  66387. private _lightmapMode;
  66388. /**
  66389. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66390. */
  66391. /**
  66392. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66393. */
  66394. lightmapMode: number;
  66395. /**
  66396. * Shadow generator associted to the light.
  66397. * @hidden Internal use only.
  66398. */
  66399. _shadowGenerator: Nullable<IShadowGenerator>;
  66400. /**
  66401. * @hidden Internal use only.
  66402. */
  66403. _excludedMeshesIds: string[];
  66404. /**
  66405. * @hidden Internal use only.
  66406. */
  66407. _includedOnlyMeshesIds: string[];
  66408. /**
  66409. * The current light unifom buffer.
  66410. * @hidden Internal use only.
  66411. */
  66412. _uniformBuffer: UniformBuffer;
  66413. /**
  66414. * Creates a Light object in the scene.
  66415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  66416. * @param name The firendly name of the light
  66417. * @param scene The scene the light belongs too
  66418. */
  66419. constructor(name: string, scene: Scene);
  66420. protected abstract _buildUniformLayout(): void;
  66421. /**
  66422. * Sets the passed Effect "effect" with the Light information.
  66423. * @param effect The effect to update
  66424. * @param lightIndex The index of the light in the effect to update
  66425. * @returns The light
  66426. */
  66427. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  66428. /**
  66429. * Returns the string "Light".
  66430. * @returns the class name
  66431. */
  66432. getClassName(): string;
  66433. /** @hidden */
  66434. readonly _isLight: boolean;
  66435. /**
  66436. * Converts the light information to a readable string for debug purpose.
  66437. * @param fullDetails Supports for multiple levels of logging within scene loading
  66438. * @returns the human readable light info
  66439. */
  66440. toString(fullDetails?: boolean): string;
  66441. /** @hidden */
  66442. protected _syncParentEnabledState(): void;
  66443. /**
  66444. * Set the enabled state of this node.
  66445. * @param value - the new enabled state
  66446. */
  66447. setEnabled(value: boolean): void;
  66448. /**
  66449. * Returns the Light associated shadow generator if any.
  66450. * @return the associated shadow generator.
  66451. */
  66452. getShadowGenerator(): Nullable<IShadowGenerator>;
  66453. /**
  66454. * Returns a Vector3, the absolute light position in the World.
  66455. * @returns the world space position of the light
  66456. */
  66457. getAbsolutePosition(): Vector3;
  66458. /**
  66459. * Specifies if the light will affect the passed mesh.
  66460. * @param mesh The mesh to test against the light
  66461. * @return true the mesh is affected otherwise, false.
  66462. */
  66463. canAffectMesh(mesh: AbstractMesh): boolean;
  66464. /**
  66465. * Sort function to order lights for rendering.
  66466. * @param a First Light object to compare to second.
  66467. * @param b Second Light object to compare first.
  66468. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  66469. */
  66470. static CompareLightsPriority(a: Light, b: Light): number;
  66471. /**
  66472. * Releases resources associated with this node.
  66473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66475. */
  66476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66477. /**
  66478. * Returns the light type ID (integer).
  66479. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  66480. */
  66481. getTypeID(): number;
  66482. /**
  66483. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  66484. * @returns the scaled intensity in intensity mode unit
  66485. */
  66486. getScaledIntensity(): number;
  66487. /**
  66488. * Returns a new Light object, named "name", from the current one.
  66489. * @param name The name of the cloned light
  66490. * @returns the new created light
  66491. */
  66492. clone(name: string): Nullable<Light>;
  66493. /**
  66494. * Serializes the current light into a Serialization object.
  66495. * @returns the serialized object.
  66496. */
  66497. serialize(): any;
  66498. /**
  66499. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  66500. * This new light is named "name" and added to the passed scene.
  66501. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  66502. * @param name The friendly name of the light
  66503. * @param scene The scene the new light will belong to
  66504. * @returns the constructor function
  66505. */
  66506. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  66507. /**
  66508. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  66509. * @param parsedLight The JSON representation of the light
  66510. * @param scene The scene to create the parsed light in
  66511. * @returns the created light after parsing
  66512. */
  66513. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  66514. private _hookArrayForExcluded;
  66515. private _hookArrayForIncludedOnly;
  66516. private _resyncMeshes;
  66517. /**
  66518. * Forces the meshes to update their light related information in their rendering used effects
  66519. * @hidden Internal Use Only
  66520. */
  66521. _markMeshesAsLightDirty(): void;
  66522. /**
  66523. * Recomputes the cached photometric scale if needed.
  66524. */
  66525. private _computePhotometricScale;
  66526. /**
  66527. * Returns the Photometric Scale according to the light type and intensity mode.
  66528. */
  66529. private _getPhotometricScale;
  66530. /**
  66531. * Reorder the light in the scene according to their defined priority.
  66532. * @hidden Internal Use Only
  66533. */
  66534. _reorderLightsInScene(): void;
  66535. /**
  66536. * Prepares the list of defines specific to the light type.
  66537. * @param defines the list of defines
  66538. * @param lightIndex defines the index of the light for the effect
  66539. */
  66540. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  66541. }
  66542. }
  66543. declare module BABYLON {
  66544. /**
  66545. * Interface used to define Action
  66546. */
  66547. export interface IAction {
  66548. /**
  66549. * Trigger for the action
  66550. */
  66551. trigger: number;
  66552. /** the trigger, with or without parameters, for the action */
  66553. triggerOptions: any;
  66554. /**
  66555. * Gets the trigger parameters
  66556. * @returns the trigger parameters
  66557. */
  66558. getTriggerParameter(): any;
  66559. /**
  66560. * Internal only - executes current action event
  66561. * @hidden
  66562. */
  66563. _executeCurrent(evt?: ActionEvent): void;
  66564. /**
  66565. * Serialize placeholder for child classes
  66566. * @param parent of child
  66567. * @returns the serialized object
  66568. */
  66569. serialize(parent: any): any;
  66570. }
  66571. /**
  66572. * The action to be carried out following a trigger
  66573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  66574. */
  66575. export class Action implements IAction {
  66576. /** the trigger, with or without parameters, for the action */
  66577. triggerOptions: any;
  66578. /**
  66579. * Trigger for the action
  66580. */
  66581. trigger: number;
  66582. /**
  66583. * Internal only - manager for action
  66584. * @hidden
  66585. */
  66586. _actionManager: ActionManager;
  66587. private _nextActiveAction;
  66588. private _child;
  66589. private _condition?;
  66590. private _triggerParameter;
  66591. /**
  66592. * An event triggered prior to action being executed.
  66593. */
  66594. onBeforeExecuteObservable: Observable<Action>;
  66595. /**
  66596. * Creates a new Action
  66597. * @param triggerOptions the trigger, with or without parameters, for the action
  66598. * @param condition an optional determinant of action
  66599. */
  66600. constructor(
  66601. /** the trigger, with or without parameters, for the action */
  66602. triggerOptions: any, condition?: Condition);
  66603. /**
  66604. * Internal only
  66605. * @hidden
  66606. */
  66607. _prepare(): void;
  66608. /**
  66609. * Gets the trigger parameters
  66610. * @returns the trigger parameters
  66611. */
  66612. getTriggerParameter(): any;
  66613. /**
  66614. * Internal only - executes current action event
  66615. * @hidden
  66616. */
  66617. _executeCurrent(evt?: ActionEvent): void;
  66618. /**
  66619. * Execute placeholder for child classes
  66620. * @param evt optional action event
  66621. */
  66622. execute(evt?: ActionEvent): void;
  66623. /**
  66624. * Skips to next active action
  66625. */
  66626. skipToNextActiveAction(): void;
  66627. /**
  66628. * Adds action to chain of actions, may be a DoNothingAction
  66629. * @param action defines the next action to execute
  66630. * @returns The action passed in
  66631. * @see https://www.babylonjs-playground.com/#1T30HR#0
  66632. */
  66633. then(action: Action): Action;
  66634. /**
  66635. * Internal only
  66636. * @hidden
  66637. */
  66638. _getProperty(propertyPath: string): string;
  66639. /**
  66640. * Internal only
  66641. * @hidden
  66642. */
  66643. _getEffectiveTarget(target: any, propertyPath: string): any;
  66644. /**
  66645. * Serialize placeholder for child classes
  66646. * @param parent of child
  66647. * @returns the serialized object
  66648. */
  66649. serialize(parent: any): any;
  66650. /**
  66651. * Internal only called by serialize
  66652. * @hidden
  66653. */
  66654. protected _serialize(serializedAction: any, parent?: any): any;
  66655. /**
  66656. * Internal only
  66657. * @hidden
  66658. */
  66659. static _SerializeValueAsString: (value: any) => string;
  66660. /**
  66661. * Internal only
  66662. * @hidden
  66663. */
  66664. static _GetTargetProperty: (target: Scene | Node) => {
  66665. name: string;
  66666. targetType: string;
  66667. value: string;
  66668. };
  66669. }
  66670. }
  66671. declare module BABYLON {
  66672. /**
  66673. * A Condition applied to an Action
  66674. */
  66675. export class Condition {
  66676. /**
  66677. * Internal only - manager for action
  66678. * @hidden
  66679. */
  66680. _actionManager: ActionManager;
  66681. /**
  66682. * Internal only
  66683. * @hidden
  66684. */
  66685. _evaluationId: number;
  66686. /**
  66687. * Internal only
  66688. * @hidden
  66689. */
  66690. _currentResult: boolean;
  66691. /**
  66692. * Creates a new Condition
  66693. * @param actionManager the manager of the action the condition is applied to
  66694. */
  66695. constructor(actionManager: ActionManager);
  66696. /**
  66697. * Check if the current condition is valid
  66698. * @returns a boolean
  66699. */
  66700. isValid(): boolean;
  66701. /**
  66702. * Internal only
  66703. * @hidden
  66704. */
  66705. _getProperty(propertyPath: string): string;
  66706. /**
  66707. * Internal only
  66708. * @hidden
  66709. */
  66710. _getEffectiveTarget(target: any, propertyPath: string): any;
  66711. /**
  66712. * Serialize placeholder for child classes
  66713. * @returns the serialized object
  66714. */
  66715. serialize(): any;
  66716. /**
  66717. * Internal only
  66718. * @hidden
  66719. */
  66720. protected _serialize(serializedCondition: any): any;
  66721. }
  66722. /**
  66723. * Defines specific conditional operators as extensions of Condition
  66724. */
  66725. export class ValueCondition extends Condition {
  66726. /** path to specify the property of the target the conditional operator uses */
  66727. propertyPath: string;
  66728. /** the value compared by the conditional operator against the current value of the property */
  66729. value: any;
  66730. /** the conditional operator, default ValueCondition.IsEqual */
  66731. operator: number;
  66732. /**
  66733. * Internal only
  66734. * @hidden
  66735. */
  66736. private static _IsEqual;
  66737. /**
  66738. * Internal only
  66739. * @hidden
  66740. */
  66741. private static _IsDifferent;
  66742. /**
  66743. * Internal only
  66744. * @hidden
  66745. */
  66746. private static _IsGreater;
  66747. /**
  66748. * Internal only
  66749. * @hidden
  66750. */
  66751. private static _IsLesser;
  66752. /**
  66753. * returns the number for IsEqual
  66754. */
  66755. static readonly IsEqual: number;
  66756. /**
  66757. * Returns the number for IsDifferent
  66758. */
  66759. static readonly IsDifferent: number;
  66760. /**
  66761. * Returns the number for IsGreater
  66762. */
  66763. static readonly IsGreater: number;
  66764. /**
  66765. * Returns the number for IsLesser
  66766. */
  66767. static readonly IsLesser: number;
  66768. /**
  66769. * Internal only The action manager for the condition
  66770. * @hidden
  66771. */
  66772. _actionManager: ActionManager;
  66773. /**
  66774. * Internal only
  66775. * @hidden
  66776. */
  66777. private _target;
  66778. /**
  66779. * Internal only
  66780. * @hidden
  66781. */
  66782. private _effectiveTarget;
  66783. /**
  66784. * Internal only
  66785. * @hidden
  66786. */
  66787. private _property;
  66788. /**
  66789. * Creates a new ValueCondition
  66790. * @param actionManager manager for the action the condition applies to
  66791. * @param target for the action
  66792. * @param propertyPath path to specify the property of the target the conditional operator uses
  66793. * @param value the value compared by the conditional operator against the current value of the property
  66794. * @param operator the conditional operator, default ValueCondition.IsEqual
  66795. */
  66796. constructor(actionManager: ActionManager, target: any,
  66797. /** path to specify the property of the target the conditional operator uses */
  66798. propertyPath: string,
  66799. /** the value compared by the conditional operator against the current value of the property */
  66800. value: any,
  66801. /** the conditional operator, default ValueCondition.IsEqual */
  66802. operator?: number);
  66803. /**
  66804. * Compares the given value with the property value for the specified conditional operator
  66805. * @returns the result of the comparison
  66806. */
  66807. isValid(): boolean;
  66808. /**
  66809. * Serialize the ValueCondition into a JSON compatible object
  66810. * @returns serialization object
  66811. */
  66812. serialize(): any;
  66813. /**
  66814. * Gets the name of the conditional operator for the ValueCondition
  66815. * @param operator the conditional operator
  66816. * @returns the name
  66817. */
  66818. static GetOperatorName(operator: number): string;
  66819. }
  66820. /**
  66821. * Defines a predicate condition as an extension of Condition
  66822. */
  66823. export class PredicateCondition extends Condition {
  66824. /** defines the predicate function used to validate the condition */
  66825. predicate: () => boolean;
  66826. /**
  66827. * Internal only - manager for action
  66828. * @hidden
  66829. */
  66830. _actionManager: ActionManager;
  66831. /**
  66832. * Creates a new PredicateCondition
  66833. * @param actionManager manager for the action the condition applies to
  66834. * @param predicate defines the predicate function used to validate the condition
  66835. */
  66836. constructor(actionManager: ActionManager,
  66837. /** defines the predicate function used to validate the condition */
  66838. predicate: () => boolean);
  66839. /**
  66840. * @returns the validity of the predicate condition
  66841. */
  66842. isValid(): boolean;
  66843. }
  66844. /**
  66845. * Defines a state condition as an extension of Condition
  66846. */
  66847. export class StateCondition extends Condition {
  66848. /** Value to compare with target state */
  66849. value: string;
  66850. /**
  66851. * Internal only - manager for action
  66852. * @hidden
  66853. */
  66854. _actionManager: ActionManager;
  66855. /**
  66856. * Internal only
  66857. * @hidden
  66858. */
  66859. private _target;
  66860. /**
  66861. * Creates a new StateCondition
  66862. * @param actionManager manager for the action the condition applies to
  66863. * @param target of the condition
  66864. * @param value to compare with target state
  66865. */
  66866. constructor(actionManager: ActionManager, target: any,
  66867. /** Value to compare with target state */
  66868. value: string);
  66869. /**
  66870. * Gets a boolean indicating if the current condition is met
  66871. * @returns the validity of the state
  66872. */
  66873. isValid(): boolean;
  66874. /**
  66875. * Serialize the StateCondition into a JSON compatible object
  66876. * @returns serialization object
  66877. */
  66878. serialize(): any;
  66879. }
  66880. }
  66881. declare module BABYLON {
  66882. /**
  66883. * This defines an action responsible to toggle a boolean once triggered.
  66884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66885. */
  66886. export class SwitchBooleanAction extends Action {
  66887. /**
  66888. * The path to the boolean property in the target object
  66889. */
  66890. propertyPath: string;
  66891. private _target;
  66892. private _effectiveTarget;
  66893. private _property;
  66894. /**
  66895. * Instantiate the action
  66896. * @param triggerOptions defines the trigger options
  66897. * @param target defines the object containing the boolean
  66898. * @param propertyPath defines the path to the boolean property in the target object
  66899. * @param condition defines the trigger related conditions
  66900. */
  66901. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  66902. /** @hidden */
  66903. _prepare(): void;
  66904. /**
  66905. * Execute the action toggle the boolean value.
  66906. */
  66907. execute(): void;
  66908. /**
  66909. * Serializes the actions and its related information.
  66910. * @param parent defines the object to serialize in
  66911. * @returns the serialized object
  66912. */
  66913. serialize(parent: any): any;
  66914. }
  66915. /**
  66916. * This defines an action responsible to set a the state field of the target
  66917. * to a desired value once triggered.
  66918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66919. */
  66920. export class SetStateAction extends Action {
  66921. /**
  66922. * The value to store in the state field.
  66923. */
  66924. value: string;
  66925. private _target;
  66926. /**
  66927. * Instantiate the action
  66928. * @param triggerOptions defines the trigger options
  66929. * @param target defines the object containing the state property
  66930. * @param value defines the value to store in the state field
  66931. * @param condition defines the trigger related conditions
  66932. */
  66933. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  66934. /**
  66935. * Execute the action and store the value on the target state property.
  66936. */
  66937. execute(): void;
  66938. /**
  66939. * Serializes the actions and its related information.
  66940. * @param parent defines the object to serialize in
  66941. * @returns the serialized object
  66942. */
  66943. serialize(parent: any): any;
  66944. }
  66945. /**
  66946. * This defines an action responsible to set a property of the target
  66947. * to a desired value once triggered.
  66948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66949. */
  66950. export class SetValueAction extends Action {
  66951. /**
  66952. * The path of the property to set in the target.
  66953. */
  66954. propertyPath: string;
  66955. /**
  66956. * The value to set in the property
  66957. */
  66958. value: any;
  66959. private _target;
  66960. private _effectiveTarget;
  66961. private _property;
  66962. /**
  66963. * Instantiate the action
  66964. * @param triggerOptions defines the trigger options
  66965. * @param target defines the object containing the property
  66966. * @param propertyPath defines the path of the property to set in the target
  66967. * @param value defines the value to set in the property
  66968. * @param condition defines the trigger related conditions
  66969. */
  66970. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  66971. /** @hidden */
  66972. _prepare(): void;
  66973. /**
  66974. * Execute the action and set the targetted property to the desired value.
  66975. */
  66976. execute(): void;
  66977. /**
  66978. * Serializes the actions and its related information.
  66979. * @param parent defines the object to serialize in
  66980. * @returns the serialized object
  66981. */
  66982. serialize(parent: any): any;
  66983. }
  66984. /**
  66985. * This defines an action responsible to increment the target value
  66986. * to a desired value once triggered.
  66987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66988. */
  66989. export class IncrementValueAction extends Action {
  66990. /**
  66991. * The path of the property to increment in the target.
  66992. */
  66993. propertyPath: string;
  66994. /**
  66995. * The value we should increment the property by.
  66996. */
  66997. value: any;
  66998. private _target;
  66999. private _effectiveTarget;
  67000. private _property;
  67001. /**
  67002. * Instantiate the action
  67003. * @param triggerOptions defines the trigger options
  67004. * @param target defines the object containing the property
  67005. * @param propertyPath defines the path of the property to increment in the target
  67006. * @param value defines the value value we should increment the property by
  67007. * @param condition defines the trigger related conditions
  67008. */
  67009. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67010. /** @hidden */
  67011. _prepare(): void;
  67012. /**
  67013. * Execute the action and increment the target of the value amount.
  67014. */
  67015. execute(): void;
  67016. /**
  67017. * Serializes the actions and its related information.
  67018. * @param parent defines the object to serialize in
  67019. * @returns the serialized object
  67020. */
  67021. serialize(parent: any): any;
  67022. }
  67023. /**
  67024. * This defines an action responsible to start an animation once triggered.
  67025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67026. */
  67027. export class PlayAnimationAction extends Action {
  67028. /**
  67029. * Where the animation should start (animation frame)
  67030. */
  67031. from: number;
  67032. /**
  67033. * Where the animation should stop (animation frame)
  67034. */
  67035. to: number;
  67036. /**
  67037. * Define if the animation should loop or stop after the first play.
  67038. */
  67039. loop?: boolean;
  67040. private _target;
  67041. /**
  67042. * Instantiate the action
  67043. * @param triggerOptions defines the trigger options
  67044. * @param target defines the target animation or animation name
  67045. * @param from defines from where the animation should start (animation frame)
  67046. * @param end defines where the animation should stop (animation frame)
  67047. * @param loop defines if the animation should loop or stop after the first play
  67048. * @param condition defines the trigger related conditions
  67049. */
  67050. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  67051. /** @hidden */
  67052. _prepare(): void;
  67053. /**
  67054. * Execute the action and play the animation.
  67055. */
  67056. execute(): void;
  67057. /**
  67058. * Serializes the actions and its related information.
  67059. * @param parent defines the object to serialize in
  67060. * @returns the serialized object
  67061. */
  67062. serialize(parent: any): any;
  67063. }
  67064. /**
  67065. * This defines an action responsible to stop an animation once triggered.
  67066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67067. */
  67068. export class StopAnimationAction extends Action {
  67069. private _target;
  67070. /**
  67071. * Instantiate the action
  67072. * @param triggerOptions defines the trigger options
  67073. * @param target defines the target animation or animation name
  67074. * @param condition defines the trigger related conditions
  67075. */
  67076. constructor(triggerOptions: any, target: any, condition?: Condition);
  67077. /** @hidden */
  67078. _prepare(): void;
  67079. /**
  67080. * Execute the action and stop 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 that does nothing once triggered.
  67092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67093. */
  67094. export class DoNothingAction extends Action {
  67095. /**
  67096. * Instantiate the action
  67097. * @param triggerOptions defines the trigger options
  67098. * @param condition defines the trigger related conditions
  67099. */
  67100. constructor(triggerOptions?: any, condition?: Condition);
  67101. /**
  67102. * Execute the action and do nothing.
  67103. */
  67104. execute(): void;
  67105. /**
  67106. * Serializes the actions and its related information.
  67107. * @param parent defines the object to serialize in
  67108. * @returns the serialized object
  67109. */
  67110. serialize(parent: any): any;
  67111. }
  67112. /**
  67113. * This defines an action responsible to trigger several actions once triggered.
  67114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67115. */
  67116. export class CombineAction extends Action {
  67117. /**
  67118. * The list of aggregated animations to run.
  67119. */
  67120. children: Action[];
  67121. /**
  67122. * Instantiate the action
  67123. * @param triggerOptions defines the trigger options
  67124. * @param children defines the list of aggregated animations to run
  67125. * @param condition defines the trigger related conditions
  67126. */
  67127. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  67128. /** @hidden */
  67129. _prepare(): void;
  67130. /**
  67131. * Execute the action and executes all the aggregated actions.
  67132. */
  67133. execute(evt: ActionEvent): void;
  67134. /**
  67135. * Serializes the actions and its related information.
  67136. * @param parent defines the object to serialize in
  67137. * @returns the serialized object
  67138. */
  67139. serialize(parent: any): any;
  67140. }
  67141. /**
  67142. * This defines an action responsible to run code (external event) once triggered.
  67143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67144. */
  67145. export class ExecuteCodeAction extends Action {
  67146. /**
  67147. * The callback function to run.
  67148. */
  67149. func: (evt: ActionEvent) => void;
  67150. /**
  67151. * Instantiate the action
  67152. * @param triggerOptions defines the trigger options
  67153. * @param func defines the callback function to run
  67154. * @param condition defines the trigger related conditions
  67155. */
  67156. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  67157. /**
  67158. * Execute the action and run the attached code.
  67159. */
  67160. execute(evt: ActionEvent): void;
  67161. }
  67162. /**
  67163. * This defines an action responsible to set the parent property of the target once triggered.
  67164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67165. */
  67166. export class SetParentAction extends Action {
  67167. private _parent;
  67168. private _target;
  67169. /**
  67170. * Instantiate the action
  67171. * @param triggerOptions defines the trigger options
  67172. * @param target defines the target containing the parent property
  67173. * @param parent defines from where the animation should start (animation frame)
  67174. * @param condition defines the trigger related conditions
  67175. */
  67176. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  67177. /** @hidden */
  67178. _prepare(): void;
  67179. /**
  67180. * Execute the action and set the parent property.
  67181. */
  67182. execute(): void;
  67183. /**
  67184. * Serializes the actions and its related information.
  67185. * @param parent defines the object to serialize in
  67186. * @returns the serialized object
  67187. */
  67188. serialize(parent: any): any;
  67189. }
  67190. }
  67191. declare module BABYLON {
  67192. /**
  67193. * Abstract class used to decouple action Manager from scene and meshes.
  67194. * Do not instantiate.
  67195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67196. */
  67197. export abstract class AbstractActionManager implements IDisposable {
  67198. /** Gets the list of active triggers */
  67199. static Triggers: {
  67200. [key: string]: number;
  67201. };
  67202. /** Gets the cursor to use when hovering items */
  67203. hoverCursor: string;
  67204. /** Gets the list of actions */
  67205. actions: IAction[];
  67206. /**
  67207. * Releases all associated resources
  67208. */
  67209. abstract dispose(): void;
  67210. /**
  67211. * Does this action manager has pointer triggers
  67212. */
  67213. abstract readonly hasPointerTriggers: boolean;
  67214. /**
  67215. * Does this action manager has pick triggers
  67216. */
  67217. abstract readonly hasPickTriggers: boolean;
  67218. /**
  67219. * Process a specific trigger
  67220. * @param trigger defines the trigger to process
  67221. * @param evt defines the event details to be processed
  67222. */
  67223. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  67224. /**
  67225. * Does this action manager handles actions of any of the given triggers
  67226. * @param triggers defines the triggers to be tested
  67227. * @return a boolean indicating whether one (or more) of the triggers is handled
  67228. */
  67229. abstract hasSpecificTriggers(triggers: number[]): boolean;
  67230. /**
  67231. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67232. * speed.
  67233. * @param triggerA defines the trigger to be tested
  67234. * @param triggerB defines the trigger to be tested
  67235. * @return a boolean indicating whether one (or more) of the triggers is handled
  67236. */
  67237. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67238. /**
  67239. * Does this action manager handles actions of a given trigger
  67240. * @param trigger defines the trigger to be tested
  67241. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67242. * @return whether the trigger is handled
  67243. */
  67244. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67245. /**
  67246. * Serialize this manager to a JSON object
  67247. * @param name defines the property name to store this manager
  67248. * @returns a JSON representation of this manager
  67249. */
  67250. abstract serialize(name: string): any;
  67251. /**
  67252. * Does exist one action manager with at least one trigger
  67253. **/
  67254. static readonly HasTriggers: boolean;
  67255. /**
  67256. * Does exist one action manager with at least one pick trigger
  67257. **/
  67258. static readonly HasPickTriggers: boolean;
  67259. /**
  67260. * Does exist one action manager that handles actions of a given trigger
  67261. * @param trigger defines the trigger to be tested
  67262. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  67263. **/
  67264. static HasSpecificTrigger(trigger: number): boolean;
  67265. }
  67266. }
  67267. declare module BABYLON {
  67268. /**
  67269. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  67270. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  67271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67272. */
  67273. export class ActionManager extends AbstractActionManager {
  67274. /**
  67275. * Nothing
  67276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67277. */
  67278. static readonly NothingTrigger: number;
  67279. /**
  67280. * On pick
  67281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67282. */
  67283. static readonly OnPickTrigger: number;
  67284. /**
  67285. * On left pick
  67286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67287. */
  67288. static readonly OnLeftPickTrigger: number;
  67289. /**
  67290. * On right pick
  67291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67292. */
  67293. static readonly OnRightPickTrigger: number;
  67294. /**
  67295. * On center pick
  67296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67297. */
  67298. static readonly OnCenterPickTrigger: number;
  67299. /**
  67300. * On pick down
  67301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67302. */
  67303. static readonly OnPickDownTrigger: number;
  67304. /**
  67305. * On double pick
  67306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67307. */
  67308. static readonly OnDoublePickTrigger: number;
  67309. /**
  67310. * On pick up
  67311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67312. */
  67313. static readonly OnPickUpTrigger: number;
  67314. /**
  67315. * On pick out.
  67316. * This trigger will only be raised if you also declared a OnPickDown
  67317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67318. */
  67319. static readonly OnPickOutTrigger: number;
  67320. /**
  67321. * On long press
  67322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67323. */
  67324. static readonly OnLongPressTrigger: number;
  67325. /**
  67326. * On pointer over
  67327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67328. */
  67329. static readonly OnPointerOverTrigger: number;
  67330. /**
  67331. * On pointer out
  67332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67333. */
  67334. static readonly OnPointerOutTrigger: number;
  67335. /**
  67336. * On every frame
  67337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67338. */
  67339. static readonly OnEveryFrameTrigger: number;
  67340. /**
  67341. * On intersection enter
  67342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67343. */
  67344. static readonly OnIntersectionEnterTrigger: number;
  67345. /**
  67346. * On intersection exit
  67347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67348. */
  67349. static readonly OnIntersectionExitTrigger: number;
  67350. /**
  67351. * On key down
  67352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67353. */
  67354. static readonly OnKeyDownTrigger: number;
  67355. /**
  67356. * On key up
  67357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67358. */
  67359. static readonly OnKeyUpTrigger: number;
  67360. private _scene;
  67361. /**
  67362. * Creates a new action manager
  67363. * @param scene defines the hosting scene
  67364. */
  67365. constructor(scene: Scene);
  67366. /**
  67367. * Releases all associated resources
  67368. */
  67369. dispose(): void;
  67370. /**
  67371. * Gets hosting scene
  67372. * @returns the hosting scene
  67373. */
  67374. getScene(): Scene;
  67375. /**
  67376. * Does this action manager handles actions of any of the given triggers
  67377. * @param triggers defines the triggers to be tested
  67378. * @return a boolean indicating whether one (or more) of the triggers is handled
  67379. */
  67380. hasSpecificTriggers(triggers: number[]): boolean;
  67381. /**
  67382. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67383. * speed.
  67384. * @param triggerA defines the trigger to be tested
  67385. * @param triggerB defines the trigger to be tested
  67386. * @return a boolean indicating whether one (or more) of the triggers is handled
  67387. */
  67388. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67389. /**
  67390. * Does this action manager handles actions of a given trigger
  67391. * @param trigger defines the trigger to be tested
  67392. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67393. * @return whether the trigger is handled
  67394. */
  67395. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67396. /**
  67397. * Does this action manager has pointer triggers
  67398. */
  67399. readonly hasPointerTriggers: boolean;
  67400. /**
  67401. * Does this action manager has pick triggers
  67402. */
  67403. readonly hasPickTriggers: boolean;
  67404. /**
  67405. * Registers an action to this action manager
  67406. * @param action defines the action to be registered
  67407. * @return the action amended (prepared) after registration
  67408. */
  67409. registerAction(action: Action): Nullable<Action>;
  67410. /**
  67411. * Unregisters an action to this action manager
  67412. * @param action defines the action to be unregistered
  67413. * @return a boolean indicating whether the action has been unregistered
  67414. */
  67415. unregisterAction(action: Action): Boolean;
  67416. /**
  67417. * Process a specific trigger
  67418. * @param trigger defines the trigger to process
  67419. * @param evt defines the event details to be processed
  67420. */
  67421. processTrigger(trigger: number, evt?: IActionEvent): void;
  67422. /** @hidden */
  67423. _getEffectiveTarget(target: any, propertyPath: string): any;
  67424. /** @hidden */
  67425. _getProperty(propertyPath: string): string;
  67426. /**
  67427. * Serialize this manager to a JSON object
  67428. * @param name defines the property name to store this manager
  67429. * @returns a JSON representation of this manager
  67430. */
  67431. serialize(name: string): any;
  67432. /**
  67433. * Creates a new ActionManager from a JSON data
  67434. * @param parsedActions defines the JSON data to read from
  67435. * @param object defines the hosting mesh
  67436. * @param scene defines the hosting scene
  67437. */
  67438. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  67439. /**
  67440. * Get a trigger name by index
  67441. * @param trigger defines the trigger index
  67442. * @returns a trigger name
  67443. */
  67444. static GetTriggerName(trigger: number): string;
  67445. }
  67446. }
  67447. declare module BABYLON {
  67448. /**
  67449. * Class representing a ray with position and direction
  67450. */
  67451. export class Ray {
  67452. /** origin point */
  67453. origin: Vector3;
  67454. /** direction */
  67455. direction: Vector3;
  67456. /** length of the ray */
  67457. length: number;
  67458. private static readonly TmpVector3;
  67459. private _tmpRay;
  67460. /**
  67461. * Creates a new ray
  67462. * @param origin origin point
  67463. * @param direction direction
  67464. * @param length length of the ray
  67465. */
  67466. constructor(
  67467. /** origin point */
  67468. origin: Vector3,
  67469. /** direction */
  67470. direction: Vector3,
  67471. /** length of the ray */
  67472. length?: number);
  67473. /**
  67474. * Checks if the ray intersects a box
  67475. * @param minimum bound of the box
  67476. * @param maximum bound of the box
  67477. * @param intersectionTreshold extra extend to be added to the box in all direction
  67478. * @returns if the box was hit
  67479. */
  67480. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  67481. /**
  67482. * Checks if the ray intersects a box
  67483. * @param box the bounding box to check
  67484. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  67485. * @returns if the box was hit
  67486. */
  67487. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  67488. /**
  67489. * If the ray hits a sphere
  67490. * @param sphere the bounding sphere to check
  67491. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  67492. * @returns true if it hits the sphere
  67493. */
  67494. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  67495. /**
  67496. * If the ray hits a triange
  67497. * @param vertex0 triangle vertex
  67498. * @param vertex1 triangle vertex
  67499. * @param vertex2 triangle vertex
  67500. * @returns intersection information if hit
  67501. */
  67502. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  67503. /**
  67504. * Checks if ray intersects a plane
  67505. * @param plane the plane to check
  67506. * @returns the distance away it was hit
  67507. */
  67508. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  67509. /**
  67510. * Checks if ray intersects a mesh
  67511. * @param mesh the mesh to check
  67512. * @param fastCheck if only the bounding box should checked
  67513. * @returns picking info of the intersecton
  67514. */
  67515. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  67516. /**
  67517. * Checks if ray intersects a mesh
  67518. * @param meshes the meshes to check
  67519. * @param fastCheck if only the bounding box should checked
  67520. * @param results array to store result in
  67521. * @returns Array of picking infos
  67522. */
  67523. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  67524. private _comparePickingInfo;
  67525. private static smallnum;
  67526. private static rayl;
  67527. /**
  67528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  67529. * @param sega the first point of the segment to test the intersection against
  67530. * @param segb the second point of the segment to test the intersection against
  67531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  67532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  67533. */
  67534. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  67535. /**
  67536. * Update the ray from viewport position
  67537. * @param x position
  67538. * @param y y position
  67539. * @param viewportWidth viewport width
  67540. * @param viewportHeight viewport height
  67541. * @param world world matrix
  67542. * @param view view matrix
  67543. * @param projection projection matrix
  67544. * @returns this ray updated
  67545. */
  67546. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67547. /**
  67548. * Creates a ray with origin and direction of 0,0,0
  67549. * @returns the new ray
  67550. */
  67551. static Zero(): Ray;
  67552. /**
  67553. * Creates a new ray from screen space and viewport
  67554. * @param x position
  67555. * @param y y position
  67556. * @param viewportWidth viewport width
  67557. * @param viewportHeight viewport height
  67558. * @param world world matrix
  67559. * @param view view matrix
  67560. * @param projection projection matrix
  67561. * @returns new ray
  67562. */
  67563. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67564. /**
  67565. * 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
  67566. * transformed to the given world matrix.
  67567. * @param origin The origin point
  67568. * @param end The end point
  67569. * @param world a matrix to transform the ray to. Default is the identity matrix.
  67570. * @returns the new ray
  67571. */
  67572. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  67573. /**
  67574. * Transforms a ray by a matrix
  67575. * @param ray ray to transform
  67576. * @param matrix matrix to apply
  67577. * @returns the resulting new ray
  67578. */
  67579. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  67580. /**
  67581. * Transforms a ray by a matrix
  67582. * @param ray ray to transform
  67583. * @param matrix matrix to apply
  67584. * @param result ray to store result in
  67585. */
  67586. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  67587. /**
  67588. * Unproject a ray from screen space to object space
  67589. * @param sourceX defines the screen space x coordinate to use
  67590. * @param sourceY defines the screen space y coordinate to use
  67591. * @param viewportWidth defines the current width of the viewport
  67592. * @param viewportHeight defines the current height of the viewport
  67593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67594. * @param view defines the view matrix to use
  67595. * @param projection defines the projection matrix to use
  67596. */
  67597. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  67598. }
  67599. interface Scene {
  67600. /** @hidden */
  67601. _tempPickingRay: Nullable<Ray>;
  67602. /** @hidden */
  67603. _cachedRayForTransform: Ray;
  67604. /** @hidden */
  67605. _pickWithRayInverseMatrix: Matrix;
  67606. /** @hidden */
  67607. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67608. /** @hidden */
  67609. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  67610. }
  67611. }
  67612. declare module BABYLON {
  67613. /**
  67614. * Groups all the scene component constants in one place to ease maintenance.
  67615. * @hidden
  67616. */
  67617. export class SceneComponentConstants {
  67618. static readonly NAME_EFFECTLAYER: string;
  67619. static readonly NAME_LAYER: string;
  67620. static readonly NAME_LENSFLARESYSTEM: string;
  67621. static readonly NAME_BOUNDINGBOXRENDERER: string;
  67622. static readonly NAME_PARTICLESYSTEM: string;
  67623. static readonly NAME_GAMEPAD: string;
  67624. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  67625. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  67626. static readonly NAME_DEPTHRENDERER: string;
  67627. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  67628. static readonly NAME_SPRITE: string;
  67629. static readonly NAME_OUTLINERENDERER: string;
  67630. static readonly NAME_PROCEDURALTEXTURE: string;
  67631. static readonly NAME_SHADOWGENERATOR: string;
  67632. static readonly NAME_OCTREE: string;
  67633. static readonly NAME_PHYSICSENGINE: string;
  67634. static readonly NAME_AUDIO: string;
  67635. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  67636. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67637. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  67638. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67639. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  67640. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  67641. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  67642. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  67643. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  67644. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  67645. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  67646. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  67647. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  67648. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  67649. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  67650. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  67651. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  67652. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  67653. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  67654. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  67655. static readonly STEP_AFTERRENDER_AUDIO: number;
  67656. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  67657. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  67658. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  67659. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  67660. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  67661. static readonly STEP_POINTERMOVE_SPRITE: number;
  67662. static readonly STEP_POINTERDOWN_SPRITE: number;
  67663. static readonly STEP_POINTERUP_SPRITE: number;
  67664. }
  67665. /**
  67666. * This represents a scene component.
  67667. *
  67668. * This is used to decouple the dependency the scene is having on the different workloads like
  67669. * layers, post processes...
  67670. */
  67671. export interface ISceneComponent {
  67672. /**
  67673. * The name of the component. Each component must have a unique name.
  67674. */
  67675. name: string;
  67676. /**
  67677. * The scene the component belongs to.
  67678. */
  67679. scene: Scene;
  67680. /**
  67681. * Register the component to one instance of a scene.
  67682. */
  67683. register(): void;
  67684. /**
  67685. * Rebuilds the elements related to this component in case of
  67686. * context lost for instance.
  67687. */
  67688. rebuild(): void;
  67689. /**
  67690. * Disposes the component and the associated ressources.
  67691. */
  67692. dispose(): void;
  67693. }
  67694. /**
  67695. * This represents a SERIALIZABLE scene component.
  67696. *
  67697. * This extends Scene Component to add Serialization methods on top.
  67698. */
  67699. export interface ISceneSerializableComponent extends ISceneComponent {
  67700. /**
  67701. * Adds all the element from the container to the scene
  67702. * @param container the container holding the elements
  67703. */
  67704. addFromContainer(container: AbstractScene): void;
  67705. /**
  67706. * Removes all the elements in the container from the scene
  67707. * @param container contains the elements to remove
  67708. */
  67709. removeFromContainer(container: AbstractScene): void;
  67710. /**
  67711. * Serializes the component data to the specified json object
  67712. * @param serializationObject The object to serialize to
  67713. */
  67714. serialize(serializationObject: any): void;
  67715. }
  67716. /**
  67717. * Strong typing of a Mesh related stage step action
  67718. */
  67719. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  67720. /**
  67721. * Strong typing of a Evaluate Sub Mesh related stage step action
  67722. */
  67723. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  67724. /**
  67725. * Strong typing of a Active Mesh related stage step action
  67726. */
  67727. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  67728. /**
  67729. * Strong typing of a Camera related stage step action
  67730. */
  67731. export type CameraStageAction = (camera: Camera) => void;
  67732. /**
  67733. * Strong typing of a Render Target related stage step action
  67734. */
  67735. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  67736. /**
  67737. * Strong typing of a RenderingGroup related stage step action
  67738. */
  67739. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  67740. /**
  67741. * Strong typing of a Mesh Render related stage step action
  67742. */
  67743. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  67744. /**
  67745. * Strong typing of a simple stage step action
  67746. */
  67747. export type SimpleStageAction = () => void;
  67748. /**
  67749. * Strong typing of a render target action.
  67750. */
  67751. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  67752. /**
  67753. * Strong typing of a pointer move action.
  67754. */
  67755. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  67756. /**
  67757. * Strong typing of a pointer up/down action.
  67758. */
  67759. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  67760. /**
  67761. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  67762. * @hidden
  67763. */
  67764. export class Stage<T extends Function> extends Array<{
  67765. index: number;
  67766. component: ISceneComponent;
  67767. action: T;
  67768. }> {
  67769. /**
  67770. * Hide ctor from the rest of the world.
  67771. * @param items The items to add.
  67772. */
  67773. private constructor();
  67774. /**
  67775. * Creates a new Stage.
  67776. * @returns A new instance of a Stage
  67777. */
  67778. static Create<T extends Function>(): Stage<T>;
  67779. /**
  67780. * Registers a step in an ordered way in the targeted stage.
  67781. * @param index Defines the position to register the step in
  67782. * @param component Defines the component attached to the step
  67783. * @param action Defines the action to launch during the step
  67784. */
  67785. registerStep(index: number, component: ISceneComponent, action: T): void;
  67786. /**
  67787. * Clears all the steps from the stage.
  67788. */
  67789. clear(): void;
  67790. }
  67791. }
  67792. declare module BABYLON {
  67793. interface Scene {
  67794. /** @hidden */
  67795. _pointerOverSprite: Nullable<Sprite>;
  67796. /** @hidden */
  67797. _pickedDownSprite: Nullable<Sprite>;
  67798. /** @hidden */
  67799. _tempSpritePickingRay: Nullable<Ray>;
  67800. /**
  67801. * All of the sprite managers added to this scene
  67802. * @see http://doc.babylonjs.com/babylon101/sprites
  67803. */
  67804. spriteManagers: Array<ISpriteManager>;
  67805. /**
  67806. * An event triggered when sprites rendering is about to start
  67807. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67808. */
  67809. onBeforeSpritesRenderingObservable: Observable<Scene>;
  67810. /**
  67811. * An event triggered when sprites rendering is done
  67812. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67813. */
  67814. onAfterSpritesRenderingObservable: Observable<Scene>;
  67815. /** @hidden */
  67816. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67817. /** Launch a ray to try to pick a sprite in the scene
  67818. * @param x position on screen
  67819. * @param y position on screen
  67820. * @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
  67821. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67822. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  67823. * @returns a PickingInfo
  67824. */
  67825. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67826. /** Use the given ray to pick a sprite in the scene
  67827. * @param ray The ray (in world space) to use to pick meshes
  67828. * @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
  67829. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67830. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  67831. * @returns a PickingInfo
  67832. */
  67833. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67834. /**
  67835. * Force the sprite under the pointer
  67836. * @param sprite defines the sprite to use
  67837. */
  67838. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  67839. /**
  67840. * Gets the sprite under the pointer
  67841. * @returns a Sprite or null if no sprite is under the pointer
  67842. */
  67843. getPointerOverSprite(): Nullable<Sprite>;
  67844. }
  67845. /**
  67846. * Defines the sprite scene component responsible to manage sprites
  67847. * in a given scene.
  67848. */
  67849. export class SpriteSceneComponent implements ISceneComponent {
  67850. /**
  67851. * The component name helpfull to identify the component in the list of scene components.
  67852. */
  67853. readonly name: string;
  67854. /**
  67855. * The scene the component belongs to.
  67856. */
  67857. scene: Scene;
  67858. /** @hidden */
  67859. private _spritePredicate;
  67860. /**
  67861. * Creates a new instance of the component for the given scene
  67862. * @param scene Defines the scene to register the component in
  67863. */
  67864. constructor(scene: Scene);
  67865. /**
  67866. * Registers the component in a given scene
  67867. */
  67868. register(): void;
  67869. /**
  67870. * Rebuilds the elements related to this component in case of
  67871. * context lost for instance.
  67872. */
  67873. rebuild(): void;
  67874. /**
  67875. * Disposes the component and the associated ressources.
  67876. */
  67877. dispose(): void;
  67878. private _pickSpriteButKeepRay;
  67879. private _pointerMove;
  67880. private _pointerDown;
  67881. private _pointerUp;
  67882. }
  67883. }
  67884. declare module BABYLON {
  67885. /** @hidden */
  67886. export var fogFragmentDeclaration: {
  67887. name: string;
  67888. shader: string;
  67889. };
  67890. }
  67891. declare module BABYLON {
  67892. /** @hidden */
  67893. export var fogFragment: {
  67894. name: string;
  67895. shader: string;
  67896. };
  67897. }
  67898. declare module BABYLON {
  67899. /** @hidden */
  67900. export var spritesPixelShader: {
  67901. name: string;
  67902. shader: string;
  67903. };
  67904. }
  67905. declare module BABYLON {
  67906. /** @hidden */
  67907. export var fogVertexDeclaration: {
  67908. name: string;
  67909. shader: string;
  67910. };
  67911. }
  67912. declare module BABYLON {
  67913. /** @hidden */
  67914. export var spritesVertexShader: {
  67915. name: string;
  67916. shader: string;
  67917. };
  67918. }
  67919. declare module BABYLON {
  67920. /**
  67921. * Defines the minimum interface to fullfil in order to be a sprite manager.
  67922. */
  67923. export interface ISpriteManager extends IDisposable {
  67924. /**
  67925. * Restricts the camera to viewing objects with the same layerMask.
  67926. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  67927. */
  67928. layerMask: number;
  67929. /**
  67930. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  67931. */
  67932. isPickable: boolean;
  67933. /**
  67934. * Specifies the rendering group id for this mesh (0 by default)
  67935. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  67936. */
  67937. renderingGroupId: number;
  67938. /**
  67939. * Defines the list of sprites managed by the manager.
  67940. */
  67941. sprites: Array<Sprite>;
  67942. /**
  67943. * Tests the intersection of a sprite with a specific ray.
  67944. * @param ray The ray we are sending to test the collision
  67945. * @param camera The camera space we are sending rays in
  67946. * @param predicate A predicate allowing excluding sprites from the list of object to test
  67947. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  67948. * @returns picking info or null.
  67949. */
  67950. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67951. /**
  67952. * Renders the list of sprites on screen.
  67953. */
  67954. render(): void;
  67955. }
  67956. /**
  67957. * Class used to manage multiple sprites on the same spritesheet
  67958. * @see http://doc.babylonjs.com/babylon101/sprites
  67959. */
  67960. export class SpriteManager implements ISpriteManager {
  67961. /** defines the manager's name */
  67962. name: string;
  67963. /** Gets the list of sprites */
  67964. sprites: Sprite[];
  67965. /** Gets or sets the rendering group id (0 by default) */
  67966. renderingGroupId: number;
  67967. /** Gets or sets camera layer mask */
  67968. layerMask: number;
  67969. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  67970. fogEnabled: boolean;
  67971. /** Gets or sets a boolean indicating if the sprites are pickable */
  67972. isPickable: boolean;
  67973. /** Defines the default width of a cell in the spritesheet */
  67974. cellWidth: number;
  67975. /** Defines the default height of a cell in the spritesheet */
  67976. cellHeight: number;
  67977. /**
  67978. * An event triggered when the manager is disposed.
  67979. */
  67980. onDisposeObservable: Observable<SpriteManager>;
  67981. private _onDisposeObserver;
  67982. /**
  67983. * Callback called when the manager is disposed
  67984. */
  67985. onDispose: () => void;
  67986. private _capacity;
  67987. private _spriteTexture;
  67988. private _epsilon;
  67989. private _scene;
  67990. private _vertexData;
  67991. private _buffer;
  67992. private _vertexBuffers;
  67993. private _indexBuffer;
  67994. private _effectBase;
  67995. private _effectFog;
  67996. /**
  67997. * Gets or sets the spritesheet texture
  67998. */
  67999. texture: Texture;
  68000. /**
  68001. * Creates a new sprite manager
  68002. * @param name defines the manager's name
  68003. * @param imgUrl defines the sprite sheet url
  68004. * @param capacity defines the maximum allowed number of sprites
  68005. * @param cellSize defines the size of a sprite cell
  68006. * @param scene defines the hosting scene
  68007. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68008. * @param samplingMode defines the smapling mode to use with spritesheet
  68009. */
  68010. constructor(
  68011. /** defines the manager's name */
  68012. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68013. private _appendSpriteVertex;
  68014. /**
  68015. * Intersects the sprites with a ray
  68016. * @param ray defines the ray to intersect with
  68017. * @param camera defines the current active camera
  68018. * @param predicate defines a predicate used to select candidate sprites
  68019. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68020. * @returns null if no hit or a PickingInfo
  68021. */
  68022. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68023. /**
  68024. * Render all child sprites
  68025. */
  68026. render(): void;
  68027. /**
  68028. * Release associated resources
  68029. */
  68030. dispose(): void;
  68031. }
  68032. }
  68033. declare module BABYLON {
  68034. /**
  68035. * Class used to represent a sprite
  68036. * @see http://doc.babylonjs.com/babylon101/sprites
  68037. */
  68038. export class Sprite {
  68039. /** defines the name */
  68040. name: string;
  68041. /** Gets or sets the current world position */
  68042. position: Vector3;
  68043. /** Gets or sets the main color */
  68044. color: Color4;
  68045. /** Gets or sets the width */
  68046. width: number;
  68047. /** Gets or sets the height */
  68048. height: number;
  68049. /** Gets or sets rotation angle */
  68050. angle: number;
  68051. /** Gets or sets the cell index in the sprite sheet */
  68052. cellIndex: number;
  68053. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  68054. invertU: number;
  68055. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  68056. invertV: number;
  68057. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  68058. disposeWhenFinishedAnimating: boolean;
  68059. /** Gets the list of attached animations */
  68060. animations: Animation[];
  68061. /** Gets or sets a boolean indicating if the sprite can be picked */
  68062. isPickable: boolean;
  68063. /**
  68064. * Gets or sets the associated action manager
  68065. */
  68066. actionManager: Nullable<ActionManager>;
  68067. private _animationStarted;
  68068. private _loopAnimation;
  68069. private _fromIndex;
  68070. private _toIndex;
  68071. private _delay;
  68072. private _direction;
  68073. private _manager;
  68074. private _time;
  68075. private _onAnimationEnd;
  68076. /**
  68077. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  68078. */
  68079. isVisible: boolean;
  68080. /**
  68081. * Gets or sets the sprite size
  68082. */
  68083. size: number;
  68084. /**
  68085. * Creates a new Sprite
  68086. * @param name defines the name
  68087. * @param manager defines the manager
  68088. */
  68089. constructor(
  68090. /** defines the name */
  68091. name: string, manager: ISpriteManager);
  68092. /**
  68093. * Starts an animation
  68094. * @param from defines the initial key
  68095. * @param to defines the end key
  68096. * @param loop defines if the animation must loop
  68097. * @param delay defines the start delay (in ms)
  68098. * @param onAnimationEnd defines a callback to call when animation ends
  68099. */
  68100. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  68101. /** Stops current animation (if any) */
  68102. stopAnimation(): void;
  68103. /** @hidden */
  68104. _animate(deltaTime: number): void;
  68105. /** Release associated resources */
  68106. dispose(): void;
  68107. }
  68108. }
  68109. declare module BABYLON {
  68110. /**
  68111. * Information about the result of picking within a scene
  68112. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  68113. */
  68114. export class PickingInfo {
  68115. /** @hidden */
  68116. _pickingUnavailable: boolean;
  68117. /**
  68118. * If the pick collided with an object
  68119. */
  68120. hit: boolean;
  68121. /**
  68122. * Distance away where the pick collided
  68123. */
  68124. distance: number;
  68125. /**
  68126. * The location of pick collision
  68127. */
  68128. pickedPoint: Nullable<Vector3>;
  68129. /**
  68130. * The mesh corresponding the the pick collision
  68131. */
  68132. pickedMesh: Nullable<AbstractMesh>;
  68133. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  68134. bu: number;
  68135. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  68136. bv: number;
  68137. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  68138. faceId: number;
  68139. /** Id of the the submesh that was picked */
  68140. subMeshId: number;
  68141. /** If a sprite was picked, this will be the sprite the pick collided with */
  68142. pickedSprite: Nullable<Sprite>;
  68143. /**
  68144. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  68145. */
  68146. originMesh: Nullable<AbstractMesh>;
  68147. /**
  68148. * The ray that was used to perform the picking.
  68149. */
  68150. ray: Nullable<Ray>;
  68151. /**
  68152. * Gets the normal correspodning to the face the pick collided with
  68153. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  68154. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  68155. * @returns The normal correspodning to the face the pick collided with
  68156. */
  68157. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  68158. /**
  68159. * Gets the texture coordinates of where the pick occured
  68160. * @returns the vector containing the coordnates of the texture
  68161. */
  68162. getTextureCoordinates(): Nullable<Vector2>;
  68163. }
  68164. }
  68165. declare module BABYLON {
  68166. /**
  68167. * Gather the list of pointer event types as constants.
  68168. */
  68169. export class PointerEventTypes {
  68170. /**
  68171. * 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.
  68172. */
  68173. static readonly POINTERDOWN: number;
  68174. /**
  68175. * The pointerup event is fired when a pointer is no longer active.
  68176. */
  68177. static readonly POINTERUP: number;
  68178. /**
  68179. * The pointermove event is fired when a pointer changes coordinates.
  68180. */
  68181. static readonly POINTERMOVE: number;
  68182. /**
  68183. * The pointerwheel event is fired when a mouse wheel has been rotated.
  68184. */
  68185. static readonly POINTERWHEEL: number;
  68186. /**
  68187. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  68188. */
  68189. static readonly POINTERPICK: number;
  68190. /**
  68191. * The pointertap event is fired when a the object has been touched and released without drag.
  68192. */
  68193. static readonly POINTERTAP: number;
  68194. /**
  68195. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  68196. */
  68197. static readonly POINTERDOUBLETAP: number;
  68198. }
  68199. /**
  68200. * Base class of pointer info types.
  68201. */
  68202. export class PointerInfoBase {
  68203. /**
  68204. * Defines the type of event (PointerEventTypes)
  68205. */
  68206. type: number;
  68207. /**
  68208. * Defines the related dom event
  68209. */
  68210. event: PointerEvent | MouseWheelEvent;
  68211. /**
  68212. * Instantiates the base class of pointers info.
  68213. * @param type Defines the type of event (PointerEventTypes)
  68214. * @param event Defines the related dom event
  68215. */
  68216. constructor(
  68217. /**
  68218. * Defines the type of event (PointerEventTypes)
  68219. */
  68220. type: number,
  68221. /**
  68222. * Defines the related dom event
  68223. */
  68224. event: PointerEvent | MouseWheelEvent);
  68225. }
  68226. /**
  68227. * This class is used to store pointer related info for the onPrePointerObservable event.
  68228. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  68229. */
  68230. export class PointerInfoPre extends PointerInfoBase {
  68231. /**
  68232. * Ray from a pointer if availible (eg. 6dof controller)
  68233. */
  68234. ray: Nullable<Ray>;
  68235. /**
  68236. * Defines the local position of the pointer on the canvas.
  68237. */
  68238. localPosition: Vector2;
  68239. /**
  68240. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  68241. */
  68242. skipOnPointerObservable: boolean;
  68243. /**
  68244. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  68245. * @param type Defines the type of event (PointerEventTypes)
  68246. * @param event Defines the related dom event
  68247. * @param localX Defines the local x coordinates of the pointer when the event occured
  68248. * @param localY Defines the local y coordinates of the pointer when the event occured
  68249. */
  68250. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  68251. }
  68252. /**
  68253. * This type contains all the data related to a pointer event in Babylon.js.
  68254. * 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.
  68255. */
  68256. export class PointerInfo extends PointerInfoBase {
  68257. /**
  68258. * Defines the picking info associated to the info (if any)\
  68259. */
  68260. pickInfo: Nullable<PickingInfo>;
  68261. /**
  68262. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  68263. * @param type Defines the type of event (PointerEventTypes)
  68264. * @param event Defines the related dom event
  68265. * @param pickInfo Defines the picking info associated to the info (if any)\
  68266. */
  68267. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  68268. /**
  68269. * Defines the picking info associated to the info (if any)\
  68270. */
  68271. pickInfo: Nullable<PickingInfo>);
  68272. }
  68273. }
  68274. declare module BABYLON {
  68275. /**
  68276. * Manage the mouse inputs to control the movement of a free camera.
  68277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68278. */
  68279. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  68280. /**
  68281. * Define if touch is enabled in the mouse input
  68282. */
  68283. touchEnabled: boolean;
  68284. /**
  68285. * Defines the camera the input is attached to.
  68286. */
  68287. camera: FreeCamera;
  68288. /**
  68289. * Defines the buttons associated with the input to handle camera move.
  68290. */
  68291. buttons: number[];
  68292. /**
  68293. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  68294. */
  68295. angularSensibility: number;
  68296. private _pointerInput;
  68297. private _onMouseMove;
  68298. private _observer;
  68299. private previousPosition;
  68300. /**
  68301. * Manage the mouse inputs to control the movement of a free camera.
  68302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68303. * @param touchEnabled Defines if touch is enabled or not
  68304. */
  68305. constructor(
  68306. /**
  68307. * Define if touch is enabled in the mouse input
  68308. */
  68309. touchEnabled?: boolean);
  68310. /**
  68311. * Attach the input controls to a specific dom element to get the input from.
  68312. * @param element Defines the element the controls should be listened from
  68313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68314. */
  68315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68316. /**
  68317. * Detach the current controls from the specified dom element.
  68318. * @param element Defines the element to stop listening the inputs from
  68319. */
  68320. detachControl(element: Nullable<HTMLElement>): void;
  68321. /**
  68322. * Gets the class name of the current intput.
  68323. * @returns the class name
  68324. */
  68325. getClassName(): string;
  68326. /**
  68327. * Get the friendly name associated with the input class.
  68328. * @returns the input friendly name
  68329. */
  68330. getSimpleName(): string;
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /**
  68335. * Manage the touch inputs to control the movement of a free camera.
  68336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68337. */
  68338. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  68339. /**
  68340. * Defines the camera the input is attached to.
  68341. */
  68342. camera: FreeCamera;
  68343. /**
  68344. * Defines the touch sensibility for rotation.
  68345. * The higher the faster.
  68346. */
  68347. touchAngularSensibility: number;
  68348. /**
  68349. * Defines the touch sensibility for move.
  68350. * The higher the faster.
  68351. */
  68352. touchMoveSensibility: number;
  68353. private _offsetX;
  68354. private _offsetY;
  68355. private _pointerPressed;
  68356. private _pointerInput;
  68357. private _observer;
  68358. private _onLostFocus;
  68359. /**
  68360. * Attach the input controls to a specific dom element to get the input from.
  68361. * @param element Defines the element the controls should be listened from
  68362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68363. */
  68364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68365. /**
  68366. * Detach the current controls from the specified dom element.
  68367. * @param element Defines the element to stop listening the inputs from
  68368. */
  68369. detachControl(element: Nullable<HTMLElement>): void;
  68370. /**
  68371. * Update the current camera state depending on the inputs that have been used this frame.
  68372. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68373. */
  68374. checkInputs(): void;
  68375. /**
  68376. * Gets the class name of the current intput.
  68377. * @returns the class name
  68378. */
  68379. getClassName(): string;
  68380. /**
  68381. * Get the friendly name associated with the input class.
  68382. * @returns the input friendly name
  68383. */
  68384. getSimpleName(): string;
  68385. }
  68386. }
  68387. declare module BABYLON {
  68388. /**
  68389. * Default Inputs manager for the FreeCamera.
  68390. * It groups all the default supported inputs for ease of use.
  68391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68392. */
  68393. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  68394. /**
  68395. * Instantiates a new FreeCameraInputsManager.
  68396. * @param camera Defines the camera the inputs belong to
  68397. */
  68398. constructor(camera: FreeCamera);
  68399. /**
  68400. * Add keyboard input support to the input manager.
  68401. * @returns the current input manager
  68402. */
  68403. addKeyboard(): FreeCameraInputsManager;
  68404. /**
  68405. * Add mouse input support to the input manager.
  68406. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  68407. * @returns the current input manager
  68408. */
  68409. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  68410. /**
  68411. * Add touch input support to the input manager.
  68412. * @returns the current input manager
  68413. */
  68414. addTouch(): FreeCameraInputsManager;
  68415. }
  68416. }
  68417. declare module BABYLON {
  68418. /**
  68419. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68420. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  68421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68422. */
  68423. export class FreeCamera extends TargetCamera {
  68424. /**
  68425. * Define the collision ellipsoid of the camera.
  68426. * This is helpful to simulate a camera body like the player body around the camera
  68427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  68428. */
  68429. ellipsoid: Vector3;
  68430. /**
  68431. * Define an offset for the position of the ellipsoid around the camera.
  68432. * This can be helpful to determine the center of the body near the gravity center of the body
  68433. * instead of its head.
  68434. */
  68435. ellipsoidOffset: Vector3;
  68436. /**
  68437. * Enable or disable collisions of the camera with the rest of the scene objects.
  68438. */
  68439. checkCollisions: boolean;
  68440. /**
  68441. * Enable or disable gravity on the camera.
  68442. */
  68443. applyGravity: boolean;
  68444. /**
  68445. * Define the input manager associated to the camera.
  68446. */
  68447. inputs: FreeCameraInputsManager;
  68448. /**
  68449. * Gets the input sensibility for a mouse input. (default is 2000.0)
  68450. * Higher values reduce sensitivity.
  68451. */
  68452. /**
  68453. * Sets the input sensibility for a mouse input. (default is 2000.0)
  68454. * Higher values reduce sensitivity.
  68455. */
  68456. angularSensibility: number;
  68457. /**
  68458. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68459. */
  68460. keysUp: number[];
  68461. /**
  68462. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68463. */
  68464. keysDown: number[];
  68465. /**
  68466. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68467. */
  68468. keysLeft: number[];
  68469. /**
  68470. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68471. */
  68472. keysRight: number[];
  68473. /**
  68474. * Event raised when the camera collide with a mesh in the scene.
  68475. */
  68476. onCollide: (collidedMesh: AbstractMesh) => void;
  68477. private _collider;
  68478. private _needMoveForGravity;
  68479. private _oldPosition;
  68480. private _diffPosition;
  68481. private _newPosition;
  68482. /** @hidden */
  68483. _localDirection: Vector3;
  68484. /** @hidden */
  68485. _transformedDirection: Vector3;
  68486. /**
  68487. * Instantiates a Free Camera.
  68488. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68489. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  68490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68491. * @param name Define the name of the camera in the scene
  68492. * @param position Define the start position of the camera in the scene
  68493. * @param scene Define the scene the camera belongs to
  68494. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68495. */
  68496. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68497. /**
  68498. * Attached controls to the current camera.
  68499. * @param element Defines the element the controls should be listened from
  68500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68501. */
  68502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68503. /**
  68504. * Detach the current controls from the camera.
  68505. * The camera will stop reacting to inputs.
  68506. * @param element Defines the element to stop listening the inputs from
  68507. */
  68508. detachControl(element: HTMLElement): void;
  68509. private _collisionMask;
  68510. /**
  68511. * Define a collision mask to limit the list of object the camera can collide with
  68512. */
  68513. collisionMask: number;
  68514. /** @hidden */
  68515. _collideWithWorld(displacement: Vector3): void;
  68516. private _onCollisionPositionChange;
  68517. /** @hidden */
  68518. _checkInputs(): void;
  68519. /** @hidden */
  68520. _decideIfNeedsToMove(): boolean;
  68521. /** @hidden */
  68522. _updatePosition(): void;
  68523. /**
  68524. * Destroy the camera and release the current resources hold by it.
  68525. */
  68526. dispose(): void;
  68527. /**
  68528. * Gets the current object class name.
  68529. * @return the class name
  68530. */
  68531. getClassName(): string;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /**
  68536. * Represents a gamepad control stick position
  68537. */
  68538. export class StickValues {
  68539. /**
  68540. * The x component of the control stick
  68541. */
  68542. x: number;
  68543. /**
  68544. * The y component of the control stick
  68545. */
  68546. y: number;
  68547. /**
  68548. * Initializes the gamepad x and y control stick values
  68549. * @param x The x component of the gamepad control stick value
  68550. * @param y The y component of the gamepad control stick value
  68551. */
  68552. constructor(
  68553. /**
  68554. * The x component of the control stick
  68555. */
  68556. x: number,
  68557. /**
  68558. * The y component of the control stick
  68559. */
  68560. y: number);
  68561. }
  68562. /**
  68563. * An interface which manages callbacks for gamepad button changes
  68564. */
  68565. export interface GamepadButtonChanges {
  68566. /**
  68567. * Called when a gamepad has been changed
  68568. */
  68569. changed: boolean;
  68570. /**
  68571. * Called when a gamepad press event has been triggered
  68572. */
  68573. pressChanged: boolean;
  68574. /**
  68575. * Called when a touch event has been triggered
  68576. */
  68577. touchChanged: boolean;
  68578. /**
  68579. * Called when a value has changed
  68580. */
  68581. valueChanged: boolean;
  68582. }
  68583. /**
  68584. * Represents a gamepad
  68585. */
  68586. export class Gamepad {
  68587. /**
  68588. * The id of the gamepad
  68589. */
  68590. id: string;
  68591. /**
  68592. * The index of the gamepad
  68593. */
  68594. index: number;
  68595. /**
  68596. * The browser gamepad
  68597. */
  68598. browserGamepad: any;
  68599. /**
  68600. * Specifies what type of gamepad this represents
  68601. */
  68602. type: number;
  68603. private _leftStick;
  68604. private _rightStick;
  68605. /** @hidden */
  68606. _isConnected: boolean;
  68607. private _leftStickAxisX;
  68608. private _leftStickAxisY;
  68609. private _rightStickAxisX;
  68610. private _rightStickAxisY;
  68611. /**
  68612. * Triggered when the left control stick has been changed
  68613. */
  68614. private _onleftstickchanged;
  68615. /**
  68616. * Triggered when the right control stick has been changed
  68617. */
  68618. private _onrightstickchanged;
  68619. /**
  68620. * Represents a gamepad controller
  68621. */
  68622. static GAMEPAD: number;
  68623. /**
  68624. * Represents a generic controller
  68625. */
  68626. static GENERIC: number;
  68627. /**
  68628. * Represents an XBox controller
  68629. */
  68630. static XBOX: number;
  68631. /**
  68632. * Represents a pose-enabled controller
  68633. */
  68634. static POSE_ENABLED: number;
  68635. /**
  68636. * Specifies whether the left control stick should be Y-inverted
  68637. */
  68638. protected _invertLeftStickY: boolean;
  68639. /**
  68640. * Specifies if the gamepad has been connected
  68641. */
  68642. readonly isConnected: boolean;
  68643. /**
  68644. * Initializes the gamepad
  68645. * @param id The id of the gamepad
  68646. * @param index The index of the gamepad
  68647. * @param browserGamepad The browser gamepad
  68648. * @param leftStickX The x component of the left joystick
  68649. * @param leftStickY The y component of the left joystick
  68650. * @param rightStickX The x component of the right joystick
  68651. * @param rightStickY The y component of the right joystick
  68652. */
  68653. constructor(
  68654. /**
  68655. * The id of the gamepad
  68656. */
  68657. id: string,
  68658. /**
  68659. * The index of the gamepad
  68660. */
  68661. index: number,
  68662. /**
  68663. * The browser gamepad
  68664. */
  68665. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  68666. /**
  68667. * Callback triggered when the left joystick has changed
  68668. * @param callback
  68669. */
  68670. onleftstickchanged(callback: (values: StickValues) => void): void;
  68671. /**
  68672. * Callback triggered when the right joystick has changed
  68673. * @param callback
  68674. */
  68675. onrightstickchanged(callback: (values: StickValues) => void): void;
  68676. /**
  68677. * Gets the left joystick
  68678. */
  68679. /**
  68680. * Sets the left joystick values
  68681. */
  68682. leftStick: StickValues;
  68683. /**
  68684. * Gets the right joystick
  68685. */
  68686. /**
  68687. * Sets the right joystick value
  68688. */
  68689. rightStick: StickValues;
  68690. /**
  68691. * Updates the gamepad joystick positions
  68692. */
  68693. update(): void;
  68694. /**
  68695. * Disposes the gamepad
  68696. */
  68697. dispose(): void;
  68698. }
  68699. /**
  68700. * Represents a generic gamepad
  68701. */
  68702. export class GenericPad extends Gamepad {
  68703. private _buttons;
  68704. private _onbuttondown;
  68705. private _onbuttonup;
  68706. /**
  68707. * Observable triggered when a button has been pressed
  68708. */
  68709. onButtonDownObservable: Observable<number>;
  68710. /**
  68711. * Observable triggered when a button has been released
  68712. */
  68713. onButtonUpObservable: Observable<number>;
  68714. /**
  68715. * Callback triggered when a button has been pressed
  68716. * @param callback Called when a button has been pressed
  68717. */
  68718. onbuttondown(callback: (buttonPressed: number) => void): void;
  68719. /**
  68720. * Callback triggered when a button has been released
  68721. * @param callback Called when a button has been released
  68722. */
  68723. onbuttonup(callback: (buttonReleased: number) => void): void;
  68724. /**
  68725. * Initializes the generic gamepad
  68726. * @param id The id of the generic gamepad
  68727. * @param index The index of the generic gamepad
  68728. * @param browserGamepad The browser gamepad
  68729. */
  68730. constructor(id: string, index: number, browserGamepad: any);
  68731. private _setButtonValue;
  68732. /**
  68733. * Updates the generic gamepad
  68734. */
  68735. update(): void;
  68736. /**
  68737. * Disposes the generic gamepad
  68738. */
  68739. dispose(): void;
  68740. }
  68741. }
  68742. declare module BABYLON {
  68743. /**
  68744. * 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.
  68745. * @see https://doc.babylonjs.com/how_to/transformnode
  68746. */
  68747. export class TransformNode extends Node {
  68748. /**
  68749. * Object will not rotate to face the camera
  68750. */
  68751. static BILLBOARDMODE_NONE: number;
  68752. /**
  68753. * Object will rotate to face the camera but only on the x axis
  68754. */
  68755. static BILLBOARDMODE_X: number;
  68756. /**
  68757. * Object will rotate to face the camera but only on the y axis
  68758. */
  68759. static BILLBOARDMODE_Y: number;
  68760. /**
  68761. * Object will rotate to face the camera but only on the z axis
  68762. */
  68763. static BILLBOARDMODE_Z: number;
  68764. /**
  68765. * Object will rotate to face the camera
  68766. */
  68767. static BILLBOARDMODE_ALL: number;
  68768. private _forward;
  68769. private _forwardInverted;
  68770. private _up;
  68771. private _right;
  68772. private _rightInverted;
  68773. private _position;
  68774. private _rotation;
  68775. private _rotationQuaternion;
  68776. protected _scaling: Vector3;
  68777. protected _isDirty: boolean;
  68778. private _transformToBoneReferal;
  68779. /**
  68780. * Set the billboard mode. Default is 0.
  68781. *
  68782. * | Value | Type | Description |
  68783. * | --- | --- | --- |
  68784. * | 0 | BILLBOARDMODE_NONE | |
  68785. * | 1 | BILLBOARDMODE_X | |
  68786. * | 2 | BILLBOARDMODE_Y | |
  68787. * | 4 | BILLBOARDMODE_Z | |
  68788. * | 7 | BILLBOARDMODE_ALL | |
  68789. *
  68790. */
  68791. billboardMode: number;
  68792. /**
  68793. * 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
  68794. */
  68795. scalingDeterminant: number;
  68796. /**
  68797. * Sets the distance of the object to max, often used by skybox
  68798. */
  68799. infiniteDistance: boolean;
  68800. /**
  68801. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  68802. * By default the system will update normals to compensate
  68803. */
  68804. ignoreNonUniformScaling: boolean;
  68805. /** @hidden */
  68806. _poseMatrix: Matrix;
  68807. /** @hidden */
  68808. _localMatrix: Matrix;
  68809. private _absolutePosition;
  68810. private _pivotMatrix;
  68811. private _pivotMatrixInverse;
  68812. protected _postMultiplyPivotMatrix: boolean;
  68813. protected _isWorldMatrixFrozen: boolean;
  68814. /** @hidden */
  68815. _indexInSceneTransformNodesArray: number;
  68816. /**
  68817. * An event triggered after the world matrix is updated
  68818. */
  68819. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  68820. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  68821. /**
  68822. * Gets a string identifying the name of the class
  68823. * @returns "TransformNode" string
  68824. */
  68825. getClassName(): string;
  68826. /**
  68827. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  68828. */
  68829. position: Vector3;
  68830. /**
  68831. * 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)).
  68832. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  68833. */
  68834. rotation: Vector3;
  68835. /**
  68836. * 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)).
  68837. */
  68838. scaling: Vector3;
  68839. /**
  68840. * 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).
  68841. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  68842. */
  68843. rotationQuaternion: Nullable<Quaternion>;
  68844. /**
  68845. * The forward direction of that transform in world space.
  68846. */
  68847. readonly forward: Vector3;
  68848. /**
  68849. * The up direction of that transform in world space.
  68850. */
  68851. readonly up: Vector3;
  68852. /**
  68853. * The right direction of that transform in world space.
  68854. */
  68855. readonly right: Vector3;
  68856. /**
  68857. * Copies the parameter passed Matrix into the mesh Pose matrix.
  68858. * @param matrix the matrix to copy the pose from
  68859. * @returns this TransformNode.
  68860. */
  68861. updatePoseMatrix(matrix: Matrix): TransformNode;
  68862. /**
  68863. * Returns the mesh Pose matrix.
  68864. * @returns the pose matrix
  68865. */
  68866. getPoseMatrix(): Matrix;
  68867. /** @hidden */
  68868. _isSynchronized(): boolean;
  68869. /** @hidden */
  68870. _initCache(): void;
  68871. /**
  68872. * Flag the transform node as dirty (Forcing it to update everything)
  68873. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  68874. * @returns this transform node
  68875. */
  68876. markAsDirty(property: string): TransformNode;
  68877. /**
  68878. * Returns the current mesh absolute position.
  68879. * Returns a Vector3.
  68880. */
  68881. readonly absolutePosition: Vector3;
  68882. /**
  68883. * Sets a new matrix to apply before all other transformation
  68884. * @param matrix defines the transform matrix
  68885. * @returns the current TransformNode
  68886. */
  68887. setPreTransformMatrix(matrix: Matrix): TransformNode;
  68888. /**
  68889. * Sets a new pivot matrix to the current node
  68890. * @param matrix defines the new pivot matrix to use
  68891. * @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
  68892. * @returns the current TransformNode
  68893. */
  68894. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  68895. /**
  68896. * Returns the mesh pivot matrix.
  68897. * Default : Identity.
  68898. * @returns the matrix
  68899. */
  68900. getPivotMatrix(): Matrix;
  68901. /**
  68902. * Prevents the World matrix to be computed any longer.
  68903. * @returns the TransformNode.
  68904. */
  68905. freezeWorldMatrix(): TransformNode;
  68906. /**
  68907. * Allows back the World matrix computation.
  68908. * @returns the TransformNode.
  68909. */
  68910. unfreezeWorldMatrix(): this;
  68911. /**
  68912. * True if the World matrix has been frozen.
  68913. */
  68914. readonly isWorldMatrixFrozen: boolean;
  68915. /**
  68916. * Retuns the mesh absolute position in the World.
  68917. * @returns a Vector3.
  68918. */
  68919. getAbsolutePosition(): Vector3;
  68920. /**
  68921. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  68922. * @param absolutePosition the absolute position to set
  68923. * @returns the TransformNode.
  68924. */
  68925. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  68926. /**
  68927. * Sets the mesh position in its local space.
  68928. * @param vector3 the position to set in localspace
  68929. * @returns the TransformNode.
  68930. */
  68931. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  68932. /**
  68933. * Returns the mesh position in the local space from the current World matrix values.
  68934. * @returns a new Vector3.
  68935. */
  68936. getPositionExpressedInLocalSpace(): Vector3;
  68937. /**
  68938. * Translates the mesh along the passed Vector3 in its local space.
  68939. * @param vector3 the distance to translate in localspace
  68940. * @returns the TransformNode.
  68941. */
  68942. locallyTranslate(vector3: Vector3): TransformNode;
  68943. private static _lookAtVectorCache;
  68944. /**
  68945. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  68946. * @param targetPoint the position (must be in same space as current mesh) to look at
  68947. * @param yawCor optional yaw (y-axis) correction in radians
  68948. * @param pitchCor optional pitch (x-axis) correction in radians
  68949. * @param rollCor optional roll (z-axis) correction in radians
  68950. * @param space the choosen space of the target
  68951. * @returns the TransformNode.
  68952. */
  68953. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  68954. /**
  68955. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68956. * This Vector3 is expressed in the World space.
  68957. * @param localAxis axis to rotate
  68958. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68959. */
  68960. getDirection(localAxis: Vector3): Vector3;
  68961. /**
  68962. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  68963. * localAxis is expressed in the mesh local space.
  68964. * result is computed in the Wordl space from the mesh World matrix.
  68965. * @param localAxis axis to rotate
  68966. * @param result the resulting transformnode
  68967. * @returns this TransformNode.
  68968. */
  68969. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  68970. /**
  68971. * Sets this transform node rotation to the given local axis.
  68972. * @param localAxis the axis in local space
  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. * @returns this TransformNode
  68977. */
  68978. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  68979. /**
  68980. * Sets a new pivot point to the current node
  68981. * @param point defines the new pivot point to use
  68982. * @param space defines if the point is in world or local space (local by default)
  68983. * @returns the current TransformNode
  68984. */
  68985. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  68986. /**
  68987. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  68988. * @returns the pivot point
  68989. */
  68990. getPivotPoint(): Vector3;
  68991. /**
  68992. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  68993. * @param result the vector3 to store the result
  68994. * @returns this TransformNode.
  68995. */
  68996. getPivotPointToRef(result: Vector3): TransformNode;
  68997. /**
  68998. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  68999. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  69000. */
  69001. getAbsolutePivotPoint(): Vector3;
  69002. /**
  69003. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  69004. * @param result vector3 to store the result
  69005. * @returns this TransformNode.
  69006. */
  69007. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  69008. /**
  69009. * Defines the passed node as the parent of the current node.
  69010. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  69011. * @param node the node ot set as the parent
  69012. * @returns this TransformNode.
  69013. */
  69014. setParent(node: Nullable<Node>): TransformNode;
  69015. private _nonUniformScaling;
  69016. /**
  69017. * True if the scaling property of this object is non uniform eg. (1,2,1)
  69018. */
  69019. readonly nonUniformScaling: boolean;
  69020. /** @hidden */
  69021. _updateNonUniformScalingState(value: boolean): boolean;
  69022. /**
  69023. * Attach the current TransformNode to another TransformNode associated with a bone
  69024. * @param bone Bone affecting the TransformNode
  69025. * @param affectedTransformNode TransformNode associated with the bone
  69026. * @returns this object
  69027. */
  69028. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  69029. /**
  69030. * Detach the transform node if its associated with a bone
  69031. * @returns this object
  69032. */
  69033. detachFromBone(): TransformNode;
  69034. private static _rotationAxisCache;
  69035. /**
  69036. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  69037. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69038. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69039. * The passed axis is also normalized.
  69040. * @param axis the axis to rotate around
  69041. * @param amount the amount to rotate in radians
  69042. * @param space Space to rotate in (Default: local)
  69043. * @returns the TransformNode.
  69044. */
  69045. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  69046. /**
  69047. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  69048. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69049. * The passed axis is also normalized. .
  69050. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  69051. * @param point the point to rotate around
  69052. * @param axis the axis to rotate around
  69053. * @param amount the amount to rotate in radians
  69054. * @returns the TransformNode
  69055. */
  69056. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  69057. /**
  69058. * Translates the mesh along the axis vector for the passed distance in the given space.
  69059. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69060. * @param axis the axis to translate in
  69061. * @param distance the distance to translate
  69062. * @param space Space to rotate in (Default: local)
  69063. * @returns the TransformNode.
  69064. */
  69065. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  69066. /**
  69067. * Adds a rotation step to the mesh current rotation.
  69068. * x, y, z are Euler angles expressed in radians.
  69069. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  69070. * This means this rotation is made in the mesh local space only.
  69071. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  69072. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  69073. * ```javascript
  69074. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  69075. * ```
  69076. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  69077. * 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.
  69078. * @param x Rotation to add
  69079. * @param y Rotation to add
  69080. * @param z Rotation to add
  69081. * @returns the TransformNode.
  69082. */
  69083. addRotation(x: number, y: number, z: number): TransformNode;
  69084. /**
  69085. * Computes the world matrix of the node
  69086. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69087. * @returns the world matrix
  69088. */
  69089. computeWorldMatrix(force?: boolean): Matrix;
  69090. protected _afterComputeWorldMatrix(): void;
  69091. /**
  69092. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  69093. * @param func callback function to add
  69094. *
  69095. * @returns the TransformNode.
  69096. */
  69097. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69098. /**
  69099. * Removes a registered callback function.
  69100. * @param func callback function to remove
  69101. * @returns the TransformNode.
  69102. */
  69103. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69104. /**
  69105. * Gets the position of the current mesh in camera space
  69106. * @param camera defines the camera to use
  69107. * @returns a position
  69108. */
  69109. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  69110. /**
  69111. * Returns the distance from the mesh to the active camera
  69112. * @param camera defines the camera to use
  69113. * @returns the distance
  69114. */
  69115. getDistanceToCamera(camera?: Nullable<Camera>): number;
  69116. /**
  69117. * Clone the current transform node
  69118. * @param name Name of the new clone
  69119. * @param newParent New parent for the clone
  69120. * @param doNotCloneChildren Do not clone children hierarchy
  69121. * @returns the new transform node
  69122. */
  69123. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  69124. /**
  69125. * Serializes the objects information.
  69126. * @param currentSerializationObject defines the object to serialize in
  69127. * @returns the serialized object
  69128. */
  69129. serialize(currentSerializationObject?: any): any;
  69130. /**
  69131. * Returns a new TransformNode object parsed from the source provided.
  69132. * @param parsedTransformNode is the source.
  69133. * @param scene the scne the object belongs to
  69134. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  69135. * @returns a new TransformNode object parsed from the source provided.
  69136. */
  69137. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  69138. /**
  69139. * Get all child-transformNodes of this node
  69140. * @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
  69141. * @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
  69142. * @returns an array of TransformNode
  69143. */
  69144. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  69145. /**
  69146. * Releases resources associated with this transform node.
  69147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69149. */
  69150. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69151. }
  69152. }
  69153. declare module BABYLON {
  69154. /**
  69155. * Defines the types of pose enabled controllers that are supported
  69156. */
  69157. export enum PoseEnabledControllerType {
  69158. /**
  69159. * HTC Vive
  69160. */
  69161. VIVE = 0,
  69162. /**
  69163. * Oculus Rift
  69164. */
  69165. OCULUS = 1,
  69166. /**
  69167. * Windows mixed reality
  69168. */
  69169. WINDOWS = 2,
  69170. /**
  69171. * Samsung gear VR
  69172. */
  69173. GEAR_VR = 3,
  69174. /**
  69175. * Google Daydream
  69176. */
  69177. DAYDREAM = 4,
  69178. /**
  69179. * Generic
  69180. */
  69181. GENERIC = 5
  69182. }
  69183. /**
  69184. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69185. */
  69186. export interface MutableGamepadButton {
  69187. /**
  69188. * Value of the button/trigger
  69189. */
  69190. value: number;
  69191. /**
  69192. * If the button/trigger is currently touched
  69193. */
  69194. touched: boolean;
  69195. /**
  69196. * If the button/trigger is currently pressed
  69197. */
  69198. pressed: boolean;
  69199. }
  69200. /**
  69201. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69202. * @hidden
  69203. */
  69204. export interface ExtendedGamepadButton extends GamepadButton {
  69205. /**
  69206. * If the button/trigger is currently pressed
  69207. */
  69208. readonly pressed: boolean;
  69209. /**
  69210. * If the button/trigger is currently touched
  69211. */
  69212. readonly touched: boolean;
  69213. /**
  69214. * Value of the button/trigger
  69215. */
  69216. readonly value: number;
  69217. }
  69218. /** @hidden */
  69219. export interface _GamePadFactory {
  69220. /**
  69221. * Returns wether or not the current gamepad can be created for this type of controller.
  69222. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69223. * @returns true if it can be created, otherwise false
  69224. */
  69225. canCreate(gamepadInfo: any): boolean;
  69226. /**
  69227. * Creates a new instance of the Gamepad.
  69228. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69229. * @returns the new gamepad instance
  69230. */
  69231. create(gamepadInfo: any): Gamepad;
  69232. }
  69233. /**
  69234. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69235. */
  69236. export class PoseEnabledControllerHelper {
  69237. /** @hidden */
  69238. static _ControllerFactories: _GamePadFactory[];
  69239. /** @hidden */
  69240. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69241. /**
  69242. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69243. * @param vrGamepad the gamepad to initialized
  69244. * @returns a vr controller of the type the gamepad identified as
  69245. */
  69246. static InitiateController(vrGamepad: any): Gamepad;
  69247. }
  69248. /**
  69249. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69250. */
  69251. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69252. private _deviceRoomPosition;
  69253. private _deviceRoomRotationQuaternion;
  69254. /**
  69255. * The device position in babylon space
  69256. */
  69257. devicePosition: Vector3;
  69258. /**
  69259. * The device rotation in babylon space
  69260. */
  69261. deviceRotationQuaternion: Quaternion;
  69262. /**
  69263. * The scale factor of the device in babylon space
  69264. */
  69265. deviceScaleFactor: number;
  69266. /**
  69267. * (Likely devicePosition should be used instead) The device position in its room space
  69268. */
  69269. position: Vector3;
  69270. /**
  69271. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69272. */
  69273. rotationQuaternion: Quaternion;
  69274. /**
  69275. * The type of controller (Eg. Windows mixed reality)
  69276. */
  69277. controllerType: PoseEnabledControllerType;
  69278. protected _calculatedPosition: Vector3;
  69279. private _calculatedRotation;
  69280. /**
  69281. * The raw pose from the device
  69282. */
  69283. rawPose: DevicePose;
  69284. private _trackPosition;
  69285. private _maxRotationDistFromHeadset;
  69286. private _draggedRoomRotation;
  69287. /**
  69288. * @hidden
  69289. */
  69290. _disableTrackPosition(fixedPosition: Vector3): void;
  69291. /**
  69292. * Internal, the mesh attached to the controller
  69293. * @hidden
  69294. */
  69295. _mesh: Nullable<AbstractMesh>;
  69296. private _poseControlledCamera;
  69297. private _leftHandSystemQuaternion;
  69298. /**
  69299. * Internal, matrix used to convert room space to babylon space
  69300. * @hidden
  69301. */
  69302. _deviceToWorld: Matrix;
  69303. /**
  69304. * Node to be used when casting a ray from the controller
  69305. * @hidden
  69306. */
  69307. _pointingPoseNode: Nullable<TransformNode>;
  69308. /**
  69309. * Name of the child mesh that can be used to cast a ray from the controller
  69310. */
  69311. static readonly POINTING_POSE: string;
  69312. /**
  69313. * Creates a new PoseEnabledController from a gamepad
  69314. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69315. */
  69316. constructor(browserGamepad: any);
  69317. private _workingMatrix;
  69318. /**
  69319. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69320. */
  69321. update(): void;
  69322. /**
  69323. * Updates only the pose device and mesh without doing any button event checking
  69324. */
  69325. protected _updatePoseAndMesh(): void;
  69326. /**
  69327. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69328. * @param poseData raw pose fromthe device
  69329. */
  69330. updateFromDevice(poseData: DevicePose): void;
  69331. /**
  69332. * @hidden
  69333. */
  69334. _meshAttachedObservable: Observable<AbstractMesh>;
  69335. /**
  69336. * Attaches a mesh to the controller
  69337. * @param mesh the mesh to be attached
  69338. */
  69339. attachToMesh(mesh: AbstractMesh): void;
  69340. /**
  69341. * Attaches the controllers mesh to a camera
  69342. * @param camera the camera the mesh should be attached to
  69343. */
  69344. attachToPoseControlledCamera(camera: TargetCamera): void;
  69345. /**
  69346. * Disposes of the controller
  69347. */
  69348. dispose(): void;
  69349. /**
  69350. * The mesh that is attached to the controller
  69351. */
  69352. readonly mesh: Nullable<AbstractMesh>;
  69353. /**
  69354. * Gets the ray of the controller in the direction the controller is pointing
  69355. * @param length the length the resulting ray should be
  69356. * @returns a ray in the direction the controller is pointing
  69357. */
  69358. getForwardRay(length?: number): Ray;
  69359. }
  69360. }
  69361. declare module BABYLON {
  69362. /**
  69363. * Defines the WebVRController object that represents controllers tracked in 3D space
  69364. */
  69365. export abstract class WebVRController extends PoseEnabledController {
  69366. /**
  69367. * Internal, the default controller model for the controller
  69368. */
  69369. protected _defaultModel: AbstractMesh;
  69370. /**
  69371. * Fired when the trigger state has changed
  69372. */
  69373. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69374. /**
  69375. * Fired when the main button state has changed
  69376. */
  69377. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69378. /**
  69379. * Fired when the secondary button state has changed
  69380. */
  69381. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69382. /**
  69383. * Fired when the pad state has changed
  69384. */
  69385. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69386. /**
  69387. * Fired when controllers stick values have changed
  69388. */
  69389. onPadValuesChangedObservable: Observable<StickValues>;
  69390. /**
  69391. * Array of button availible on the controller
  69392. */
  69393. protected _buttons: Array<MutableGamepadButton>;
  69394. private _onButtonStateChange;
  69395. /**
  69396. * Fired when a controller button's state has changed
  69397. * @param callback the callback containing the button that was modified
  69398. */
  69399. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69400. /**
  69401. * X and Y axis corrisponding to the controllers joystick
  69402. */
  69403. pad: StickValues;
  69404. /**
  69405. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69406. */
  69407. hand: string;
  69408. /**
  69409. * The default controller model for the controller
  69410. */
  69411. readonly defaultModel: AbstractMesh;
  69412. /**
  69413. * Creates a new WebVRController from a gamepad
  69414. * @param vrGamepad the gamepad that the WebVRController should be created from
  69415. */
  69416. constructor(vrGamepad: any);
  69417. /**
  69418. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69419. */
  69420. update(): void;
  69421. /**
  69422. * Function to be called when a button is modified
  69423. */
  69424. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69425. /**
  69426. * Loads a mesh and attaches it to the controller
  69427. * @param scene the scene the mesh should be added to
  69428. * @param meshLoaded callback for when the mesh has been loaded
  69429. */
  69430. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69431. private _setButtonValue;
  69432. private _changes;
  69433. private _checkChanges;
  69434. /**
  69435. * Disposes of th webVRCOntroller
  69436. */
  69437. dispose(): void;
  69438. }
  69439. }
  69440. declare module BABYLON {
  69441. /**
  69442. * The HemisphericLight simulates the ambient environment light,
  69443. * so the passed direction is the light reflection direction, not the incoming direction.
  69444. */
  69445. export class HemisphericLight extends Light {
  69446. /**
  69447. * The groundColor is the light in the opposite direction to the one specified during creation.
  69448. * 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.
  69449. */
  69450. groundColor: Color3;
  69451. /**
  69452. * The light reflection direction, not the incoming direction.
  69453. */
  69454. direction: Vector3;
  69455. /**
  69456. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69457. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69458. * The HemisphericLight can't cast shadows.
  69459. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69460. * @param name The friendly name of the light
  69461. * @param direction The direction of the light reflection
  69462. * @param scene The scene the light belongs to
  69463. */
  69464. constructor(name: string, direction: Vector3, scene: Scene);
  69465. protected _buildUniformLayout(): void;
  69466. /**
  69467. * Returns the string "HemisphericLight".
  69468. * @return The class name
  69469. */
  69470. getClassName(): string;
  69471. /**
  69472. * Sets the HemisphericLight direction towards the passed target (Vector3).
  69473. * Returns the updated direction.
  69474. * @param target The target the direction should point to
  69475. * @return The computed direction
  69476. */
  69477. setDirectionToTarget(target: Vector3): Vector3;
  69478. /**
  69479. * Returns the shadow generator associated to the light.
  69480. * @returns Always null for hemispheric lights because it does not support shadows.
  69481. */
  69482. getShadowGenerator(): Nullable<IShadowGenerator>;
  69483. /**
  69484. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  69485. * @param effect The effect to update
  69486. * @param lightIndex The index of the light in the effect to update
  69487. * @returns The hemispheric light
  69488. */
  69489. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  69490. /**
  69491. * Computes the world matrix of the node
  69492. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69493. * @param useWasUpdatedFlag defines a reserved property
  69494. * @returns the world matrix
  69495. */
  69496. computeWorldMatrix(): Matrix;
  69497. /**
  69498. * Returns the integer 3.
  69499. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69500. */
  69501. getTypeID(): number;
  69502. /**
  69503. * Prepares the list of defines specific to the light type.
  69504. * @param defines the list of defines
  69505. * @param lightIndex defines the index of the light for the effect
  69506. */
  69507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69508. }
  69509. }
  69510. declare module BABYLON {
  69511. /**
  69512. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  69513. * IMPORTANT!! The data is right-hand data.
  69514. * @export
  69515. * @interface DevicePose
  69516. */
  69517. export interface DevicePose {
  69518. /**
  69519. * The position of the device, values in array are [x,y,z].
  69520. */
  69521. readonly position: Nullable<Float32Array>;
  69522. /**
  69523. * The linearVelocity of the device, values in array are [x,y,z].
  69524. */
  69525. readonly linearVelocity: Nullable<Float32Array>;
  69526. /**
  69527. * The linearAcceleration of the device, values in array are [x,y,z].
  69528. */
  69529. readonly linearAcceleration: Nullable<Float32Array>;
  69530. /**
  69531. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  69532. */
  69533. readonly orientation: Nullable<Float32Array>;
  69534. /**
  69535. * The angularVelocity of the device, values in array are [x,y,z].
  69536. */
  69537. readonly angularVelocity: Nullable<Float32Array>;
  69538. /**
  69539. * The angularAcceleration of the device, values in array are [x,y,z].
  69540. */
  69541. readonly angularAcceleration: Nullable<Float32Array>;
  69542. }
  69543. /**
  69544. * Interface representing a pose controlled object in Babylon.
  69545. * A pose controlled object has both regular pose values as well as pose values
  69546. * from an external device such as a VR head mounted display
  69547. */
  69548. export interface PoseControlled {
  69549. /**
  69550. * The position of the object in babylon space.
  69551. */
  69552. position: Vector3;
  69553. /**
  69554. * The rotation quaternion of the object in babylon space.
  69555. */
  69556. rotationQuaternion: Quaternion;
  69557. /**
  69558. * The position of the device in babylon space.
  69559. */
  69560. devicePosition?: Vector3;
  69561. /**
  69562. * The rotation quaternion of the device in babylon space.
  69563. */
  69564. deviceRotationQuaternion: Quaternion;
  69565. /**
  69566. * The raw pose coming from the device.
  69567. */
  69568. rawPose: Nullable<DevicePose>;
  69569. /**
  69570. * The scale of the device to be used when translating from device space to babylon space.
  69571. */
  69572. deviceScaleFactor: number;
  69573. /**
  69574. * Updates the poseControlled values based on the input device pose.
  69575. * @param poseData the pose data to update the object with
  69576. */
  69577. updateFromDevice(poseData: DevicePose): void;
  69578. }
  69579. /**
  69580. * Set of options to customize the webVRCamera
  69581. */
  69582. export interface WebVROptions {
  69583. /**
  69584. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  69585. */
  69586. trackPosition?: boolean;
  69587. /**
  69588. * Sets the scale of the vrDevice in babylon space. (default: 1)
  69589. */
  69590. positionScale?: number;
  69591. /**
  69592. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  69593. */
  69594. displayName?: string;
  69595. /**
  69596. * Should the native controller meshes be initialized. (default: true)
  69597. */
  69598. controllerMeshes?: boolean;
  69599. /**
  69600. * Creating a default HemiLight only on controllers. (default: true)
  69601. */
  69602. defaultLightingOnControllers?: boolean;
  69603. /**
  69604. * If you don't want to use the default VR button of the helper. (default: false)
  69605. */
  69606. useCustomVRButton?: boolean;
  69607. /**
  69608. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  69609. */
  69610. customVRButton?: HTMLButtonElement;
  69611. /**
  69612. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  69613. */
  69614. rayLength?: number;
  69615. /**
  69616. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  69617. */
  69618. defaultHeight?: number;
  69619. }
  69620. /**
  69621. * This represents a WebVR camera.
  69622. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  69623. * @example http://doc.babylonjs.com/how_to/webvr_camera
  69624. */
  69625. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  69626. private webVROptions;
  69627. /**
  69628. * @hidden
  69629. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  69630. */
  69631. _vrDevice: any;
  69632. /**
  69633. * The rawPose of the vrDevice.
  69634. */
  69635. rawPose: Nullable<DevicePose>;
  69636. private _onVREnabled;
  69637. private _specsVersion;
  69638. private _attached;
  69639. private _frameData;
  69640. protected _descendants: Array<Node>;
  69641. private _deviceRoomPosition;
  69642. /** @hidden */
  69643. _deviceRoomRotationQuaternion: Quaternion;
  69644. private _standingMatrix;
  69645. /**
  69646. * Represents device position in babylon space.
  69647. */
  69648. devicePosition: Vector3;
  69649. /**
  69650. * Represents device rotation in babylon space.
  69651. */
  69652. deviceRotationQuaternion: Quaternion;
  69653. /**
  69654. * The scale of the device to be used when translating from device space to babylon space.
  69655. */
  69656. deviceScaleFactor: number;
  69657. private _deviceToWorld;
  69658. private _worldToDevice;
  69659. /**
  69660. * References to the webVR controllers for the vrDevice.
  69661. */
  69662. controllers: Array<WebVRController>;
  69663. /**
  69664. * Emits an event when a controller is attached.
  69665. */
  69666. onControllersAttachedObservable: Observable<WebVRController[]>;
  69667. /**
  69668. * Emits an event when a controller's mesh has been loaded;
  69669. */
  69670. onControllerMeshLoadedObservable: Observable<WebVRController>;
  69671. /**
  69672. * Emits an event when the HMD's pose has been updated.
  69673. */
  69674. onPoseUpdatedFromDeviceObservable: Observable<any>;
  69675. private _poseSet;
  69676. /**
  69677. * If the rig cameras be used as parent instead of this camera.
  69678. */
  69679. rigParenting: boolean;
  69680. private _lightOnControllers;
  69681. private _defaultHeight?;
  69682. /**
  69683. * Instantiates a WebVRFreeCamera.
  69684. * @param name The name of the WebVRFreeCamera
  69685. * @param position The starting anchor position for the camera
  69686. * @param scene The scene the camera belongs to
  69687. * @param webVROptions a set of customizable options for the webVRCamera
  69688. */
  69689. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  69690. /**
  69691. * Gets the device distance from the ground in meters.
  69692. * @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.
  69693. */
  69694. deviceDistanceToRoomGround(): number;
  69695. /**
  69696. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69697. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  69698. */
  69699. useStandingMatrix(callback?: (bool: boolean) => void): void;
  69700. /**
  69701. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69702. * @returns A promise with a boolean set to if the standing matrix is supported.
  69703. */
  69704. useStandingMatrixAsync(): Promise<boolean>;
  69705. /**
  69706. * Disposes the camera
  69707. */
  69708. dispose(): void;
  69709. /**
  69710. * Gets a vrController by name.
  69711. * @param name The name of the controller to retreive
  69712. * @returns the controller matching the name specified or null if not found
  69713. */
  69714. getControllerByName(name: string): Nullable<WebVRController>;
  69715. private _leftController;
  69716. /**
  69717. * The controller corrisponding to the users left hand.
  69718. */
  69719. readonly leftController: Nullable<WebVRController>;
  69720. private _rightController;
  69721. /**
  69722. * The controller corrisponding to the users right hand.
  69723. */
  69724. readonly rightController: Nullable<WebVRController>;
  69725. /**
  69726. * Casts a ray forward from the vrCamera's gaze.
  69727. * @param length Length of the ray (default: 100)
  69728. * @returns the ray corrisponding to the gaze
  69729. */
  69730. getForwardRay(length?: number): Ray;
  69731. /**
  69732. * @hidden
  69733. * Updates the camera based on device's frame data
  69734. */
  69735. _checkInputs(): void;
  69736. /**
  69737. * Updates the poseControlled values based on the input device pose.
  69738. * @param poseData Pose coming from the device
  69739. */
  69740. updateFromDevice(poseData: DevicePose): void;
  69741. private _htmlElementAttached;
  69742. private _detachIfAttached;
  69743. /**
  69744. * WebVR's attach control will start broadcasting frames to the device.
  69745. * Note that in certain browsers (chrome for example) this function must be called
  69746. * within a user-interaction callback. Example:
  69747. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  69748. *
  69749. * @param element html element to attach the vrDevice to
  69750. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  69751. */
  69752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69753. /**
  69754. * Detaches the camera from the html element and disables VR
  69755. *
  69756. * @param element html element to detach from
  69757. */
  69758. detachControl(element: HTMLElement): void;
  69759. /**
  69760. * @returns the name of this class
  69761. */
  69762. getClassName(): string;
  69763. /**
  69764. * Calls resetPose on the vrDisplay
  69765. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  69766. */
  69767. resetToCurrentRotation(): void;
  69768. /**
  69769. * @hidden
  69770. * Updates the rig cameras (left and right eye)
  69771. */
  69772. _updateRigCameras(): void;
  69773. private _workingVector;
  69774. private _oneVector;
  69775. private _workingMatrix;
  69776. private updateCacheCalled;
  69777. private _correctPositionIfNotTrackPosition;
  69778. /**
  69779. * @hidden
  69780. * Updates the cached values of the camera
  69781. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  69782. */
  69783. _updateCache(ignoreParentClass?: boolean): void;
  69784. /**
  69785. * @hidden
  69786. * Get current device position in babylon world
  69787. */
  69788. _computeDevicePosition(): void;
  69789. /**
  69790. * Updates the current device position and rotation in the babylon world
  69791. */
  69792. update(): void;
  69793. /**
  69794. * @hidden
  69795. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  69796. * @returns an identity matrix
  69797. */
  69798. _getViewMatrix(): Matrix;
  69799. private _tmpMatrix;
  69800. /**
  69801. * This function is called by the two RIG cameras.
  69802. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  69803. * @hidden
  69804. */
  69805. _getWebVRViewMatrix(): Matrix;
  69806. /** @hidden */
  69807. _getWebVRProjectionMatrix(): Matrix;
  69808. private _onGamepadConnectedObserver;
  69809. private _onGamepadDisconnectedObserver;
  69810. private _updateCacheWhenTrackingDisabledObserver;
  69811. /**
  69812. * Initializes the controllers and their meshes
  69813. */
  69814. initControllers(): void;
  69815. }
  69816. }
  69817. declare module BABYLON {
  69818. /**
  69819. * Size options for a post process
  69820. */
  69821. export type PostProcessOptions = {
  69822. width: number;
  69823. height: number;
  69824. };
  69825. /**
  69826. * PostProcess can be used to apply a shader to a texture after it has been rendered
  69827. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69828. */
  69829. export class PostProcess {
  69830. /** Name of the PostProcess. */
  69831. name: string;
  69832. /**
  69833. * Width of the texture to apply the post process on
  69834. */
  69835. width: number;
  69836. /**
  69837. * Height of the texture to apply the post process on
  69838. */
  69839. height: number;
  69840. /**
  69841. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  69842. * @hidden
  69843. */
  69844. _outputTexture: Nullable<InternalTexture>;
  69845. /**
  69846. * Sampling mode used by the shader
  69847. * See https://doc.babylonjs.com/classes/3.1/texture
  69848. */
  69849. renderTargetSamplingMode: number;
  69850. /**
  69851. * Clear color to use when screen clearing
  69852. */
  69853. clearColor: Color4;
  69854. /**
  69855. * If the buffer needs to be cleared before applying the post process. (default: true)
  69856. * Should be set to false if shader will overwrite all previous pixels.
  69857. */
  69858. autoClear: boolean;
  69859. /**
  69860. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  69861. */
  69862. alphaMode: number;
  69863. /**
  69864. * Sets the setAlphaBlendConstants of the babylon engine
  69865. */
  69866. alphaConstants: Color4;
  69867. /**
  69868. * Animations to be used for the post processing
  69869. */
  69870. animations: Animation[];
  69871. /**
  69872. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  69873. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  69874. */
  69875. enablePixelPerfectMode: boolean;
  69876. /**
  69877. * Force the postprocess to be applied without taking in account viewport
  69878. */
  69879. forceFullscreenViewport: boolean;
  69880. /**
  69881. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  69882. *
  69883. * | Value | Type | Description |
  69884. * | ----- | ----------------------------------- | ----------- |
  69885. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  69886. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  69887. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  69888. *
  69889. */
  69890. scaleMode: number;
  69891. /**
  69892. * Force textures to be a power of two (default: false)
  69893. */
  69894. alwaysForcePOT: boolean;
  69895. private _samples;
  69896. /**
  69897. * Number of sample textures (default: 1)
  69898. */
  69899. samples: number;
  69900. /**
  69901. * Modify the scale of the post process to be the same as the viewport (default: false)
  69902. */
  69903. adaptScaleToCurrentViewport: boolean;
  69904. private _camera;
  69905. private _scene;
  69906. private _engine;
  69907. private _options;
  69908. private _reusable;
  69909. private _textureType;
  69910. /**
  69911. * Smart array of input and output textures for the post process.
  69912. * @hidden
  69913. */
  69914. _textures: SmartArray<InternalTexture>;
  69915. /**
  69916. * The index in _textures that corresponds to the output texture.
  69917. * @hidden
  69918. */
  69919. _currentRenderTextureInd: number;
  69920. private _effect;
  69921. private _samplers;
  69922. private _fragmentUrl;
  69923. private _vertexUrl;
  69924. private _parameters;
  69925. private _scaleRatio;
  69926. protected _indexParameters: any;
  69927. private _shareOutputWithPostProcess;
  69928. private _texelSize;
  69929. private _forcedOutputTexture;
  69930. /**
  69931. * Returns the fragment url or shader name used in the post process.
  69932. * @returns the fragment url or name in the shader store.
  69933. */
  69934. getEffectName(): string;
  69935. /**
  69936. * An event triggered when the postprocess is activated.
  69937. */
  69938. onActivateObservable: Observable<Camera>;
  69939. private _onActivateObserver;
  69940. /**
  69941. * A function that is added to the onActivateObservable
  69942. */
  69943. onActivate: Nullable<(camera: Camera) => void>;
  69944. /**
  69945. * An event triggered when the postprocess changes its size.
  69946. */
  69947. onSizeChangedObservable: Observable<PostProcess>;
  69948. private _onSizeChangedObserver;
  69949. /**
  69950. * A function that is added to the onSizeChangedObservable
  69951. */
  69952. onSizeChanged: (postProcess: PostProcess) => void;
  69953. /**
  69954. * An event triggered when the postprocess applies its effect.
  69955. */
  69956. onApplyObservable: Observable<Effect>;
  69957. private _onApplyObserver;
  69958. /**
  69959. * A function that is added to the onApplyObservable
  69960. */
  69961. onApply: (effect: Effect) => void;
  69962. /**
  69963. * An event triggered before rendering the postprocess
  69964. */
  69965. onBeforeRenderObservable: Observable<Effect>;
  69966. private _onBeforeRenderObserver;
  69967. /**
  69968. * A function that is added to the onBeforeRenderObservable
  69969. */
  69970. onBeforeRender: (effect: Effect) => void;
  69971. /**
  69972. * An event triggered after rendering the postprocess
  69973. */
  69974. onAfterRenderObservable: Observable<Effect>;
  69975. private _onAfterRenderObserver;
  69976. /**
  69977. * A function that is added to the onAfterRenderObservable
  69978. */
  69979. onAfterRender: (efect: Effect) => void;
  69980. /**
  69981. * 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
  69982. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  69983. */
  69984. inputTexture: InternalTexture;
  69985. /**
  69986. * Gets the camera which post process is applied to.
  69987. * @returns The camera the post process is applied to.
  69988. */
  69989. getCamera(): Camera;
  69990. /**
  69991. * Gets the texel size of the postprocess.
  69992. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  69993. */
  69994. readonly texelSize: Vector2;
  69995. /**
  69996. * Creates a new instance PostProcess
  69997. * @param name The name of the PostProcess.
  69998. * @param fragmentUrl The url of the fragment shader to be used.
  69999. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70000. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70001. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70002. * @param camera The camera to apply the render pass to.
  70003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70004. * @param engine The engine which the post process will be applied. (default: current engine)
  70005. * @param reusable If the post process can be reused on the same frame. (default: false)
  70006. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70007. * @param textureType Type of textures used when performing the post process. (default: 0)
  70008. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70009. * @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
  70010. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70011. */
  70012. constructor(
  70013. /** Name of the PostProcess. */
  70014. 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);
  70015. /**
  70016. * Gets the engine which this post process belongs to.
  70017. * @returns The engine the post process was enabled with.
  70018. */
  70019. getEngine(): Engine;
  70020. /**
  70021. * The effect that is created when initializing the post process.
  70022. * @returns The created effect corrisponding the the postprocess.
  70023. */
  70024. getEffect(): Effect;
  70025. /**
  70026. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70027. * @param postProcess The post process to share the output with.
  70028. * @returns This post process.
  70029. */
  70030. shareOutputWith(postProcess: PostProcess): PostProcess;
  70031. /**
  70032. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70033. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70034. */
  70035. useOwnOutput(): void;
  70036. /**
  70037. * Updates the effect with the current post process compile time values and recompiles the shader.
  70038. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70039. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70040. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70041. * @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
  70042. * @param onCompiled Called when the shader has been compiled.
  70043. * @param onError Called if there is an error when compiling a shader.
  70044. */
  70045. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70046. /**
  70047. * The post process is reusable if it can be used multiple times within one frame.
  70048. * @returns If the post process is reusable
  70049. */
  70050. isReusable(): boolean;
  70051. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70052. markTextureDirty(): void;
  70053. /**
  70054. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70055. * 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.
  70056. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70057. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70058. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70059. * @returns The target texture that was bound to be written to.
  70060. */
  70061. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70062. /**
  70063. * If the post process is supported.
  70064. */
  70065. readonly isSupported: boolean;
  70066. /**
  70067. * The aspect ratio of the output texture.
  70068. */
  70069. readonly aspectRatio: number;
  70070. /**
  70071. * Get a value indicating if the post-process is ready to be used
  70072. * @returns true if the post-process is ready (shader is compiled)
  70073. */
  70074. isReady(): boolean;
  70075. /**
  70076. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70077. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70078. */
  70079. apply(): Nullable<Effect>;
  70080. private _disposeTextures;
  70081. /**
  70082. * Disposes the post process.
  70083. * @param camera The camera to dispose the post process on.
  70084. */
  70085. dispose(camera?: Camera): void;
  70086. }
  70087. }
  70088. declare module BABYLON {
  70089. /**
  70090. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70091. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70092. */
  70093. export class PostProcessManager {
  70094. private _scene;
  70095. private _indexBuffer;
  70096. private _vertexBuffers;
  70097. /**
  70098. * Creates a new instance PostProcess
  70099. * @param scene The scene that the post process is associated with.
  70100. */
  70101. constructor(scene: Scene);
  70102. private _prepareBuffers;
  70103. private _buildIndexBuffer;
  70104. /**
  70105. * Rebuilds the vertex buffers of the manager.
  70106. * @hidden
  70107. */
  70108. _rebuild(): void;
  70109. /**
  70110. * Prepares a frame to be run through a post process.
  70111. * @param sourceTexture The input texture to the post procesess. (default: null)
  70112. * @param postProcesses An array of post processes to be run. (default: null)
  70113. * @returns True if the post processes were able to be run.
  70114. * @hidden
  70115. */
  70116. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70117. /**
  70118. * Manually render a set of post processes to a texture.
  70119. * @param postProcesses An array of post processes to be run.
  70120. * @param targetTexture The target texture to render to.
  70121. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70122. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70123. * @param lodLevel defines which lod of the texture to render to
  70124. */
  70125. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70126. /**
  70127. * Finalize the result of the output of the postprocesses.
  70128. * @param doNotPresent If true the result will not be displayed to the screen.
  70129. * @param targetTexture The target texture to render to.
  70130. * @param faceIndex The index of the face to bind the target texture to.
  70131. * @param postProcesses The array of post processes to render.
  70132. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70133. * @hidden
  70134. */
  70135. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70136. /**
  70137. * Disposes of the post process manager.
  70138. */
  70139. dispose(): void;
  70140. }
  70141. }
  70142. declare module BABYLON {
  70143. /**
  70144. * Raw texture can help creating a texture directly from an array of data.
  70145. * This can be super useful if you either get the data from an uncompressed source or
  70146. * if you wish to create your texture pixel by pixel.
  70147. */
  70148. export class RawTexture extends Texture {
  70149. /**
  70150. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70151. */
  70152. format: number;
  70153. private _engine;
  70154. /**
  70155. * Instantiates a new RawTexture.
  70156. * Raw texture can help creating a texture directly from an array of data.
  70157. * This can be super useful if you either get the data from an uncompressed source or
  70158. * if you wish to create your texture pixel by pixel.
  70159. * @param data define the array of data to use to create the texture
  70160. * @param width define the width of the texture
  70161. * @param height define the height of the texture
  70162. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70163. * @param scene define the scene the texture belongs to
  70164. * @param generateMipMaps define whether mip maps should be generated or not
  70165. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70166. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70167. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70168. */
  70169. constructor(data: ArrayBufferView, width: number, height: number,
  70170. /**
  70171. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70172. */
  70173. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  70174. /**
  70175. * Updates the texture underlying data.
  70176. * @param data Define the new data of the texture
  70177. */
  70178. update(data: ArrayBufferView): void;
  70179. /**
  70180. * Creates a luminance texture from some data.
  70181. * @param data Define the texture data
  70182. * @param width Define the width of the texture
  70183. * @param height Define the height of the texture
  70184. * @param scene Define the scene the texture belongs to
  70185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70188. * @returns the luminance texture
  70189. */
  70190. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70191. /**
  70192. * Creates a luminance alpha texture from some data.
  70193. * @param data Define the texture data
  70194. * @param width Define the width of the texture
  70195. * @param height Define the height of the texture
  70196. * @param scene Define the scene the texture belongs to
  70197. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70198. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70199. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70200. * @returns the luminance alpha texture
  70201. */
  70202. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70203. /**
  70204. * Creates an alpha texture from some data.
  70205. * @param data Define the texture data
  70206. * @param width Define the width of the texture
  70207. * @param height Define the height of the texture
  70208. * @param scene Define the scene the texture belongs to
  70209. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70210. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70211. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70212. * @returns the alpha texture
  70213. */
  70214. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70215. /**
  70216. * Creates a RGB texture from some data.
  70217. * @param data Define the texture data
  70218. * @param width Define the width of the texture
  70219. * @param height Define the height of the texture
  70220. * @param scene Define the scene the texture belongs to
  70221. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70222. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70223. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70224. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70225. * @returns the RGB alpha texture
  70226. */
  70227. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70228. /**
  70229. * Creates a RGBA texture from some data.
  70230. * @param data Define the texture data
  70231. * @param width Define the width of the texture
  70232. * @param height Define the height of the texture
  70233. * @param scene Define the scene the texture belongs to
  70234. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70235. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70236. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70237. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70238. * @returns the RGBA texture
  70239. */
  70240. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70241. /**
  70242. * Creates a R texture from some data.
  70243. * @param data Define the texture data
  70244. * @param width Define the width of the texture
  70245. * @param height Define the height of the texture
  70246. * @param scene Define the scene the texture belongs to
  70247. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70250. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70251. * @returns the R texture
  70252. */
  70253. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70254. }
  70255. }
  70256. declare module BABYLON {
  70257. interface AbstractScene {
  70258. /**
  70259. * The list of layers (background and foreground) of the scene
  70260. */
  70261. layers: Array<Layer>;
  70262. }
  70263. /**
  70264. * Defines the layer scene component responsible to manage any layers
  70265. * in a given scene.
  70266. */
  70267. export class LayerSceneComponent implements ISceneComponent {
  70268. /**
  70269. * The component name helpfull to identify the component in the list of scene components.
  70270. */
  70271. readonly name: string;
  70272. /**
  70273. * The scene the component belongs to.
  70274. */
  70275. scene: Scene;
  70276. private _engine;
  70277. /**
  70278. * Creates a new instance of the component for the given scene
  70279. * @param scene Defines the scene to register the component in
  70280. */
  70281. constructor(scene: Scene);
  70282. /**
  70283. * Registers the component in a given scene
  70284. */
  70285. register(): void;
  70286. /**
  70287. * Rebuilds the elements related to this component in case of
  70288. * context lost for instance.
  70289. */
  70290. rebuild(): void;
  70291. /**
  70292. * Disposes the component and the associated ressources.
  70293. */
  70294. dispose(): void;
  70295. private _draw;
  70296. private _drawCameraPredicate;
  70297. private _drawCameraBackground;
  70298. private _drawCameraForeground;
  70299. private _drawRenderTargetPredicate;
  70300. private _drawRenderTargetBackground;
  70301. private _drawRenderTargetForeground;
  70302. }
  70303. }
  70304. declare module BABYLON {
  70305. /** @hidden */
  70306. export var layerPixelShader: {
  70307. name: string;
  70308. shader: string;
  70309. };
  70310. }
  70311. declare module BABYLON {
  70312. /** @hidden */
  70313. export var layerVertexShader: {
  70314. name: string;
  70315. shader: string;
  70316. };
  70317. }
  70318. declare module BABYLON {
  70319. /**
  70320. * This represents a full screen 2d layer.
  70321. * This can be useful to display a picture in the background of your scene for instance.
  70322. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70323. */
  70324. export class Layer {
  70325. /**
  70326. * Define the name of the layer.
  70327. */
  70328. name: string;
  70329. /**
  70330. * Define the texture the layer should display.
  70331. */
  70332. texture: Nullable<Texture>;
  70333. /**
  70334. * Is the layer in background or foreground.
  70335. */
  70336. isBackground: boolean;
  70337. /**
  70338. * Define the color of the layer (instead of texture).
  70339. */
  70340. color: Color4;
  70341. /**
  70342. * Define the scale of the layer in order to zoom in out of the texture.
  70343. */
  70344. scale: Vector2;
  70345. /**
  70346. * Define an offset for the layer in order to shift the texture.
  70347. */
  70348. offset: Vector2;
  70349. /**
  70350. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70351. */
  70352. alphaBlendingMode: number;
  70353. /**
  70354. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70355. * Alpha test will not mix with the background color in case of transparency.
  70356. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70357. */
  70358. alphaTest: boolean;
  70359. /**
  70360. * Define a mask to restrict the layer to only some of the scene cameras.
  70361. */
  70362. layerMask: number;
  70363. /**
  70364. * Define the list of render target the layer is visible into.
  70365. */
  70366. renderTargetTextures: RenderTargetTexture[];
  70367. /**
  70368. * Define if the layer is only used in renderTarget or if it also
  70369. * renders in the main frame buffer of the canvas.
  70370. */
  70371. renderOnlyInRenderTargetTextures: boolean;
  70372. private _scene;
  70373. private _vertexBuffers;
  70374. private _indexBuffer;
  70375. private _effect;
  70376. private _alphaTestEffect;
  70377. /**
  70378. * An event triggered when the layer is disposed.
  70379. */
  70380. onDisposeObservable: Observable<Layer>;
  70381. private _onDisposeObserver;
  70382. /**
  70383. * Back compatibility with callback before the onDisposeObservable existed.
  70384. * The set callback will be triggered when the layer has been disposed.
  70385. */
  70386. onDispose: () => void;
  70387. /**
  70388. * An event triggered before rendering the scene
  70389. */
  70390. onBeforeRenderObservable: Observable<Layer>;
  70391. private _onBeforeRenderObserver;
  70392. /**
  70393. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70394. * The set callback will be triggered just before rendering the layer.
  70395. */
  70396. onBeforeRender: () => void;
  70397. /**
  70398. * An event triggered after rendering the scene
  70399. */
  70400. onAfterRenderObservable: Observable<Layer>;
  70401. private _onAfterRenderObserver;
  70402. /**
  70403. * Back compatibility with callback before the onAfterRenderObservable existed.
  70404. * The set callback will be triggered just after rendering the layer.
  70405. */
  70406. onAfterRender: () => void;
  70407. /**
  70408. * Instantiates a new layer.
  70409. * This represents a full screen 2d layer.
  70410. * This can be useful to display a picture in the background of your scene for instance.
  70411. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70412. * @param name Define the name of the layer in the scene
  70413. * @param imgUrl Define the url of the texture to display in the layer
  70414. * @param scene Define the scene the layer belongs to
  70415. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70416. * @param color Defines a color for the layer
  70417. */
  70418. constructor(
  70419. /**
  70420. * Define the name of the layer.
  70421. */
  70422. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70423. private _createIndexBuffer;
  70424. /** @hidden */
  70425. _rebuild(): void;
  70426. /**
  70427. * Renders the layer in the scene.
  70428. */
  70429. render(): void;
  70430. /**
  70431. * Disposes and releases the associated ressources.
  70432. */
  70433. dispose(): void;
  70434. }
  70435. }
  70436. declare module BABYLON {
  70437. interface AbstractScene {
  70438. /**
  70439. * The list of procedural textures added to the scene
  70440. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70441. */
  70442. proceduralTextures: Array<ProceduralTexture>;
  70443. }
  70444. /**
  70445. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70446. * in a given scene.
  70447. */
  70448. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70449. /**
  70450. * The component name helpfull to identify the component in the list of scene components.
  70451. */
  70452. readonly name: string;
  70453. /**
  70454. * The scene the component belongs to.
  70455. */
  70456. scene: Scene;
  70457. /**
  70458. * Creates a new instance of the component for the given scene
  70459. * @param scene Defines the scene to register the component in
  70460. */
  70461. constructor(scene: Scene);
  70462. /**
  70463. * Registers the component in a given scene
  70464. */
  70465. register(): void;
  70466. /**
  70467. * Rebuilds the elements related to this component in case of
  70468. * context lost for instance.
  70469. */
  70470. rebuild(): void;
  70471. /**
  70472. * Disposes the component and the associated ressources.
  70473. */
  70474. dispose(): void;
  70475. private _beforeClear;
  70476. }
  70477. }
  70478. declare module BABYLON {
  70479. /** @hidden */
  70480. export var proceduralVertexShader: {
  70481. name: string;
  70482. shader: string;
  70483. };
  70484. }
  70485. declare module BABYLON {
  70486. /**
  70487. * 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.
  70488. * This is the base class of any Procedural texture and contains most of the shareable code.
  70489. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70490. */
  70491. export class ProceduralTexture extends Texture {
  70492. isCube: boolean;
  70493. /**
  70494. * Define if the texture is enabled or not (disabled texture will not render)
  70495. */
  70496. isEnabled: boolean;
  70497. /**
  70498. * Define if the texture must be cleared before rendering (default is true)
  70499. */
  70500. autoClear: boolean;
  70501. /**
  70502. * Callback called when the texture is generated
  70503. */
  70504. onGenerated: () => void;
  70505. /**
  70506. * Event raised when the texture is generated
  70507. */
  70508. onGeneratedObservable: Observable<ProceduralTexture>;
  70509. /** @hidden */
  70510. _generateMipMaps: boolean;
  70511. /** @hidden **/
  70512. _effect: Effect;
  70513. /** @hidden */
  70514. _textures: {
  70515. [key: string]: Texture;
  70516. };
  70517. private _size;
  70518. private _currentRefreshId;
  70519. private _refreshRate;
  70520. private _vertexBuffers;
  70521. private _indexBuffer;
  70522. private _uniforms;
  70523. private _samplers;
  70524. private _fragment;
  70525. private _floats;
  70526. private _ints;
  70527. private _floatsArrays;
  70528. private _colors3;
  70529. private _colors4;
  70530. private _vectors2;
  70531. private _vectors3;
  70532. private _matrices;
  70533. private _fallbackTexture;
  70534. private _fallbackTextureUsed;
  70535. private _engine;
  70536. private _cachedDefines;
  70537. private _contentUpdateId;
  70538. private _contentData;
  70539. /**
  70540. * Instantiates a new procedural texture.
  70541. * 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.
  70542. * This is the base class of any Procedural texture and contains most of the shareable code.
  70543. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70544. * @param name Define the name of the texture
  70545. * @param size Define the size of the texture to create
  70546. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70547. * @param scene Define the scene the texture belongs to
  70548. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70549. * @param generateMipMaps Define if the texture should creates mip maps or not
  70550. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70551. */
  70552. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70553. /**
  70554. * The effect that is created when initializing the post process.
  70555. * @returns The created effect corrisponding the the postprocess.
  70556. */
  70557. getEffect(): Effect;
  70558. /**
  70559. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70560. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70561. */
  70562. getContent(): Nullable<ArrayBufferView>;
  70563. private _createIndexBuffer;
  70564. /** @hidden */
  70565. _rebuild(): void;
  70566. /**
  70567. * Resets the texture in order to recreate its associated resources.
  70568. * This can be called in case of context loss
  70569. */
  70570. reset(): void;
  70571. protected _getDefines(): string;
  70572. /**
  70573. * Is the texture ready to be used ? (rendered at least once)
  70574. * @returns true if ready, otherwise, false.
  70575. */
  70576. isReady(): boolean;
  70577. /**
  70578. * Resets the refresh counter of the texture and start bak from scratch.
  70579. * Could be useful to regenerate the texture if it is setup to render only once.
  70580. */
  70581. resetRefreshCounter(): void;
  70582. /**
  70583. * Set the fragment shader to use in order to render the texture.
  70584. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  70585. */
  70586. setFragment(fragment: any): void;
  70587. /**
  70588. * Define the refresh rate of the texture or the rendering frequency.
  70589. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70590. */
  70591. refreshRate: number;
  70592. /** @hidden */
  70593. _shouldRender(): boolean;
  70594. /**
  70595. * Get the size the texture is rendering at.
  70596. * @returns the size (texture is always squared)
  70597. */
  70598. getRenderSize(): number;
  70599. /**
  70600. * Resize the texture to new value.
  70601. * @param size Define the new size the texture should have
  70602. * @param generateMipMaps Define whether the new texture should create mip maps
  70603. */
  70604. resize(size: number, generateMipMaps: boolean): void;
  70605. private _checkUniform;
  70606. /**
  70607. * Set a texture in the shader program used to render.
  70608. * @param name Define the name of the uniform samplers as defined in the shader
  70609. * @param texture Define the texture to bind to this sampler
  70610. * @return the texture itself allowing "fluent" like uniform updates
  70611. */
  70612. setTexture(name: string, texture: Texture): ProceduralTexture;
  70613. /**
  70614. * Set a float in the shader.
  70615. * @param name Define the name of the uniform as defined in the shader
  70616. * @param value Define the value to give to the uniform
  70617. * @return the texture itself allowing "fluent" like uniform updates
  70618. */
  70619. setFloat(name: string, value: number): ProceduralTexture;
  70620. /**
  70621. * Set a int in the shader.
  70622. * @param name Define the name of the uniform as defined in the shader
  70623. * @param value Define the value to give to the uniform
  70624. * @return the texture itself allowing "fluent" like uniform updates
  70625. */
  70626. setInt(name: string, value: number): ProceduralTexture;
  70627. /**
  70628. * Set an array of floats in the shader.
  70629. * @param name Define the name of the uniform as defined in the shader
  70630. * @param value Define the value to give to the uniform
  70631. * @return the texture itself allowing "fluent" like uniform updates
  70632. */
  70633. setFloats(name: string, value: number[]): ProceduralTexture;
  70634. /**
  70635. * Set a vec3 in the shader from a Color3.
  70636. * @param name Define the name of the uniform as defined in the shader
  70637. * @param value Define the value to give to the uniform
  70638. * @return the texture itself allowing "fluent" like uniform updates
  70639. */
  70640. setColor3(name: string, value: Color3): ProceduralTexture;
  70641. /**
  70642. * Set a vec4 in the shader from a Color4.
  70643. * @param name Define the name of the uniform as defined in the shader
  70644. * @param value Define the value to give to the uniform
  70645. * @return the texture itself allowing "fluent" like uniform updates
  70646. */
  70647. setColor4(name: string, value: Color4): ProceduralTexture;
  70648. /**
  70649. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  70655. /**
  70656. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  70662. /**
  70663. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  70669. /**
  70670. * Render the texture to its associated render target.
  70671. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70672. */
  70673. render(useCameraPostProcess?: boolean): void;
  70674. /**
  70675. * Clone the texture.
  70676. * @returns the cloned texture
  70677. */
  70678. clone(): ProceduralTexture;
  70679. /**
  70680. * Dispose the texture and release its asoociated resources.
  70681. */
  70682. dispose(): void;
  70683. }
  70684. }
  70685. declare module BABYLON {
  70686. /**
  70687. * This represents the base class for particle system in Babylon.
  70688. * 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.
  70689. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70690. * @example https://doc.babylonjs.com/babylon101/particles
  70691. */
  70692. export class BaseParticleSystem {
  70693. /**
  70694. * Source color is added to the destination color without alpha affecting the result
  70695. */
  70696. static BLENDMODE_ONEONE: number;
  70697. /**
  70698. * Blend current color and particle color using particle’s alpha
  70699. */
  70700. static BLENDMODE_STANDARD: number;
  70701. /**
  70702. * Add current color and particle color multiplied by particle’s alpha
  70703. */
  70704. static BLENDMODE_ADD: number;
  70705. /**
  70706. * Multiply current color with particle color
  70707. */
  70708. static BLENDMODE_MULTIPLY: number;
  70709. /**
  70710. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  70711. */
  70712. static BLENDMODE_MULTIPLYADD: number;
  70713. /**
  70714. * List of animations used by the particle system.
  70715. */
  70716. animations: Animation[];
  70717. /**
  70718. * The id of the Particle system.
  70719. */
  70720. id: string;
  70721. /**
  70722. * The friendly name of the Particle system.
  70723. */
  70724. name: string;
  70725. /**
  70726. * The rendering group used by the Particle system to chose when to render.
  70727. */
  70728. renderingGroupId: number;
  70729. /**
  70730. * The emitter represents the Mesh or position we are attaching the particle system to.
  70731. */
  70732. emitter: Nullable<AbstractMesh | Vector3>;
  70733. /**
  70734. * The maximum number of particles to emit per frame
  70735. */
  70736. emitRate: number;
  70737. /**
  70738. * If you want to launch only a few particles at once, that can be done, as well.
  70739. */
  70740. manualEmitCount: number;
  70741. /**
  70742. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  70743. */
  70744. updateSpeed: number;
  70745. /**
  70746. * The amount of time the particle system is running (depends of the overall update speed).
  70747. */
  70748. targetStopDuration: number;
  70749. /**
  70750. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  70751. */
  70752. disposeOnStop: boolean;
  70753. /**
  70754. * Minimum power of emitting particles.
  70755. */
  70756. minEmitPower: number;
  70757. /**
  70758. * Maximum power of emitting particles.
  70759. */
  70760. maxEmitPower: number;
  70761. /**
  70762. * Minimum life time of emitting particles.
  70763. */
  70764. minLifeTime: number;
  70765. /**
  70766. * Maximum life time of emitting particles.
  70767. */
  70768. maxLifeTime: number;
  70769. /**
  70770. * Minimum Size of emitting particles.
  70771. */
  70772. minSize: number;
  70773. /**
  70774. * Maximum Size of emitting particles.
  70775. */
  70776. maxSize: number;
  70777. /**
  70778. * Minimum scale of emitting particles on X axis.
  70779. */
  70780. minScaleX: number;
  70781. /**
  70782. * Maximum scale of emitting particles on X axis.
  70783. */
  70784. maxScaleX: number;
  70785. /**
  70786. * Minimum scale of emitting particles on Y axis.
  70787. */
  70788. minScaleY: number;
  70789. /**
  70790. * Maximum scale of emitting particles on Y axis.
  70791. */
  70792. maxScaleY: number;
  70793. /**
  70794. * Gets or sets the minimal initial rotation in radians.
  70795. */
  70796. minInitialRotation: number;
  70797. /**
  70798. * Gets or sets the maximal initial rotation in radians.
  70799. */
  70800. maxInitialRotation: number;
  70801. /**
  70802. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70803. */
  70804. minAngularSpeed: number;
  70805. /**
  70806. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70807. */
  70808. maxAngularSpeed: number;
  70809. /**
  70810. * The texture used to render each particle. (this can be a spritesheet)
  70811. */
  70812. particleTexture: Nullable<Texture>;
  70813. /**
  70814. * The layer mask we are rendering the particles through.
  70815. */
  70816. layerMask: number;
  70817. /**
  70818. * This can help using your own shader to render the particle system.
  70819. * The according effect will be created
  70820. */
  70821. customShader: any;
  70822. /**
  70823. * By default particle system starts as soon as they are created. This prevents the
  70824. * automatic start to happen and let you decide when to start emitting particles.
  70825. */
  70826. preventAutoStart: boolean;
  70827. private _noiseTexture;
  70828. /**
  70829. * Gets or sets a texture used to add random noise to particle positions
  70830. */
  70831. noiseTexture: Nullable<ProceduralTexture>;
  70832. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70833. noiseStrength: Vector3;
  70834. /**
  70835. * Callback triggered when the particle animation is ending.
  70836. */
  70837. onAnimationEnd: Nullable<() => void>;
  70838. /**
  70839. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70840. */
  70841. blendMode: number;
  70842. /**
  70843. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70844. * to override the particles.
  70845. */
  70846. forceDepthWrite: boolean;
  70847. /** 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 */
  70848. preWarmCycles: number;
  70849. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70850. preWarmStepOffset: number;
  70851. /**
  70852. * 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)
  70853. */
  70854. spriteCellChangeSpeed: number;
  70855. /**
  70856. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70857. */
  70858. startSpriteCellID: number;
  70859. /**
  70860. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70861. */
  70862. endSpriteCellID: number;
  70863. /**
  70864. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70865. */
  70866. spriteCellWidth: number;
  70867. /**
  70868. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70869. */
  70870. spriteCellHeight: number;
  70871. /**
  70872. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70873. */
  70874. spriteRandomStartCell: boolean;
  70875. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70876. translationPivot: Vector2;
  70877. /** @hidden */
  70878. protected _isAnimationSheetEnabled: boolean;
  70879. /**
  70880. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70881. */
  70882. beginAnimationOnStart: boolean;
  70883. /**
  70884. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70885. */
  70886. beginAnimationFrom: number;
  70887. /**
  70888. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70889. */
  70890. beginAnimationTo: number;
  70891. /**
  70892. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70893. */
  70894. beginAnimationLoop: boolean;
  70895. /**
  70896. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70897. */
  70898. isAnimationSheetEnabled: boolean;
  70899. /**
  70900. * Get hosting scene
  70901. * @returns the scene
  70902. */
  70903. getScene(): Scene;
  70904. /**
  70905. * You can use gravity if you want to give an orientation to your particles.
  70906. */
  70907. gravity: Vector3;
  70908. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70909. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70910. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70911. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70912. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70913. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70914. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70915. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70916. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70917. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70918. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70919. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70920. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70921. /**
  70922. * Defines the delay in milliseconds before starting the system (0 by default)
  70923. */
  70924. startDelay: number;
  70925. /**
  70926. * Gets the current list of drag gradients.
  70927. * You must use addDragGradient and removeDragGradient to udpate this list
  70928. * @returns the list of drag gradients
  70929. */
  70930. getDragGradients(): Nullable<Array<FactorGradient>>;
  70931. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70932. limitVelocityDamping: number;
  70933. /**
  70934. * Gets the current list of limit velocity gradients.
  70935. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70936. * @returns the list of limit velocity gradients
  70937. */
  70938. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70939. /**
  70940. * Gets the current list of color gradients.
  70941. * You must use addColorGradient and removeColorGradient to udpate this list
  70942. * @returns the list of color gradients
  70943. */
  70944. getColorGradients(): Nullable<Array<ColorGradient>>;
  70945. /**
  70946. * Gets the current list of size gradients.
  70947. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70948. * @returns the list of size gradients
  70949. */
  70950. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70951. /**
  70952. * Gets the current list of color remap gradients.
  70953. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70954. * @returns the list of color remap gradients
  70955. */
  70956. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70957. /**
  70958. * Gets the current list of alpha remap gradients.
  70959. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70960. * @returns the list of alpha remap gradients
  70961. */
  70962. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70963. /**
  70964. * Gets the current list of life time gradients.
  70965. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  70966. * @returns the list of life time gradients
  70967. */
  70968. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  70969. /**
  70970. * Gets the current list of angular speed gradients.
  70971. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  70972. * @returns the list of angular speed gradients
  70973. */
  70974. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  70975. /**
  70976. * Gets the current list of velocity gradients.
  70977. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  70978. * @returns the list of velocity gradients
  70979. */
  70980. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  70981. /**
  70982. * Gets the current list of start size gradients.
  70983. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  70984. * @returns the list of start size gradients
  70985. */
  70986. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  70987. /**
  70988. * Gets the current list of emit rate gradients.
  70989. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  70990. * @returns the list of emit rate gradients
  70991. */
  70992. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  70993. /**
  70994. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70995. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70996. */
  70997. direction1: Vector3;
  70998. /**
  70999. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71000. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71001. */
  71002. direction2: Vector3;
  71003. /**
  71004. * 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.
  71005. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71006. */
  71007. minEmitBox: Vector3;
  71008. /**
  71009. * 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.
  71010. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71011. */
  71012. maxEmitBox: Vector3;
  71013. /**
  71014. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71015. */
  71016. color1: Color4;
  71017. /**
  71018. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71019. */
  71020. color2: Color4;
  71021. /**
  71022. * Color the particle will have at the end of its lifetime
  71023. */
  71024. colorDead: Color4;
  71025. /**
  71026. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71027. */
  71028. textureMask: Color4;
  71029. /**
  71030. * The particle emitter type defines the emitter used by the particle system.
  71031. * It can be for example box, sphere, or cone...
  71032. */
  71033. particleEmitterType: IParticleEmitterType;
  71034. /** @hidden */
  71035. _isSubEmitter: boolean;
  71036. /**
  71037. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71038. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71039. */
  71040. billboardMode: number;
  71041. protected _isBillboardBased: boolean;
  71042. /**
  71043. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71044. */
  71045. isBillboardBased: boolean;
  71046. /**
  71047. * The scene the particle system belongs to.
  71048. */
  71049. protected _scene: Scene;
  71050. /**
  71051. * Local cache of defines for image processing.
  71052. */
  71053. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71054. /**
  71055. * Default configuration related to image processing available in the standard Material.
  71056. */
  71057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71058. /**
  71059. * Gets the image processing configuration used either in this material.
  71060. */
  71061. /**
  71062. * Sets the Default image processing configuration used either in the this material.
  71063. *
  71064. * If sets to null, the scene one is in use.
  71065. */
  71066. imageProcessingConfiguration: ImageProcessingConfiguration;
  71067. /**
  71068. * Attaches a new image processing configuration to the Standard Material.
  71069. * @param configuration
  71070. */
  71071. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71072. /** @hidden */
  71073. protected _reset(): void;
  71074. /** @hidden */
  71075. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71076. /**
  71077. * Instantiates a particle system.
  71078. * 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.
  71079. * @param name The name of the particle system
  71080. */
  71081. constructor(name: string);
  71082. /**
  71083. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71084. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71085. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71086. * @returns the emitter
  71087. */
  71088. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71089. /**
  71090. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71091. * @param radius The radius of the hemisphere to emit from
  71092. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71093. * @returns the emitter
  71094. */
  71095. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71096. /**
  71097. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71098. * @param radius The radius of the sphere to emit from
  71099. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71100. * @returns the emitter
  71101. */
  71102. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71103. /**
  71104. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71105. * @param radius The radius of the sphere to emit from
  71106. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71107. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71108. * @returns the emitter
  71109. */
  71110. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71111. /**
  71112. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71113. * @param radius The radius of the emission cylinder
  71114. * @param height The height of the emission cylinder
  71115. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71116. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71117. * @returns the emitter
  71118. */
  71119. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71120. /**
  71121. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71122. * @param radius The radius of the cylinder to emit from
  71123. * @param height The height of the emission cylinder
  71124. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71125. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71126. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71127. * @returns the emitter
  71128. */
  71129. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71130. /**
  71131. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71132. * @param radius The radius of the cone to emit from
  71133. * @param angle The base angle of the cone
  71134. * @returns the emitter
  71135. */
  71136. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71137. /**
  71138. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71139. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71140. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71141. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71142. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71143. * @returns the emitter
  71144. */
  71145. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71146. }
  71147. }
  71148. declare module BABYLON {
  71149. /**
  71150. * Type of sub emitter
  71151. */
  71152. export enum SubEmitterType {
  71153. /**
  71154. * Attached to the particle over it's lifetime
  71155. */
  71156. ATTACHED = 0,
  71157. /**
  71158. * Created when the particle dies
  71159. */
  71160. END = 1
  71161. }
  71162. /**
  71163. * Sub emitter class used to emit particles from an existing particle
  71164. */
  71165. export class SubEmitter {
  71166. /**
  71167. * the particle system to be used by the sub emitter
  71168. */
  71169. particleSystem: ParticleSystem;
  71170. /**
  71171. * Type of the submitter (Default: END)
  71172. */
  71173. type: SubEmitterType;
  71174. /**
  71175. * 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)
  71176. * Note: This only is supported when using an emitter of type Mesh
  71177. */
  71178. inheritDirection: boolean;
  71179. /**
  71180. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71181. */
  71182. inheritedVelocityAmount: number;
  71183. /**
  71184. * Creates a sub emitter
  71185. * @param particleSystem the particle system to be used by the sub emitter
  71186. */
  71187. constructor(
  71188. /**
  71189. * the particle system to be used by the sub emitter
  71190. */
  71191. particleSystem: ParticleSystem);
  71192. /**
  71193. * Clones the sub emitter
  71194. * @returns the cloned sub emitter
  71195. */
  71196. clone(): SubEmitter;
  71197. /**
  71198. * Serialize current object to a JSON object
  71199. * @returns the serialized object
  71200. */
  71201. serialize(): any;
  71202. /** @hidden */
  71203. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71204. /**
  71205. * Creates a new SubEmitter from a serialized JSON version
  71206. * @param serializationObject defines the JSON object to read from
  71207. * @param scene defines the hosting scene
  71208. * @param rootUrl defines the rootUrl for data loading
  71209. * @returns a new SubEmitter
  71210. */
  71211. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71212. /** Release associated resources */
  71213. dispose(): void;
  71214. }
  71215. }
  71216. declare module BABYLON {
  71217. /** @hidden */
  71218. export var clipPlaneFragmentDeclaration: {
  71219. name: string;
  71220. shader: string;
  71221. };
  71222. }
  71223. declare module BABYLON {
  71224. /** @hidden */
  71225. export var imageProcessingDeclaration: {
  71226. name: string;
  71227. shader: string;
  71228. };
  71229. }
  71230. declare module BABYLON {
  71231. /** @hidden */
  71232. export var imageProcessingFunctions: {
  71233. name: string;
  71234. shader: string;
  71235. };
  71236. }
  71237. declare module BABYLON {
  71238. /** @hidden */
  71239. export var clipPlaneFragment: {
  71240. name: string;
  71241. shader: string;
  71242. };
  71243. }
  71244. declare module BABYLON {
  71245. /** @hidden */
  71246. export var particlesPixelShader: {
  71247. name: string;
  71248. shader: string;
  71249. };
  71250. }
  71251. declare module BABYLON {
  71252. /** @hidden */
  71253. export var clipPlaneVertexDeclaration: {
  71254. name: string;
  71255. shader: string;
  71256. };
  71257. }
  71258. declare module BABYLON {
  71259. /** @hidden */
  71260. export var clipPlaneVertex: {
  71261. name: string;
  71262. shader: string;
  71263. };
  71264. }
  71265. declare module BABYLON {
  71266. /** @hidden */
  71267. export var particlesVertexShader: {
  71268. name: string;
  71269. shader: string;
  71270. };
  71271. }
  71272. declare module BABYLON {
  71273. /**
  71274. * This represents a particle system in Babylon.
  71275. * 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.
  71276. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71277. * @example https://doc.babylonjs.com/babylon101/particles
  71278. */
  71279. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71280. /**
  71281. * Billboard mode will only apply to Y axis
  71282. */
  71283. static readonly BILLBOARDMODE_Y: number;
  71284. /**
  71285. * Billboard mode will apply to all axes
  71286. */
  71287. static readonly BILLBOARDMODE_ALL: number;
  71288. /**
  71289. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71290. */
  71291. static readonly BILLBOARDMODE_STRETCHED: number;
  71292. /**
  71293. * This function can be defined to provide custom update for active particles.
  71294. * This function will be called instead of regular update (age, position, color, etc.).
  71295. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71296. */
  71297. updateFunction: (particles: Particle[]) => void;
  71298. private _emitterWorldMatrix;
  71299. /**
  71300. * This function can be defined to specify initial direction for every new particle.
  71301. * It by default use the emitterType defined function
  71302. */
  71303. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71304. /**
  71305. * This function can be defined to specify initial position for every new particle.
  71306. * It by default use the emitterType defined function
  71307. */
  71308. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71309. /**
  71310. * @hidden
  71311. */
  71312. _inheritedVelocityOffset: Vector3;
  71313. /**
  71314. * An event triggered when the system is disposed
  71315. */
  71316. onDisposeObservable: Observable<ParticleSystem>;
  71317. private _onDisposeObserver;
  71318. /**
  71319. * Sets a callback that will be triggered when the system is disposed
  71320. */
  71321. onDispose: () => void;
  71322. private _particles;
  71323. private _epsilon;
  71324. private _capacity;
  71325. private _stockParticles;
  71326. private _newPartsExcess;
  71327. private _vertexData;
  71328. private _vertexBuffer;
  71329. private _vertexBuffers;
  71330. private _spriteBuffer;
  71331. private _indexBuffer;
  71332. private _effect;
  71333. private _customEffect;
  71334. private _cachedDefines;
  71335. private _scaledColorStep;
  71336. private _colorDiff;
  71337. private _scaledDirection;
  71338. private _scaledGravity;
  71339. private _currentRenderId;
  71340. private _alive;
  71341. private _useInstancing;
  71342. private _started;
  71343. private _stopped;
  71344. private _actualFrame;
  71345. private _scaledUpdateSpeed;
  71346. private _vertexBufferSize;
  71347. /** @hidden */
  71348. _currentEmitRateGradient: Nullable<FactorGradient>;
  71349. /** @hidden */
  71350. _currentEmitRate1: number;
  71351. /** @hidden */
  71352. _currentEmitRate2: number;
  71353. /** @hidden */
  71354. _currentStartSizeGradient: Nullable<FactorGradient>;
  71355. /** @hidden */
  71356. _currentStartSize1: number;
  71357. /** @hidden */
  71358. _currentStartSize2: number;
  71359. private readonly _rawTextureWidth;
  71360. private _rampGradientsTexture;
  71361. private _useRampGradients;
  71362. /** Gets or sets a boolean indicating that ramp gradients must be used
  71363. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71364. */
  71365. useRampGradients: boolean;
  71366. /**
  71367. * 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.
  71368. * 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: [])
  71369. */
  71370. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71371. private _subEmitters;
  71372. /**
  71373. * @hidden
  71374. * If the particle systems emitter should be disposed when the particle system is disposed
  71375. */
  71376. _disposeEmitterOnDispose: boolean;
  71377. /**
  71378. * The current active Sub-systems, this property is used by the root particle system only.
  71379. */
  71380. activeSubSystems: Array<ParticleSystem>;
  71381. private _rootParticleSystem;
  71382. /**
  71383. * Gets the current list of active particles
  71384. */
  71385. readonly particles: Particle[];
  71386. /**
  71387. * Returns the string "ParticleSystem"
  71388. * @returns a string containing the class name
  71389. */
  71390. getClassName(): string;
  71391. /**
  71392. * Instantiates a particle system.
  71393. * 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.
  71394. * @param name The name of the particle system
  71395. * @param capacity The max number of particles alive at the same time
  71396. * @param scene The scene the particle system belongs to
  71397. * @param customEffect a custom effect used to change the way particles are rendered by default
  71398. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71399. * @param epsilon Offset used to render the particles
  71400. */
  71401. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71402. private _addFactorGradient;
  71403. private _removeFactorGradient;
  71404. /**
  71405. * Adds a new life time gradient
  71406. * @param gradient defines the gradient to use (between 0 and 1)
  71407. * @param factor defines the life time factor to affect to the specified gradient
  71408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71409. * @returns the current particle system
  71410. */
  71411. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71412. /**
  71413. * Remove a specific life time gradient
  71414. * @param gradient defines the gradient to remove
  71415. * @returns the current particle system
  71416. */
  71417. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71418. /**
  71419. * Adds a new size gradient
  71420. * @param gradient defines the gradient to use (between 0 and 1)
  71421. * @param factor defines the size factor to affect to the specified gradient
  71422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71423. * @returns the current particle system
  71424. */
  71425. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71426. /**
  71427. * Remove a specific size gradient
  71428. * @param gradient defines the gradient to remove
  71429. * @returns the current particle system
  71430. */
  71431. removeSizeGradient(gradient: number): IParticleSystem;
  71432. /**
  71433. * Adds a new color remap gradient
  71434. * @param gradient defines the gradient to use (between 0 and 1)
  71435. * @param min defines the color remap minimal range
  71436. * @param max defines the color remap maximal range
  71437. * @returns the current particle system
  71438. */
  71439. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71440. /**
  71441. * Remove a specific color remap gradient
  71442. * @param gradient defines the gradient to remove
  71443. * @returns the current particle system
  71444. */
  71445. removeColorRemapGradient(gradient: number): IParticleSystem;
  71446. /**
  71447. * Adds a new alpha remap gradient
  71448. * @param gradient defines the gradient to use (between 0 and 1)
  71449. * @param min defines the alpha remap minimal range
  71450. * @param max defines the alpha remap maximal range
  71451. * @returns the current particle system
  71452. */
  71453. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71454. /**
  71455. * Remove a specific alpha remap gradient
  71456. * @param gradient defines the gradient to remove
  71457. * @returns the current particle system
  71458. */
  71459. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71460. /**
  71461. * Adds a new angular speed gradient
  71462. * @param gradient defines the gradient to use (between 0 and 1)
  71463. * @param factor defines the angular speed to affect to the specified gradient
  71464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71465. * @returns the current particle system
  71466. */
  71467. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71468. /**
  71469. * Remove a specific angular speed gradient
  71470. * @param gradient defines the gradient to remove
  71471. * @returns the current particle system
  71472. */
  71473. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71474. /**
  71475. * Adds a new velocity gradient
  71476. * @param gradient defines the gradient to use (between 0 and 1)
  71477. * @param factor defines the velocity to affect to the specified gradient
  71478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71479. * @returns the current particle system
  71480. */
  71481. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71482. /**
  71483. * Remove a specific velocity gradient
  71484. * @param gradient defines the gradient to remove
  71485. * @returns the current particle system
  71486. */
  71487. removeVelocityGradient(gradient: number): IParticleSystem;
  71488. /**
  71489. * Adds a new limit velocity gradient
  71490. * @param gradient defines the gradient to use (between 0 and 1)
  71491. * @param factor defines the limit velocity value to affect to the specified gradient
  71492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71493. * @returns the current particle system
  71494. */
  71495. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71496. /**
  71497. * Remove a specific limit velocity gradient
  71498. * @param gradient defines the gradient to remove
  71499. * @returns the current particle system
  71500. */
  71501. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71502. /**
  71503. * Adds a new drag gradient
  71504. * @param gradient defines the gradient to use (between 0 and 1)
  71505. * @param factor defines the drag value to affect to the specified gradient
  71506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71507. * @returns the current particle system
  71508. */
  71509. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71510. /**
  71511. * Remove a specific drag gradient
  71512. * @param gradient defines the gradient to remove
  71513. * @returns the current particle system
  71514. */
  71515. removeDragGradient(gradient: number): IParticleSystem;
  71516. /**
  71517. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71518. * @param gradient defines the gradient to use (between 0 and 1)
  71519. * @param factor defines the emit rate value to affect to the specified gradient
  71520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71521. * @returns the current particle system
  71522. */
  71523. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71524. /**
  71525. * Remove a specific emit rate gradient
  71526. * @param gradient defines the gradient to remove
  71527. * @returns the current particle system
  71528. */
  71529. removeEmitRateGradient(gradient: number): IParticleSystem;
  71530. /**
  71531. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71532. * @param gradient defines the gradient to use (between 0 and 1)
  71533. * @param factor defines the start size value to affect to the specified gradient
  71534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71535. * @returns the current particle system
  71536. */
  71537. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71538. /**
  71539. * Remove a specific start size gradient
  71540. * @param gradient defines the gradient to remove
  71541. * @returns the current particle system
  71542. */
  71543. removeStartSizeGradient(gradient: number): IParticleSystem;
  71544. private _createRampGradientTexture;
  71545. /**
  71546. * Gets the current list of ramp gradients.
  71547. * You must use addRampGradient and removeRampGradient to udpate this list
  71548. * @returns the list of ramp gradients
  71549. */
  71550. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71551. /**
  71552. * Adds a new ramp gradient used to remap particle colors
  71553. * @param gradient defines the gradient to use (between 0 and 1)
  71554. * @param color defines the color to affect to the specified gradient
  71555. * @returns the current particle system
  71556. */
  71557. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71558. /**
  71559. * Remove a specific ramp gradient
  71560. * @param gradient defines the gradient to remove
  71561. * @returns the current particle system
  71562. */
  71563. removeRampGradient(gradient: number): ParticleSystem;
  71564. /**
  71565. * Adds a new color gradient
  71566. * @param gradient defines the gradient to use (between 0 and 1)
  71567. * @param color1 defines the color to affect to the specified gradient
  71568. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71569. * @returns this particle system
  71570. */
  71571. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71572. /**
  71573. * Remove a specific color gradient
  71574. * @param gradient defines the gradient to remove
  71575. * @returns this particle system
  71576. */
  71577. removeColorGradient(gradient: number): IParticleSystem;
  71578. private _fetchR;
  71579. protected _reset(): void;
  71580. private _resetEffect;
  71581. private _createVertexBuffers;
  71582. private _createIndexBuffer;
  71583. /**
  71584. * Gets the maximum number of particles active at the same time.
  71585. * @returns The max number of active particles.
  71586. */
  71587. getCapacity(): number;
  71588. /**
  71589. * Gets whether there are still active particles in the system.
  71590. * @returns True if it is alive, otherwise false.
  71591. */
  71592. isAlive(): boolean;
  71593. /**
  71594. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71595. * @returns True if it has been started, otherwise false.
  71596. */
  71597. isStarted(): boolean;
  71598. private _prepareSubEmitterInternalArray;
  71599. /**
  71600. * Starts the particle system and begins to emit
  71601. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71602. */
  71603. start(delay?: number): void;
  71604. /**
  71605. * Stops the particle system.
  71606. * @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.
  71607. */
  71608. stop(stopSubEmitters?: boolean): void;
  71609. /**
  71610. * Remove all active particles
  71611. */
  71612. reset(): void;
  71613. /**
  71614. * @hidden (for internal use only)
  71615. */
  71616. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  71617. /**
  71618. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  71619. * Its lifetime will start back at 0.
  71620. */
  71621. recycleParticle: (particle: Particle) => void;
  71622. private _stopSubEmitters;
  71623. private _createParticle;
  71624. private _removeFromRoot;
  71625. private _emitFromParticle;
  71626. private _update;
  71627. /** @hidden */
  71628. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  71629. /** @hidden */
  71630. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  71631. /** @hidden */
  71632. private _getEffect;
  71633. /**
  71634. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71635. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  71636. */
  71637. animate(preWarmOnly?: boolean): void;
  71638. private _appendParticleVertices;
  71639. /**
  71640. * Rebuilds the particle system.
  71641. */
  71642. rebuild(): void;
  71643. /**
  71644. * Is this system ready to be used/rendered
  71645. * @return true if the system is ready
  71646. */
  71647. isReady(): boolean;
  71648. private _render;
  71649. /**
  71650. * Renders the particle system in its current state.
  71651. * @returns the current number of particles
  71652. */
  71653. render(): number;
  71654. /**
  71655. * Disposes the particle system and free the associated resources
  71656. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71657. */
  71658. dispose(disposeTexture?: boolean): void;
  71659. /**
  71660. * Clones the particle system.
  71661. * @param name The name of the cloned object
  71662. * @param newEmitter The new emitter to use
  71663. * @returns the cloned particle system
  71664. */
  71665. clone(name: string, newEmitter: any): ParticleSystem;
  71666. /**
  71667. * Serializes the particle system to a JSON object.
  71668. * @returns the JSON object
  71669. */
  71670. serialize(): any;
  71671. /** @hidden */
  71672. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  71673. /** @hidden */
  71674. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  71675. /**
  71676. * Parses a JSON object to create a particle system.
  71677. * @param parsedParticleSystem The JSON object to parse
  71678. * @param scene The scene to create the particle system in
  71679. * @param rootUrl The root url to use to load external dependencies like texture
  71680. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71681. * @returns the Parsed particle system
  71682. */
  71683. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  71684. }
  71685. }
  71686. declare module BABYLON {
  71687. /**
  71688. * A particle represents one of the element emitted by a particle system.
  71689. * This is mainly define by its coordinates, direction, velocity and age.
  71690. */
  71691. export class Particle {
  71692. /**
  71693. * The particle system the particle belongs to.
  71694. */
  71695. particleSystem: ParticleSystem;
  71696. private static _Count;
  71697. /**
  71698. * Unique ID of the particle
  71699. */
  71700. id: number;
  71701. /**
  71702. * The world position of the particle in the scene.
  71703. */
  71704. position: Vector3;
  71705. /**
  71706. * The world direction of the particle in the scene.
  71707. */
  71708. direction: Vector3;
  71709. /**
  71710. * The color of the particle.
  71711. */
  71712. color: Color4;
  71713. /**
  71714. * The color change of the particle per step.
  71715. */
  71716. colorStep: Color4;
  71717. /**
  71718. * Defines how long will the life of the particle be.
  71719. */
  71720. lifeTime: number;
  71721. /**
  71722. * The current age of the particle.
  71723. */
  71724. age: number;
  71725. /**
  71726. * The current size of the particle.
  71727. */
  71728. size: number;
  71729. /**
  71730. * The current scale of the particle.
  71731. */
  71732. scale: Vector2;
  71733. /**
  71734. * The current angle of the particle.
  71735. */
  71736. angle: number;
  71737. /**
  71738. * Defines how fast is the angle changing.
  71739. */
  71740. angularSpeed: number;
  71741. /**
  71742. * Defines the cell index used by the particle to be rendered from a sprite.
  71743. */
  71744. cellIndex: number;
  71745. /**
  71746. * The information required to support color remapping
  71747. */
  71748. remapData: Vector4;
  71749. /** @hidden */
  71750. _randomCellOffset?: number;
  71751. /** @hidden */
  71752. _initialDirection: Nullable<Vector3>;
  71753. /** @hidden */
  71754. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  71755. /** @hidden */
  71756. _initialStartSpriteCellID: number;
  71757. /** @hidden */
  71758. _initialEndSpriteCellID: number;
  71759. /** @hidden */
  71760. _currentColorGradient: Nullable<ColorGradient>;
  71761. /** @hidden */
  71762. _currentColor1: Color4;
  71763. /** @hidden */
  71764. _currentColor2: Color4;
  71765. /** @hidden */
  71766. _currentSizeGradient: Nullable<FactorGradient>;
  71767. /** @hidden */
  71768. _currentSize1: number;
  71769. /** @hidden */
  71770. _currentSize2: number;
  71771. /** @hidden */
  71772. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  71773. /** @hidden */
  71774. _currentAngularSpeed1: number;
  71775. /** @hidden */
  71776. _currentAngularSpeed2: number;
  71777. /** @hidden */
  71778. _currentVelocityGradient: Nullable<FactorGradient>;
  71779. /** @hidden */
  71780. _currentVelocity1: number;
  71781. /** @hidden */
  71782. _currentVelocity2: number;
  71783. /** @hidden */
  71784. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  71785. /** @hidden */
  71786. _currentLimitVelocity1: number;
  71787. /** @hidden */
  71788. _currentLimitVelocity2: number;
  71789. /** @hidden */
  71790. _currentDragGradient: Nullable<FactorGradient>;
  71791. /** @hidden */
  71792. _currentDrag1: number;
  71793. /** @hidden */
  71794. _currentDrag2: number;
  71795. /** @hidden */
  71796. _randomNoiseCoordinates1: Vector3;
  71797. /** @hidden */
  71798. _randomNoiseCoordinates2: Vector3;
  71799. /**
  71800. * Creates a new instance Particle
  71801. * @param particleSystem the particle system the particle belongs to
  71802. */
  71803. constructor(
  71804. /**
  71805. * The particle system the particle belongs to.
  71806. */
  71807. particleSystem: ParticleSystem);
  71808. private updateCellInfoFromSystem;
  71809. /**
  71810. * Defines how the sprite cell index is updated for the particle
  71811. */
  71812. updateCellIndex(): void;
  71813. /** @hidden */
  71814. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71815. /** @hidden */
  71816. _inheritParticleInfoToSubEmitters(): void;
  71817. /** @hidden */
  71818. _reset(): void;
  71819. /**
  71820. * Copy the properties of particle to another one.
  71821. * @param other the particle to copy the information to.
  71822. */
  71823. copyTo(other: Particle): void;
  71824. }
  71825. }
  71826. declare module BABYLON {
  71827. /**
  71828. * Particle emitter represents a volume emitting particles.
  71829. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71830. */
  71831. export interface IParticleEmitterType {
  71832. /**
  71833. * Called by the particle System when the direction is computed for the created particle.
  71834. * @param worldMatrix is the world matrix of the particle system
  71835. * @param directionToUpdate is the direction vector to update with the result
  71836. * @param particle is the particle we are computed the direction for
  71837. */
  71838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71839. /**
  71840. * Called by the particle System when the position is computed for the created particle.
  71841. * @param worldMatrix is the world matrix of the particle system
  71842. * @param positionToUpdate is the position vector to update with the result
  71843. * @param particle is the particle we are computed the position for
  71844. */
  71845. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71846. /**
  71847. * Clones the current emitter and returns a copy of it
  71848. * @returns the new emitter
  71849. */
  71850. clone(): IParticleEmitterType;
  71851. /**
  71852. * Called by the GPUParticleSystem to setup the update shader
  71853. * @param effect defines the update shader
  71854. */
  71855. applyToShader(effect: Effect): void;
  71856. /**
  71857. * Returns a string to use to update the GPU particles update shader
  71858. * @returns the effect defines string
  71859. */
  71860. getEffectDefines(): string;
  71861. /**
  71862. * Returns a string representing the class name
  71863. * @returns a string containing the class name
  71864. */
  71865. getClassName(): string;
  71866. /**
  71867. * Serializes the particle system to a JSON object.
  71868. * @returns the JSON object
  71869. */
  71870. serialize(): any;
  71871. /**
  71872. * Parse properties from a JSON object
  71873. * @param serializationObject defines the JSON object
  71874. */
  71875. parse(serializationObject: any): void;
  71876. }
  71877. }
  71878. declare module BABYLON {
  71879. /**
  71880. * Particle emitter emitting particles from the inside of a box.
  71881. * It emits the particles randomly between 2 given directions.
  71882. */
  71883. export class BoxParticleEmitter implements IParticleEmitterType {
  71884. /**
  71885. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71886. */
  71887. direction1: Vector3;
  71888. /**
  71889. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71890. */
  71891. direction2: Vector3;
  71892. /**
  71893. * 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.
  71894. */
  71895. minEmitBox: Vector3;
  71896. /**
  71897. * 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.
  71898. */
  71899. maxEmitBox: Vector3;
  71900. /**
  71901. * Creates a new instance BoxParticleEmitter
  71902. */
  71903. constructor();
  71904. /**
  71905. * Called by the particle System when the direction is computed for the created particle.
  71906. * @param worldMatrix is the world matrix of the particle system
  71907. * @param directionToUpdate is the direction vector to update with the result
  71908. * @param particle is the particle we are computed the direction for
  71909. */
  71910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71911. /**
  71912. * Called by the particle System when the position is computed for the created particle.
  71913. * @param worldMatrix is the world matrix of the particle system
  71914. * @param positionToUpdate is the position vector to update with the result
  71915. * @param particle is the particle we are computed the position for
  71916. */
  71917. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71918. /**
  71919. * Clones the current emitter and returns a copy of it
  71920. * @returns the new emitter
  71921. */
  71922. clone(): BoxParticleEmitter;
  71923. /**
  71924. * Called by the GPUParticleSystem to setup the update shader
  71925. * @param effect defines the update shader
  71926. */
  71927. applyToShader(effect: Effect): void;
  71928. /**
  71929. * Returns a string to use to update the GPU particles update shader
  71930. * @returns a string containng the defines string
  71931. */
  71932. getEffectDefines(): string;
  71933. /**
  71934. * Returns the string "BoxParticleEmitter"
  71935. * @returns a string containing the class name
  71936. */
  71937. getClassName(): string;
  71938. /**
  71939. * Serializes the particle system to a JSON object.
  71940. * @returns the JSON object
  71941. */
  71942. serialize(): any;
  71943. /**
  71944. * Parse properties from a JSON object
  71945. * @param serializationObject defines the JSON object
  71946. */
  71947. parse(serializationObject: any): void;
  71948. }
  71949. }
  71950. declare module BABYLON {
  71951. /**
  71952. * Particle emitter emitting particles from the inside of a cone.
  71953. * It emits the particles alongside the cone volume from the base to the particle.
  71954. * The emission direction might be randomized.
  71955. */
  71956. export class ConeParticleEmitter implements IParticleEmitterType {
  71957. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71958. directionRandomizer: number;
  71959. private _radius;
  71960. private _angle;
  71961. private _height;
  71962. /**
  71963. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71964. */
  71965. radiusRange: number;
  71966. /**
  71967. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  71968. */
  71969. heightRange: number;
  71970. /**
  71971. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  71972. */
  71973. emitFromSpawnPointOnly: boolean;
  71974. /**
  71975. * Gets or sets the radius of the emission cone
  71976. */
  71977. radius: number;
  71978. /**
  71979. * Gets or sets the angle of the emission cone
  71980. */
  71981. angle: number;
  71982. private _buildHeight;
  71983. /**
  71984. * Creates a new instance ConeParticleEmitter
  71985. * @param radius the radius of the emission cone (1 by default)
  71986. * @param angle the cone base angle (PI by default)
  71987. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  71988. */
  71989. constructor(radius?: number, angle?: number,
  71990. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71991. directionRandomizer?: number);
  71992. /**
  71993. * Called by the particle System when the direction is computed for the created particle.
  71994. * @param worldMatrix is the world matrix of the particle system
  71995. * @param directionToUpdate is the direction vector to update with the result
  71996. * @param particle is the particle we are computed the direction for
  71997. */
  71998. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71999. /**
  72000. * Called by the particle System when the position is computed for the created particle.
  72001. * @param worldMatrix is the world matrix of the particle system
  72002. * @param positionToUpdate is the position vector to update with the result
  72003. * @param particle is the particle we are computed the position for
  72004. */
  72005. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72006. /**
  72007. * Clones the current emitter and returns a copy of it
  72008. * @returns the new emitter
  72009. */
  72010. clone(): ConeParticleEmitter;
  72011. /**
  72012. * Called by the GPUParticleSystem to setup the update shader
  72013. * @param effect defines the update shader
  72014. */
  72015. applyToShader(effect: Effect): void;
  72016. /**
  72017. * Returns a string to use to update the GPU particles update shader
  72018. * @returns a string containng the defines string
  72019. */
  72020. getEffectDefines(): string;
  72021. /**
  72022. * Returns the string "ConeParticleEmitter"
  72023. * @returns a string containing the class name
  72024. */
  72025. getClassName(): string;
  72026. /**
  72027. * Serializes the particle system to a JSON object.
  72028. * @returns the JSON object
  72029. */
  72030. serialize(): any;
  72031. /**
  72032. * Parse properties from a JSON object
  72033. * @param serializationObject defines the JSON object
  72034. */
  72035. parse(serializationObject: any): void;
  72036. }
  72037. }
  72038. declare module BABYLON {
  72039. /**
  72040. * Particle emitter emitting particles from the inside of a cylinder.
  72041. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72042. */
  72043. export class CylinderParticleEmitter implements IParticleEmitterType {
  72044. /**
  72045. * The radius of the emission cylinder.
  72046. */
  72047. radius: number;
  72048. /**
  72049. * The height of the emission cylinder.
  72050. */
  72051. height: number;
  72052. /**
  72053. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72054. */
  72055. radiusRange: number;
  72056. /**
  72057. * How much to randomize the particle direction [0-1].
  72058. */
  72059. directionRandomizer: number;
  72060. /**
  72061. * Creates a new instance CylinderParticleEmitter
  72062. * @param radius the radius of the emission cylinder (1 by default)
  72063. * @param height the height of the emission cylinder (1 by default)
  72064. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72065. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72066. */
  72067. constructor(
  72068. /**
  72069. * The radius of the emission cylinder.
  72070. */
  72071. radius?: number,
  72072. /**
  72073. * The height of the emission cylinder.
  72074. */
  72075. height?: number,
  72076. /**
  72077. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72078. */
  72079. radiusRange?: number,
  72080. /**
  72081. * How much to randomize the particle direction [0-1].
  72082. */
  72083. directionRandomizer?: number);
  72084. /**
  72085. * Called by the particle System when the direction is computed for the created particle.
  72086. * @param worldMatrix is the world matrix of the particle system
  72087. * @param directionToUpdate is the direction vector to update with the result
  72088. * @param particle is the particle we are computed the direction for
  72089. */
  72090. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72091. /**
  72092. * Called by the particle System when the position is computed for the created particle.
  72093. * @param worldMatrix is the world matrix of the particle system
  72094. * @param positionToUpdate is the position vector to update with the result
  72095. * @param particle is the particle we are computed the position for
  72096. */
  72097. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72098. /**
  72099. * Clones the current emitter and returns a copy of it
  72100. * @returns the new emitter
  72101. */
  72102. clone(): CylinderParticleEmitter;
  72103. /**
  72104. * Called by the GPUParticleSystem to setup the update shader
  72105. * @param effect defines the update shader
  72106. */
  72107. applyToShader(effect: Effect): void;
  72108. /**
  72109. * Returns a string to use to update the GPU particles update shader
  72110. * @returns a string containng the defines string
  72111. */
  72112. getEffectDefines(): string;
  72113. /**
  72114. * Returns the string "CylinderParticleEmitter"
  72115. * @returns a string containing the class name
  72116. */
  72117. getClassName(): string;
  72118. /**
  72119. * Serializes the particle system to a JSON object.
  72120. * @returns the JSON object
  72121. */
  72122. serialize(): any;
  72123. /**
  72124. * Parse properties from a JSON object
  72125. * @param serializationObject defines the JSON object
  72126. */
  72127. parse(serializationObject: any): void;
  72128. }
  72129. /**
  72130. * Particle emitter emitting particles from the inside of a cylinder.
  72131. * It emits the particles randomly between two vectors.
  72132. */
  72133. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72134. /**
  72135. * The min limit of the emission direction.
  72136. */
  72137. direction1: Vector3;
  72138. /**
  72139. * The max limit of the emission direction.
  72140. */
  72141. direction2: Vector3;
  72142. /**
  72143. * Creates a new instance CylinderDirectedParticleEmitter
  72144. * @param radius the radius of the emission cylinder (1 by default)
  72145. * @param height the height of the emission cylinder (1 by default)
  72146. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72147. * @param direction1 the min limit of the emission direction (up vector by default)
  72148. * @param direction2 the max limit of the emission direction (up vector by default)
  72149. */
  72150. constructor(radius?: number, height?: number, radiusRange?: number,
  72151. /**
  72152. * The min limit of the emission direction.
  72153. */
  72154. direction1?: Vector3,
  72155. /**
  72156. * The max limit of the emission direction.
  72157. */
  72158. direction2?: Vector3);
  72159. /**
  72160. * Called by the particle System when the direction is computed for the created particle.
  72161. * @param worldMatrix is the world matrix of the particle system
  72162. * @param directionToUpdate is the direction vector to update with the result
  72163. * @param particle is the particle we are computed the direction for
  72164. */
  72165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72166. /**
  72167. * Clones the current emitter and returns a copy of it
  72168. * @returns the new emitter
  72169. */
  72170. clone(): CylinderDirectedParticleEmitter;
  72171. /**
  72172. * Called by the GPUParticleSystem to setup the update shader
  72173. * @param effect defines the update shader
  72174. */
  72175. applyToShader(effect: Effect): void;
  72176. /**
  72177. * Returns a string to use to update the GPU particles update shader
  72178. * @returns a string containng the defines string
  72179. */
  72180. getEffectDefines(): string;
  72181. /**
  72182. * Returns the string "CylinderDirectedParticleEmitter"
  72183. * @returns a string containing the class name
  72184. */
  72185. getClassName(): string;
  72186. /**
  72187. * Serializes the particle system to a JSON object.
  72188. * @returns the JSON object
  72189. */
  72190. serialize(): any;
  72191. /**
  72192. * Parse properties from a JSON object
  72193. * @param serializationObject defines the JSON object
  72194. */
  72195. parse(serializationObject: any): void;
  72196. }
  72197. }
  72198. declare module BABYLON {
  72199. /**
  72200. * Particle emitter emitting particles from the inside of a hemisphere.
  72201. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72202. */
  72203. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72204. /**
  72205. * The radius of the emission hemisphere.
  72206. */
  72207. radius: number;
  72208. /**
  72209. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72210. */
  72211. radiusRange: number;
  72212. /**
  72213. * How much to randomize the particle direction [0-1].
  72214. */
  72215. directionRandomizer: number;
  72216. /**
  72217. * Creates a new instance HemisphericParticleEmitter
  72218. * @param radius the radius of the emission hemisphere (1 by default)
  72219. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72220. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72221. */
  72222. constructor(
  72223. /**
  72224. * The radius of the emission hemisphere.
  72225. */
  72226. radius?: number,
  72227. /**
  72228. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72229. */
  72230. radiusRange?: number,
  72231. /**
  72232. * How much to randomize the particle direction [0-1].
  72233. */
  72234. directionRandomizer?: number);
  72235. /**
  72236. * Called by the particle System when the direction is computed for the created particle.
  72237. * @param worldMatrix is the world matrix of the particle system
  72238. * @param directionToUpdate is the direction vector to update with the result
  72239. * @param particle is the particle we are computed the direction for
  72240. */
  72241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72242. /**
  72243. * Called by the particle System when the position is computed for the created particle.
  72244. * @param worldMatrix is the world matrix of the particle system
  72245. * @param positionToUpdate is the position vector to update with the result
  72246. * @param particle is the particle we are computed the position for
  72247. */
  72248. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72249. /**
  72250. * Clones the current emitter and returns a copy of it
  72251. * @returns the new emitter
  72252. */
  72253. clone(): HemisphericParticleEmitter;
  72254. /**
  72255. * Called by the GPUParticleSystem to setup the update shader
  72256. * @param effect defines the update shader
  72257. */
  72258. applyToShader(effect: Effect): void;
  72259. /**
  72260. * Returns a string to use to update the GPU particles update shader
  72261. * @returns a string containng the defines string
  72262. */
  72263. getEffectDefines(): string;
  72264. /**
  72265. * Returns the string "HemisphericParticleEmitter"
  72266. * @returns a string containing the class name
  72267. */
  72268. getClassName(): string;
  72269. /**
  72270. * Serializes the particle system to a JSON object.
  72271. * @returns the JSON object
  72272. */
  72273. serialize(): any;
  72274. /**
  72275. * Parse properties from a JSON object
  72276. * @param serializationObject defines the JSON object
  72277. */
  72278. parse(serializationObject: any): void;
  72279. }
  72280. }
  72281. declare module BABYLON {
  72282. /**
  72283. * Particle emitter emitting particles from a point.
  72284. * It emits the particles randomly between 2 given directions.
  72285. */
  72286. export class PointParticleEmitter implements IParticleEmitterType {
  72287. /**
  72288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72289. */
  72290. direction1: Vector3;
  72291. /**
  72292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72293. */
  72294. direction2: Vector3;
  72295. /**
  72296. * Creates a new instance PointParticleEmitter
  72297. */
  72298. constructor();
  72299. /**
  72300. * Called by the particle System when the direction is computed for the created particle.
  72301. * @param worldMatrix is the world matrix of the particle system
  72302. * @param directionToUpdate is the direction vector to update with the result
  72303. * @param particle is the particle we are computed the direction for
  72304. */
  72305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72306. /**
  72307. * Called by the particle System when the position is computed for the created particle.
  72308. * @param worldMatrix is the world matrix of the particle system
  72309. * @param positionToUpdate is the position vector to update with the result
  72310. * @param particle is the particle we are computed the position for
  72311. */
  72312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72313. /**
  72314. * Clones the current emitter and returns a copy of it
  72315. * @returns the new emitter
  72316. */
  72317. clone(): PointParticleEmitter;
  72318. /**
  72319. * Called by the GPUParticleSystem to setup the update shader
  72320. * @param effect defines the update shader
  72321. */
  72322. applyToShader(effect: Effect): void;
  72323. /**
  72324. * Returns a string to use to update the GPU particles update shader
  72325. * @returns a string containng the defines string
  72326. */
  72327. getEffectDefines(): string;
  72328. /**
  72329. * Returns the string "PointParticleEmitter"
  72330. * @returns a string containing the class name
  72331. */
  72332. getClassName(): string;
  72333. /**
  72334. * Serializes the particle system to a JSON object.
  72335. * @returns the JSON object
  72336. */
  72337. serialize(): any;
  72338. /**
  72339. * Parse properties from a JSON object
  72340. * @param serializationObject defines the JSON object
  72341. */
  72342. parse(serializationObject: any): void;
  72343. }
  72344. }
  72345. declare module BABYLON {
  72346. /**
  72347. * Particle emitter emitting particles from the inside of a sphere.
  72348. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72349. */
  72350. export class SphereParticleEmitter implements IParticleEmitterType {
  72351. /**
  72352. * The radius of the emission sphere.
  72353. */
  72354. radius: number;
  72355. /**
  72356. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72357. */
  72358. radiusRange: number;
  72359. /**
  72360. * How much to randomize the particle direction [0-1].
  72361. */
  72362. directionRandomizer: number;
  72363. /**
  72364. * Creates a new instance SphereParticleEmitter
  72365. * @param radius the radius of the emission sphere (1 by default)
  72366. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72367. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72368. */
  72369. constructor(
  72370. /**
  72371. * The radius of the emission sphere.
  72372. */
  72373. radius?: number,
  72374. /**
  72375. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72376. */
  72377. radiusRange?: number,
  72378. /**
  72379. * How much to randomize the particle direction [0-1].
  72380. */
  72381. directionRandomizer?: number);
  72382. /**
  72383. * Called by the particle System when the direction is computed for the created particle.
  72384. * @param worldMatrix is the world matrix of the particle system
  72385. * @param directionToUpdate is the direction vector to update with the result
  72386. * @param particle is the particle we are computed the direction for
  72387. */
  72388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72389. /**
  72390. * Called by the particle System when the position is computed for the created particle.
  72391. * @param worldMatrix is the world matrix of the particle system
  72392. * @param positionToUpdate is the position vector to update with the result
  72393. * @param particle is the particle we are computed the position for
  72394. */
  72395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72396. /**
  72397. * Clones the current emitter and returns a copy of it
  72398. * @returns the new emitter
  72399. */
  72400. clone(): SphereParticleEmitter;
  72401. /**
  72402. * Called by the GPUParticleSystem to setup the update shader
  72403. * @param effect defines the update shader
  72404. */
  72405. applyToShader(effect: Effect): void;
  72406. /**
  72407. * Returns a string to use to update the GPU particles update shader
  72408. * @returns a string containng the defines string
  72409. */
  72410. getEffectDefines(): string;
  72411. /**
  72412. * Returns the string "SphereParticleEmitter"
  72413. * @returns a string containing the class name
  72414. */
  72415. getClassName(): string;
  72416. /**
  72417. * Serializes the particle system to a JSON object.
  72418. * @returns the JSON object
  72419. */
  72420. serialize(): any;
  72421. /**
  72422. * Parse properties from a JSON object
  72423. * @param serializationObject defines the JSON object
  72424. */
  72425. parse(serializationObject: any): void;
  72426. }
  72427. /**
  72428. * Particle emitter emitting particles from the inside of a sphere.
  72429. * It emits the particles randomly between two vectors.
  72430. */
  72431. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72432. /**
  72433. * The min limit of the emission direction.
  72434. */
  72435. direction1: Vector3;
  72436. /**
  72437. * The max limit of the emission direction.
  72438. */
  72439. direction2: Vector3;
  72440. /**
  72441. * Creates a new instance SphereDirectedParticleEmitter
  72442. * @param radius the radius of the emission sphere (1 by default)
  72443. * @param direction1 the min limit of the emission direction (up vector by default)
  72444. * @param direction2 the max limit of the emission direction (up vector by default)
  72445. */
  72446. constructor(radius?: number,
  72447. /**
  72448. * The min limit of the emission direction.
  72449. */
  72450. direction1?: Vector3,
  72451. /**
  72452. * The max limit of the emission direction.
  72453. */
  72454. direction2?: Vector3);
  72455. /**
  72456. * Called by the particle System when the direction is computed for the created particle.
  72457. * @param worldMatrix is the world matrix of the particle system
  72458. * @param directionToUpdate is the direction vector to update with the result
  72459. * @param particle is the particle we are computed the direction for
  72460. */
  72461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72462. /**
  72463. * Clones the current emitter and returns a copy of it
  72464. * @returns the new emitter
  72465. */
  72466. clone(): SphereDirectedParticleEmitter;
  72467. /**
  72468. * Called by the GPUParticleSystem to setup the update shader
  72469. * @param effect defines the update shader
  72470. */
  72471. applyToShader(effect: Effect): void;
  72472. /**
  72473. * Returns a string to use to update the GPU particles update shader
  72474. * @returns a string containng the defines string
  72475. */
  72476. getEffectDefines(): string;
  72477. /**
  72478. * Returns the string "SphereDirectedParticleEmitter"
  72479. * @returns a string containing the class name
  72480. */
  72481. getClassName(): string;
  72482. /**
  72483. * Serializes the particle system to a JSON object.
  72484. * @returns the JSON object
  72485. */
  72486. serialize(): any;
  72487. /**
  72488. * Parse properties from a JSON object
  72489. * @param serializationObject defines the JSON object
  72490. */
  72491. parse(serializationObject: any): void;
  72492. }
  72493. }
  72494. declare module BABYLON {
  72495. /**
  72496. * Interface representing a particle system in Babylon.js.
  72497. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72498. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72499. */
  72500. export interface IParticleSystem {
  72501. /**
  72502. * List of animations used by the particle system.
  72503. */
  72504. animations: Animation[];
  72505. /**
  72506. * The id of the Particle system.
  72507. */
  72508. id: string;
  72509. /**
  72510. * The name of the Particle system.
  72511. */
  72512. name: string;
  72513. /**
  72514. * The emitter represents the Mesh or position we are attaching the particle system to.
  72515. */
  72516. emitter: Nullable<AbstractMesh | Vector3>;
  72517. /**
  72518. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72519. */
  72520. isBillboardBased: boolean;
  72521. /**
  72522. * The rendering group used by the Particle system to chose when to render.
  72523. */
  72524. renderingGroupId: number;
  72525. /**
  72526. * The layer mask we are rendering the particles through.
  72527. */
  72528. layerMask: number;
  72529. /**
  72530. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72531. */
  72532. updateSpeed: number;
  72533. /**
  72534. * The amount of time the particle system is running (depends of the overall update speed).
  72535. */
  72536. targetStopDuration: number;
  72537. /**
  72538. * The texture used to render each particle. (this can be a spritesheet)
  72539. */
  72540. particleTexture: Nullable<Texture>;
  72541. /**
  72542. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72543. */
  72544. blendMode: number;
  72545. /**
  72546. * Minimum life time of emitting particles.
  72547. */
  72548. minLifeTime: number;
  72549. /**
  72550. * Maximum life time of emitting particles.
  72551. */
  72552. maxLifeTime: number;
  72553. /**
  72554. * Minimum Size of emitting particles.
  72555. */
  72556. minSize: number;
  72557. /**
  72558. * Maximum Size of emitting particles.
  72559. */
  72560. maxSize: number;
  72561. /**
  72562. * Minimum scale of emitting particles on X axis.
  72563. */
  72564. minScaleX: number;
  72565. /**
  72566. * Maximum scale of emitting particles on X axis.
  72567. */
  72568. maxScaleX: number;
  72569. /**
  72570. * Minimum scale of emitting particles on Y axis.
  72571. */
  72572. minScaleY: number;
  72573. /**
  72574. * Maximum scale of emitting particles on Y axis.
  72575. */
  72576. maxScaleY: number;
  72577. /**
  72578. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72579. */
  72580. color1: Color4;
  72581. /**
  72582. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72583. */
  72584. color2: Color4;
  72585. /**
  72586. * Color the particle will have at the end of its lifetime.
  72587. */
  72588. colorDead: Color4;
  72589. /**
  72590. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  72591. */
  72592. emitRate: number;
  72593. /**
  72594. * You can use gravity if you want to give an orientation to your particles.
  72595. */
  72596. gravity: Vector3;
  72597. /**
  72598. * Minimum power of emitting particles.
  72599. */
  72600. minEmitPower: number;
  72601. /**
  72602. * Maximum power of emitting particles.
  72603. */
  72604. maxEmitPower: number;
  72605. /**
  72606. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72607. */
  72608. minAngularSpeed: number;
  72609. /**
  72610. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72611. */
  72612. maxAngularSpeed: number;
  72613. /**
  72614. * Gets or sets the minimal initial rotation in radians.
  72615. */
  72616. minInitialRotation: number;
  72617. /**
  72618. * Gets or sets the maximal initial rotation in radians.
  72619. */
  72620. maxInitialRotation: number;
  72621. /**
  72622. * The particle emitter type defines the emitter used by the particle system.
  72623. * It can be for example box, sphere, or cone...
  72624. */
  72625. particleEmitterType: Nullable<IParticleEmitterType>;
  72626. /**
  72627. * Defines the delay in milliseconds before starting the system (0 by default)
  72628. */
  72629. startDelay: number;
  72630. /**
  72631. * 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
  72632. */
  72633. preWarmCycles: number;
  72634. /**
  72635. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  72636. */
  72637. preWarmStepOffset: number;
  72638. /**
  72639. * 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)
  72640. */
  72641. spriteCellChangeSpeed: number;
  72642. /**
  72643. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72644. */
  72645. startSpriteCellID: number;
  72646. /**
  72647. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72648. */
  72649. endSpriteCellID: number;
  72650. /**
  72651. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72652. */
  72653. spriteCellWidth: number;
  72654. /**
  72655. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72656. */
  72657. spriteCellHeight: number;
  72658. /**
  72659. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72660. */
  72661. spriteRandomStartCell: boolean;
  72662. /**
  72663. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  72664. */
  72665. isAnimationSheetEnabled: boolean;
  72666. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72667. translationPivot: Vector2;
  72668. /**
  72669. * Gets or sets a texture used to add random noise to particle positions
  72670. */
  72671. noiseTexture: Nullable<BaseTexture>;
  72672. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72673. noiseStrength: Vector3;
  72674. /**
  72675. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72676. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72677. */
  72678. billboardMode: number;
  72679. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72680. limitVelocityDamping: number;
  72681. /**
  72682. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72683. */
  72684. beginAnimationOnStart: boolean;
  72685. /**
  72686. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72687. */
  72688. beginAnimationFrom: number;
  72689. /**
  72690. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72691. */
  72692. beginAnimationTo: number;
  72693. /**
  72694. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72695. */
  72696. beginAnimationLoop: boolean;
  72697. /**
  72698. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72699. */
  72700. disposeOnStop: boolean;
  72701. /**
  72702. * Gets the maximum number of particles active at the same time.
  72703. * @returns The max number of active particles.
  72704. */
  72705. getCapacity(): number;
  72706. /**
  72707. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72708. * @returns True if it has been started, otherwise false.
  72709. */
  72710. isStarted(): boolean;
  72711. /**
  72712. * Animates the particle system for this frame.
  72713. */
  72714. animate(): void;
  72715. /**
  72716. * Renders the particle system in its current state.
  72717. * @returns the current number of particles
  72718. */
  72719. render(): number;
  72720. /**
  72721. * Dispose the particle system and frees its associated resources.
  72722. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72723. */
  72724. dispose(disposeTexture?: boolean): void;
  72725. /**
  72726. * Clones the particle system.
  72727. * @param name The name of the cloned object
  72728. * @param newEmitter The new emitter to use
  72729. * @returns the cloned particle system
  72730. */
  72731. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  72732. /**
  72733. * Serializes the particle system to a JSON object.
  72734. * @returns the JSON object
  72735. */
  72736. serialize(): any;
  72737. /**
  72738. * Rebuild the particle system
  72739. */
  72740. rebuild(): void;
  72741. /**
  72742. * Starts the particle system and begins to emit
  72743. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  72744. */
  72745. start(delay?: number): void;
  72746. /**
  72747. * Stops the particle system.
  72748. */
  72749. stop(): void;
  72750. /**
  72751. * Remove all active particles
  72752. */
  72753. reset(): void;
  72754. /**
  72755. * Is this system ready to be used/rendered
  72756. * @return true if the system is ready
  72757. */
  72758. isReady(): boolean;
  72759. /**
  72760. * Adds a new color gradient
  72761. * @param gradient defines the gradient to use (between 0 and 1)
  72762. * @param color1 defines the color to affect to the specified gradient
  72763. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72764. * @returns the current particle system
  72765. */
  72766. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72767. /**
  72768. * Remove a specific color gradient
  72769. * @param gradient defines the gradient to remove
  72770. * @returns the current particle system
  72771. */
  72772. removeColorGradient(gradient: number): IParticleSystem;
  72773. /**
  72774. * Adds a new size gradient
  72775. * @param gradient defines the gradient to use (between 0 and 1)
  72776. * @param factor defines the size factor to affect to the specified gradient
  72777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72778. * @returns the current particle system
  72779. */
  72780. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72781. /**
  72782. * Remove a specific size gradient
  72783. * @param gradient defines the gradient to remove
  72784. * @returns the current particle system
  72785. */
  72786. removeSizeGradient(gradient: number): IParticleSystem;
  72787. /**
  72788. * Gets the current list of color gradients.
  72789. * You must use addColorGradient and removeColorGradient to udpate this list
  72790. * @returns the list of color gradients
  72791. */
  72792. getColorGradients(): Nullable<Array<ColorGradient>>;
  72793. /**
  72794. * Gets the current list of size gradients.
  72795. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72796. * @returns the list of size gradients
  72797. */
  72798. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72799. /**
  72800. * Gets the current list of angular speed gradients.
  72801. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72802. * @returns the list of angular speed gradients
  72803. */
  72804. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72805. /**
  72806. * Adds a new angular speed gradient
  72807. * @param gradient defines the gradient to use (between 0 and 1)
  72808. * @param factor defines the angular speed to affect to the specified gradient
  72809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72810. * @returns the current particle system
  72811. */
  72812. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72813. /**
  72814. * Remove a specific angular speed gradient
  72815. * @param gradient defines the gradient to remove
  72816. * @returns the current particle system
  72817. */
  72818. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72819. /**
  72820. * Gets the current list of velocity gradients.
  72821. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72822. * @returns the list of velocity gradients
  72823. */
  72824. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72825. /**
  72826. * Adds a new velocity gradient
  72827. * @param gradient defines the gradient to use (between 0 and 1)
  72828. * @param factor defines the velocity to affect to the specified gradient
  72829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72830. * @returns the current particle system
  72831. */
  72832. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72833. /**
  72834. * Remove a specific velocity gradient
  72835. * @param gradient defines the gradient to remove
  72836. * @returns the current particle system
  72837. */
  72838. removeVelocityGradient(gradient: number): IParticleSystem;
  72839. /**
  72840. * Gets the current list of limit velocity gradients.
  72841. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72842. * @returns the list of limit velocity gradients
  72843. */
  72844. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72845. /**
  72846. * Adds a new limit velocity gradient
  72847. * @param gradient defines the gradient to use (between 0 and 1)
  72848. * @param factor defines the limit velocity to affect to the specified gradient
  72849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72850. * @returns the current particle system
  72851. */
  72852. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72853. /**
  72854. * Remove a specific limit velocity gradient
  72855. * @param gradient defines the gradient to remove
  72856. * @returns the current particle system
  72857. */
  72858. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72859. /**
  72860. * Adds a new drag gradient
  72861. * @param gradient defines the gradient to use (between 0 and 1)
  72862. * @param factor defines the drag to affect to the specified gradient
  72863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72864. * @returns the current particle system
  72865. */
  72866. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72867. /**
  72868. * Remove a specific drag gradient
  72869. * @param gradient defines the gradient to remove
  72870. * @returns the current particle system
  72871. */
  72872. removeDragGradient(gradient: number): IParticleSystem;
  72873. /**
  72874. * Gets the current list of drag gradients.
  72875. * You must use addDragGradient and removeDragGradient to udpate this list
  72876. * @returns the list of drag gradients
  72877. */
  72878. getDragGradients(): Nullable<Array<FactorGradient>>;
  72879. /**
  72880. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72881. * @param gradient defines the gradient to use (between 0 and 1)
  72882. * @param factor defines the emit rate to affect to the specified gradient
  72883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72884. * @returns the current particle system
  72885. */
  72886. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72887. /**
  72888. * Remove a specific emit rate gradient
  72889. * @param gradient defines the gradient to remove
  72890. * @returns the current particle system
  72891. */
  72892. removeEmitRateGradient(gradient: number): IParticleSystem;
  72893. /**
  72894. * Gets the current list of emit rate gradients.
  72895. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72896. * @returns the list of emit rate gradients
  72897. */
  72898. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72899. /**
  72900. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72901. * @param gradient defines the gradient to use (between 0 and 1)
  72902. * @param factor defines the start size to affect to the specified gradient
  72903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72904. * @returns the current particle system
  72905. */
  72906. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72907. /**
  72908. * Remove a specific start size gradient
  72909. * @param gradient defines the gradient to remove
  72910. * @returns the current particle system
  72911. */
  72912. removeStartSizeGradient(gradient: number): IParticleSystem;
  72913. /**
  72914. * Gets the current list of start size gradients.
  72915. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72916. * @returns the list of start size gradients
  72917. */
  72918. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72919. /**
  72920. * Adds a new life time gradient
  72921. * @param gradient defines the gradient to use (between 0 and 1)
  72922. * @param factor defines the life time factor to affect to the specified gradient
  72923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72924. * @returns the current particle system
  72925. */
  72926. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72927. /**
  72928. * Remove a specific life time gradient
  72929. * @param gradient defines the gradient to remove
  72930. * @returns the current particle system
  72931. */
  72932. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72933. /**
  72934. * Gets the current list of life time gradients.
  72935. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72936. * @returns the list of life time gradients
  72937. */
  72938. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72939. /**
  72940. * Gets the current list of color gradients.
  72941. * You must use addColorGradient and removeColorGradient to udpate this list
  72942. * @returns the list of color gradients
  72943. */
  72944. getColorGradients(): Nullable<Array<ColorGradient>>;
  72945. /**
  72946. * Adds a new ramp gradient used to remap particle colors
  72947. * @param gradient defines the gradient to use (between 0 and 1)
  72948. * @param color defines the color to affect to the specified gradient
  72949. * @returns the current particle system
  72950. */
  72951. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72952. /**
  72953. * Gets the current list of ramp gradients.
  72954. * You must use addRampGradient and removeRampGradient to udpate this list
  72955. * @returns the list of ramp gradients
  72956. */
  72957. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72958. /** Gets or sets a boolean indicating that ramp gradients must be used
  72959. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72960. */
  72961. useRampGradients: boolean;
  72962. /**
  72963. * Adds a new color remap gradient
  72964. * @param gradient defines the gradient to use (between 0 and 1)
  72965. * @param min defines the color remap minimal range
  72966. * @param max defines the color remap maximal range
  72967. * @returns the current particle system
  72968. */
  72969. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72970. /**
  72971. * Gets the current list of color remap gradients.
  72972. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72973. * @returns the list of color remap gradients
  72974. */
  72975. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72976. /**
  72977. * Adds a new alpha remap gradient
  72978. * @param gradient defines the gradient to use (between 0 and 1)
  72979. * @param min defines the alpha remap minimal range
  72980. * @param max defines the alpha remap maximal range
  72981. * @returns the current particle system
  72982. */
  72983. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72984. /**
  72985. * Gets the current list of alpha remap gradients.
  72986. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72987. * @returns the list of alpha remap gradients
  72988. */
  72989. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72990. /**
  72991. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72994. * @returns the emitter
  72995. */
  72996. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72997. /**
  72998. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72999. * @param radius The radius of the hemisphere to emit from
  73000. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73001. * @returns the emitter
  73002. */
  73003. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73004. /**
  73005. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73006. * @param radius The radius of the sphere to emit from
  73007. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73008. * @returns the emitter
  73009. */
  73010. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73011. /**
  73012. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73013. * @param radius The radius of the sphere to emit from
  73014. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73015. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73016. * @returns the emitter
  73017. */
  73018. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73019. /**
  73020. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73021. * @param radius The radius of the emission cylinder
  73022. * @param height The height of the emission cylinder
  73023. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73024. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73025. * @returns the emitter
  73026. */
  73027. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73028. /**
  73029. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73030. * @param radius The radius of the cylinder to emit from
  73031. * @param height The height of the emission cylinder
  73032. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73033. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73034. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73035. * @returns the emitter
  73036. */
  73037. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73038. /**
  73039. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73040. * @param radius The radius of the cone to emit from
  73041. * @param angle The base angle of the cone
  73042. * @returns the emitter
  73043. */
  73044. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73045. /**
  73046. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73047. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73048. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73049. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73050. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73051. * @returns the emitter
  73052. */
  73053. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73054. /**
  73055. * Get hosting scene
  73056. * @returns the scene
  73057. */
  73058. getScene(): Scene;
  73059. }
  73060. }
  73061. declare module BABYLON {
  73062. /** @hidden */
  73063. export var linePixelShader: {
  73064. name: string;
  73065. shader: string;
  73066. };
  73067. }
  73068. declare module BABYLON {
  73069. /** @hidden */
  73070. export var lineVertexShader: {
  73071. name: string;
  73072. shader: string;
  73073. };
  73074. }
  73075. declare module BABYLON {
  73076. interface AbstractMesh {
  73077. /**
  73078. * Disables the mesh edge rendering mode
  73079. * @returns the currentAbstractMesh
  73080. */
  73081. disableEdgesRendering(): AbstractMesh;
  73082. /**
  73083. * Enables the edge rendering mode on the mesh.
  73084. * This mode makes the mesh edges visible
  73085. * @param epsilon defines the maximal distance between two angles to detect a face
  73086. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73087. * @returns the currentAbstractMesh
  73088. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73089. */
  73090. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73091. /**
  73092. * Gets the edgesRenderer associated with the mesh
  73093. */
  73094. edgesRenderer: Nullable<EdgesRenderer>;
  73095. }
  73096. interface LinesMesh {
  73097. /**
  73098. * Enables the edge rendering mode on the mesh.
  73099. * This mode makes the mesh edges visible
  73100. * @param epsilon defines the maximal distance between two angles to detect a face
  73101. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73102. * @returns the currentAbstractMesh
  73103. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73104. */
  73105. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73106. }
  73107. interface InstancedLinesMesh {
  73108. /**
  73109. * Enables the edge rendering mode on the mesh.
  73110. * This mode makes the mesh edges visible
  73111. * @param epsilon defines the maximal distance between two angles to detect a face
  73112. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73113. * @returns the current InstancedLinesMesh
  73114. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73115. */
  73116. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  73117. }
  73118. /**
  73119. * Defines the minimum contract an Edges renderer should follow.
  73120. */
  73121. export interface IEdgesRenderer extends IDisposable {
  73122. /**
  73123. * Gets or sets a boolean indicating if the edgesRenderer is active
  73124. */
  73125. isEnabled: boolean;
  73126. /**
  73127. * Renders the edges of the attached mesh,
  73128. */
  73129. render(): void;
  73130. /**
  73131. * Checks wether or not the edges renderer is ready to render.
  73132. * @return true if ready, otherwise false.
  73133. */
  73134. isReady(): boolean;
  73135. }
  73136. /**
  73137. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  73138. */
  73139. export class EdgesRenderer implements IEdgesRenderer {
  73140. /**
  73141. * Define the size of the edges with an orthographic camera
  73142. */
  73143. edgesWidthScalerForOrthographic: number;
  73144. /**
  73145. * Define the size of the edges with a perspective camera
  73146. */
  73147. edgesWidthScalerForPerspective: number;
  73148. protected _source: AbstractMesh;
  73149. protected _linesPositions: number[];
  73150. protected _linesNormals: number[];
  73151. protected _linesIndices: number[];
  73152. protected _epsilon: number;
  73153. protected _indicesCount: number;
  73154. protected _lineShader: ShaderMaterial;
  73155. protected _ib: WebGLBuffer;
  73156. protected _buffers: {
  73157. [key: string]: Nullable<VertexBuffer>;
  73158. };
  73159. protected _checkVerticesInsteadOfIndices: boolean;
  73160. private _meshRebuildObserver;
  73161. private _meshDisposeObserver;
  73162. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  73163. isEnabled: boolean;
  73164. /**
  73165. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  73166. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  73167. * @param source Mesh used to create edges
  73168. * @param epsilon sum of angles in adjacency to check for edge
  73169. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  73170. * @param generateEdgesLines - should generate Lines or only prepare resources.
  73171. */
  73172. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  73173. protected _prepareRessources(): void;
  73174. /** @hidden */
  73175. _rebuild(): void;
  73176. /**
  73177. * Releases the required resources for the edges renderer
  73178. */
  73179. dispose(): void;
  73180. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  73181. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  73182. /**
  73183. * Checks if the pair of p0 and p1 is en edge
  73184. * @param faceIndex
  73185. * @param edge
  73186. * @param faceNormals
  73187. * @param p0
  73188. * @param p1
  73189. * @private
  73190. */
  73191. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  73192. /**
  73193. * push line into the position, normal and index buffer
  73194. * @protected
  73195. */
  73196. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  73197. /**
  73198. * Generates lines edges from adjacencjes
  73199. * @private
  73200. */
  73201. _generateEdgesLines(): void;
  73202. /**
  73203. * Checks wether or not the edges renderer is ready to render.
  73204. * @return true if ready, otherwise false.
  73205. */
  73206. isReady(): boolean;
  73207. /**
  73208. * Renders the edges of the attached mesh,
  73209. */
  73210. render(): void;
  73211. }
  73212. /**
  73213. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  73214. */
  73215. export class LineEdgesRenderer extends EdgesRenderer {
  73216. /**
  73217. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  73218. * @param source LineMesh used to generate edges
  73219. * @param epsilon not important (specified angle for edge detection)
  73220. * @param checkVerticesInsteadOfIndices not important for LineMesh
  73221. */
  73222. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  73223. /**
  73224. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  73225. */
  73226. _generateEdgesLines(): void;
  73227. }
  73228. }
  73229. declare module BABYLON {
  73230. /**
  73231. * This represents the object necessary to create a rendering group.
  73232. * This is exclusively used and created by the rendering manager.
  73233. * To modify the behavior, you use the available helpers in your scene or meshes.
  73234. * @hidden
  73235. */
  73236. export class RenderingGroup {
  73237. index: number;
  73238. private _scene;
  73239. private _opaqueSubMeshes;
  73240. private _transparentSubMeshes;
  73241. private _alphaTestSubMeshes;
  73242. private _depthOnlySubMeshes;
  73243. private _particleSystems;
  73244. private _spriteManagers;
  73245. private _opaqueSortCompareFn;
  73246. private _alphaTestSortCompareFn;
  73247. private _transparentSortCompareFn;
  73248. private _renderOpaque;
  73249. private _renderAlphaTest;
  73250. private _renderTransparent;
  73251. private _edgesRenderers;
  73252. onBeforeTransparentRendering: () => void;
  73253. /**
  73254. * Set the opaque sort comparison function.
  73255. * If null the sub meshes will be render in the order they were created
  73256. */
  73257. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73258. /**
  73259. * Set the alpha test sort comparison function.
  73260. * If null the sub meshes will be render in the order they were created
  73261. */
  73262. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73263. /**
  73264. * Set the transparent sort comparison function.
  73265. * If null the sub meshes will be render in the order they were created
  73266. */
  73267. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73268. /**
  73269. * Creates a new rendering group.
  73270. * @param index The rendering group index
  73271. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73272. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73273. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73274. */
  73275. 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>);
  73276. /**
  73277. * Render all the sub meshes contained in the group.
  73278. * @param customRenderFunction Used to override the default render behaviour of the group.
  73279. * @returns true if rendered some submeshes.
  73280. */
  73281. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73282. /**
  73283. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73284. * @param subMeshes The submeshes to render
  73285. */
  73286. private renderOpaqueSorted;
  73287. /**
  73288. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73289. * @param subMeshes The submeshes to render
  73290. */
  73291. private renderAlphaTestSorted;
  73292. /**
  73293. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73294. * @param subMeshes The submeshes to render
  73295. */
  73296. private renderTransparentSorted;
  73297. /**
  73298. * Renders the submeshes in a specified order.
  73299. * @param subMeshes The submeshes to sort before render
  73300. * @param sortCompareFn The comparison function use to sort
  73301. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73302. * @param transparent Specifies to activate blending if true
  73303. */
  73304. private static renderSorted;
  73305. /**
  73306. * Renders the submeshes in the order they were dispatched (no sort applied).
  73307. * @param subMeshes The submeshes to render
  73308. */
  73309. private static renderUnsorted;
  73310. /**
  73311. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73312. * are rendered back to front if in the same alpha index.
  73313. *
  73314. * @param a The first submesh
  73315. * @param b The second submesh
  73316. * @returns The result of the comparison
  73317. */
  73318. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73319. /**
  73320. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73321. * are rendered back to front.
  73322. *
  73323. * @param a The first submesh
  73324. * @param b The second submesh
  73325. * @returns The result of the comparison
  73326. */
  73327. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73328. /**
  73329. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73330. * are rendered front to back (prevent overdraw).
  73331. *
  73332. * @param a The first submesh
  73333. * @param b The second submesh
  73334. * @returns The result of the comparison
  73335. */
  73336. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73337. /**
  73338. * Resets the different lists of submeshes to prepare a new frame.
  73339. */
  73340. prepare(): void;
  73341. dispose(): void;
  73342. /**
  73343. * Inserts the submesh in its correct queue depending on its material.
  73344. * @param subMesh The submesh to dispatch
  73345. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73346. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73347. */
  73348. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73349. dispatchSprites(spriteManager: ISpriteManager): void;
  73350. dispatchParticles(particleSystem: IParticleSystem): void;
  73351. private _renderParticles;
  73352. private _renderSprites;
  73353. }
  73354. }
  73355. declare module BABYLON {
  73356. /**
  73357. * Interface describing the different options available in the rendering manager
  73358. * regarding Auto Clear between groups.
  73359. */
  73360. export interface IRenderingManagerAutoClearSetup {
  73361. /**
  73362. * Defines whether or not autoclear is enable.
  73363. */
  73364. autoClear: boolean;
  73365. /**
  73366. * Defines whether or not to autoclear the depth buffer.
  73367. */
  73368. depth: boolean;
  73369. /**
  73370. * Defines whether or not to autoclear the stencil buffer.
  73371. */
  73372. stencil: boolean;
  73373. }
  73374. /**
  73375. * This class is used by the onRenderingGroupObservable
  73376. */
  73377. export class RenderingGroupInfo {
  73378. /**
  73379. * The Scene that being rendered
  73380. */
  73381. scene: Scene;
  73382. /**
  73383. * The camera currently used for the rendering pass
  73384. */
  73385. camera: Nullable<Camera>;
  73386. /**
  73387. * The ID of the renderingGroup being processed
  73388. */
  73389. renderingGroupId: number;
  73390. }
  73391. /**
  73392. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73393. * It is enable to manage the different groups as well as the different necessary sort functions.
  73394. * This should not be used directly aside of the few static configurations
  73395. */
  73396. export class RenderingManager {
  73397. /**
  73398. * The max id used for rendering groups (not included)
  73399. */
  73400. static MAX_RENDERINGGROUPS: number;
  73401. /**
  73402. * The min id used for rendering groups (included)
  73403. */
  73404. static MIN_RENDERINGGROUPS: number;
  73405. /**
  73406. * Used to globally prevent autoclearing scenes.
  73407. */
  73408. static AUTOCLEAR: boolean;
  73409. /**
  73410. * @hidden
  73411. */
  73412. _useSceneAutoClearSetup: boolean;
  73413. private _scene;
  73414. private _renderingGroups;
  73415. private _depthStencilBufferAlreadyCleaned;
  73416. private _autoClearDepthStencil;
  73417. private _customOpaqueSortCompareFn;
  73418. private _customAlphaTestSortCompareFn;
  73419. private _customTransparentSortCompareFn;
  73420. private _renderingGroupInfo;
  73421. /**
  73422. * Instantiates a new rendering group for a particular scene
  73423. * @param scene Defines the scene the groups belongs to
  73424. */
  73425. constructor(scene: Scene);
  73426. private _clearDepthStencilBuffer;
  73427. /**
  73428. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73429. * @hidden
  73430. */
  73431. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73432. /**
  73433. * Resets the different information of the group to prepare a new frame
  73434. * @hidden
  73435. */
  73436. reset(): void;
  73437. /**
  73438. * Dispose and release the group and its associated resources.
  73439. * @hidden
  73440. */
  73441. dispose(): void;
  73442. /**
  73443. * Clear the info related to rendering groups preventing retention points during dispose.
  73444. */
  73445. freeRenderingGroups(): void;
  73446. private _prepareRenderingGroup;
  73447. /**
  73448. * Add a sprite manager to the rendering manager in order to render it this frame.
  73449. * @param spriteManager Define the sprite manager to render
  73450. */
  73451. dispatchSprites(spriteManager: ISpriteManager): void;
  73452. /**
  73453. * Add a particle system to the rendering manager in order to render it this frame.
  73454. * @param particleSystem Define the particle system to render
  73455. */
  73456. dispatchParticles(particleSystem: IParticleSystem): void;
  73457. /**
  73458. * Add a submesh to the manager in order to render it this frame
  73459. * @param subMesh The submesh to dispatch
  73460. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73461. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73462. */
  73463. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73464. /**
  73465. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73466. * This allowed control for front to back rendering or reversly depending of the special needs.
  73467. *
  73468. * @param renderingGroupId The rendering group id corresponding to its index
  73469. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73470. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73471. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73472. */
  73473. 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;
  73474. /**
  73475. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73476. *
  73477. * @param renderingGroupId The rendering group id corresponding to its index
  73478. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73479. * @param depth Automatically clears depth between groups if true and autoClear is true.
  73480. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  73481. */
  73482. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  73483. /**
  73484. * Gets the current auto clear configuration for one rendering group of the rendering
  73485. * manager.
  73486. * @param index the rendering group index to get the information for
  73487. * @returns The auto clear setup for the requested rendering group
  73488. */
  73489. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  73490. }
  73491. }
  73492. declare module BABYLON {
  73493. /**
  73494. * This Helps creating a texture that will be created from a camera in your scene.
  73495. * It is basically a dynamic texture that could be used to create special effects for instance.
  73496. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  73497. */
  73498. export class RenderTargetTexture extends Texture {
  73499. isCube: boolean;
  73500. /**
  73501. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  73502. */
  73503. static readonly REFRESHRATE_RENDER_ONCE: number;
  73504. /**
  73505. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  73506. */
  73507. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  73508. /**
  73509. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  73510. * the central point of your effect and can save a lot of performances.
  73511. */
  73512. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  73513. /**
  73514. * Use this predicate to dynamically define the list of mesh you want to render.
  73515. * If set, the renderList property will be overwritten.
  73516. */
  73517. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  73518. private _renderList;
  73519. /**
  73520. * Use this list to define the list of mesh you want to render.
  73521. */
  73522. renderList: Nullable<Array<AbstractMesh>>;
  73523. private _hookArray;
  73524. /**
  73525. * Define if particles should be rendered in your texture.
  73526. */
  73527. renderParticles: boolean;
  73528. /**
  73529. * Define if sprites should be rendered in your texture.
  73530. */
  73531. renderSprites: boolean;
  73532. /**
  73533. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  73534. */
  73535. coordinatesMode: number;
  73536. /**
  73537. * Define the camera used to render the texture.
  73538. */
  73539. activeCamera: Nullable<Camera>;
  73540. /**
  73541. * Override the render function of the texture with your own one.
  73542. */
  73543. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  73544. /**
  73545. * Define if camera post processes should be use while rendering the texture.
  73546. */
  73547. useCameraPostProcesses: boolean;
  73548. /**
  73549. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  73550. */
  73551. ignoreCameraViewport: boolean;
  73552. private _postProcessManager;
  73553. private _postProcesses;
  73554. private _resizeObserver;
  73555. /**
  73556. * An event triggered when the texture is unbind.
  73557. */
  73558. onBeforeBindObservable: Observable<RenderTargetTexture>;
  73559. /**
  73560. * An event triggered when the texture is unbind.
  73561. */
  73562. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  73563. private _onAfterUnbindObserver;
  73564. /**
  73565. * Set a after unbind callback in the texture.
  73566. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  73567. */
  73568. onAfterUnbind: () => void;
  73569. /**
  73570. * An event triggered before rendering the texture
  73571. */
  73572. onBeforeRenderObservable: Observable<number>;
  73573. private _onBeforeRenderObserver;
  73574. /**
  73575. * Set a before render callback in the texture.
  73576. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  73577. */
  73578. onBeforeRender: (faceIndex: number) => void;
  73579. /**
  73580. * An event triggered after rendering the texture
  73581. */
  73582. onAfterRenderObservable: Observable<number>;
  73583. private _onAfterRenderObserver;
  73584. /**
  73585. * Set a after render callback in the texture.
  73586. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  73587. */
  73588. onAfterRender: (faceIndex: number) => void;
  73589. /**
  73590. * An event triggered after the texture clear
  73591. */
  73592. onClearObservable: Observable<Engine>;
  73593. private _onClearObserver;
  73594. /**
  73595. * Set a clear callback in the texture.
  73596. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  73597. */
  73598. onClear: (Engine: Engine) => void;
  73599. /**
  73600. * Define the clear color of the Render Target if it should be different from the scene.
  73601. */
  73602. clearColor: Color4;
  73603. protected _size: number | {
  73604. width: number;
  73605. height: number;
  73606. };
  73607. protected _initialSizeParameter: number | {
  73608. width: number;
  73609. height: number;
  73610. } | {
  73611. ratio: number;
  73612. };
  73613. protected _sizeRatio: Nullable<number>;
  73614. /** @hidden */
  73615. _generateMipMaps: boolean;
  73616. protected _renderingManager: RenderingManager;
  73617. /** @hidden */
  73618. _waitingRenderList: string[];
  73619. protected _doNotChangeAspectRatio: boolean;
  73620. protected _currentRefreshId: number;
  73621. protected _refreshRate: number;
  73622. protected _textureMatrix: Matrix;
  73623. protected _samples: number;
  73624. protected _renderTargetOptions: RenderTargetCreationOptions;
  73625. /**
  73626. * Gets render target creation options that were used.
  73627. */
  73628. readonly renderTargetOptions: RenderTargetCreationOptions;
  73629. protected _engine: Engine;
  73630. protected _onRatioRescale(): void;
  73631. /**
  73632. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  73633. * It must define where the camera used to render the texture is set
  73634. */
  73635. boundingBoxPosition: Vector3;
  73636. private _boundingBoxSize;
  73637. /**
  73638. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  73639. * When defined, the cubemap will switch to local mode
  73640. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73641. * @example https://www.babylonjs-playground.com/#RNASML
  73642. */
  73643. boundingBoxSize: Vector3;
  73644. /**
  73645. * In case the RTT has been created with a depth texture, get the associated
  73646. * depth texture.
  73647. * Otherwise, return null.
  73648. */
  73649. depthStencilTexture: Nullable<InternalTexture>;
  73650. /**
  73651. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  73652. * or used a shadow, depth texture...
  73653. * @param name The friendly name of the texture
  73654. * @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)
  73655. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  73656. * @param generateMipMaps True if mip maps need to be generated after render.
  73657. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  73658. * @param type The type of the buffer in the RTT (int, half float, float...)
  73659. * @param isCube True if a cube texture needs to be created
  73660. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  73661. * @param generateDepthBuffer True to generate a depth buffer
  73662. * @param generateStencilBuffer True to generate a stencil buffer
  73663. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  73664. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  73665. * @param delayAllocation if the texture allocation should be delayed (default: false)
  73666. */
  73667. constructor(name: string, size: number | {
  73668. width: number;
  73669. height: number;
  73670. } | {
  73671. ratio: number;
  73672. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  73673. /**
  73674. * Creates a depth stencil texture.
  73675. * This is only available in WebGL 2 or with the depth texture extension available.
  73676. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  73677. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  73678. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  73679. */
  73680. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  73681. private _processSizeParameter;
  73682. /**
  73683. * Define the number of samples to use in case of MSAA.
  73684. * It defaults to one meaning no MSAA has been enabled.
  73685. */
  73686. samples: number;
  73687. /**
  73688. * Resets the refresh counter of the texture and start bak from scratch.
  73689. * Could be useful to regenerate the texture if it is setup to render only once.
  73690. */
  73691. resetRefreshCounter(): void;
  73692. /**
  73693. * Define the refresh rate of the texture or the rendering frequency.
  73694. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73695. */
  73696. refreshRate: number;
  73697. /**
  73698. * Adds a post process to the render target rendering passes.
  73699. * @param postProcess define the post process to add
  73700. */
  73701. addPostProcess(postProcess: PostProcess): void;
  73702. /**
  73703. * Clear all the post processes attached to the render target
  73704. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  73705. */
  73706. clearPostProcesses(dispose?: boolean): void;
  73707. /**
  73708. * Remove one of the post process from the list of attached post processes to the texture
  73709. * @param postProcess define the post process to remove from the list
  73710. */
  73711. removePostProcess(postProcess: PostProcess): void;
  73712. /** @hidden */
  73713. _shouldRender(): boolean;
  73714. /**
  73715. * Gets the actual render size of the texture.
  73716. * @returns the width of the render size
  73717. */
  73718. getRenderSize(): number;
  73719. /**
  73720. * Gets the actual render width of the texture.
  73721. * @returns the width of the render size
  73722. */
  73723. getRenderWidth(): number;
  73724. /**
  73725. * Gets the actual render height of the texture.
  73726. * @returns the height of the render size
  73727. */
  73728. getRenderHeight(): number;
  73729. /**
  73730. * Get if the texture can be rescaled or not.
  73731. */
  73732. readonly canRescale: boolean;
  73733. /**
  73734. * Resize the texture using a ratio.
  73735. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  73736. */
  73737. scale(ratio: number): void;
  73738. /**
  73739. * Get the texture reflection matrix used to rotate/transform the reflection.
  73740. * @returns the reflection matrix
  73741. */
  73742. getReflectionTextureMatrix(): Matrix;
  73743. /**
  73744. * Resize the texture to a new desired size.
  73745. * Be carrefull as it will recreate all the data in the new texture.
  73746. * @param size Define the new size. It can be:
  73747. * - a number for squared texture,
  73748. * - an object containing { width: number, height: number }
  73749. * - or an object containing a ratio { ratio: number }
  73750. */
  73751. resize(size: number | {
  73752. width: number;
  73753. height: number;
  73754. } | {
  73755. ratio: number;
  73756. }): void;
  73757. /**
  73758. * Renders all the objects from the render list into the texture.
  73759. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  73760. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  73761. */
  73762. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  73763. private _bestReflectionRenderTargetDimension;
  73764. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  73765. private renderToTarget;
  73766. /**
  73767. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73768. * This allowed control for front to back rendering or reversly depending of the special needs.
  73769. *
  73770. * @param renderingGroupId The rendering group id corresponding to its index
  73771. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73772. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73773. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73774. */
  73775. 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;
  73776. /**
  73777. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73778. *
  73779. * @param renderingGroupId The rendering group id corresponding to its index
  73780. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73781. */
  73782. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  73783. /**
  73784. * Clones the texture.
  73785. * @returns the cloned texture
  73786. */
  73787. clone(): RenderTargetTexture;
  73788. /**
  73789. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  73790. * @returns The JSON representation of the texture
  73791. */
  73792. serialize(): any;
  73793. /**
  73794. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  73795. */
  73796. disposeFramebufferObjects(): void;
  73797. /**
  73798. * Dispose the texture and release its associated resources.
  73799. */
  73800. dispose(): void;
  73801. /** @hidden */
  73802. _rebuild(): void;
  73803. /**
  73804. * Clear the info related to rendering groups preventing retention point in material dispose.
  73805. */
  73806. freeRenderingGroups(): void;
  73807. }
  73808. }
  73809. declare module BABYLON {
  73810. /**
  73811. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73812. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73813. * You can then easily use it as a reflectionTexture on a flat surface.
  73814. * In case the surface is not a plane, please consider relying on reflection probes.
  73815. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73816. */
  73817. export class MirrorTexture extends RenderTargetTexture {
  73818. private scene;
  73819. /**
  73820. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  73821. * 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.
  73822. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73823. */
  73824. mirrorPlane: Plane;
  73825. /**
  73826. * Define the blur ratio used to blur the reflection if needed.
  73827. */
  73828. blurRatio: number;
  73829. /**
  73830. * Define the adaptive blur kernel used to blur the reflection if needed.
  73831. * This will autocompute the closest best match for the `blurKernel`
  73832. */
  73833. adaptiveBlurKernel: number;
  73834. /**
  73835. * Define the blur kernel used to blur the reflection if needed.
  73836. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73837. */
  73838. blurKernel: number;
  73839. /**
  73840. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  73841. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73842. */
  73843. blurKernelX: number;
  73844. /**
  73845. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  73846. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73847. */
  73848. blurKernelY: number;
  73849. private _autoComputeBlurKernel;
  73850. protected _onRatioRescale(): void;
  73851. private _updateGammaSpace;
  73852. private _imageProcessingConfigChangeObserver;
  73853. private _transformMatrix;
  73854. private _mirrorMatrix;
  73855. private _savedViewMatrix;
  73856. private _blurX;
  73857. private _blurY;
  73858. private _adaptiveBlurKernel;
  73859. private _blurKernelX;
  73860. private _blurKernelY;
  73861. private _blurRatio;
  73862. /**
  73863. * Instantiates a Mirror Texture.
  73864. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73865. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73866. * You can then easily use it as a reflectionTexture on a flat surface.
  73867. * In case the surface is not a plane, please consider relying on reflection probes.
  73868. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73869. * @param name
  73870. * @param size
  73871. * @param scene
  73872. * @param generateMipMaps
  73873. * @param type
  73874. * @param samplingMode
  73875. * @param generateDepthBuffer
  73876. */
  73877. constructor(name: string, size: number | {
  73878. width: number;
  73879. height: number;
  73880. } | {
  73881. ratio: number;
  73882. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  73883. private _preparePostProcesses;
  73884. /**
  73885. * Clone the mirror texture.
  73886. * @returns the cloned texture
  73887. */
  73888. clone(): MirrorTexture;
  73889. /**
  73890. * Serialize the texture to a JSON representation you could use in Parse later on
  73891. * @returns the serialized JSON representation
  73892. */
  73893. serialize(): any;
  73894. /**
  73895. * Dispose the texture and release its associated resources.
  73896. */
  73897. dispose(): void;
  73898. }
  73899. }
  73900. declare module BABYLON {
  73901. /**
  73902. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  73903. * @see http://doc.babylonjs.com/babylon101/materials#texture
  73904. */
  73905. export class Texture extends BaseTexture {
  73906. /** @hidden */
  73907. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  73908. /** @hidden */
  73909. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  73910. /** @hidden */
  73911. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  73912. /** nearest is mag = nearest and min = nearest and mip = linear */
  73913. static readonly NEAREST_SAMPLINGMODE: number;
  73914. /** nearest is mag = nearest and min = nearest and mip = linear */
  73915. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  73916. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73917. static readonly BILINEAR_SAMPLINGMODE: number;
  73918. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73919. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  73920. /** Trilinear is mag = linear and min = linear and mip = linear */
  73921. static readonly TRILINEAR_SAMPLINGMODE: number;
  73922. /** Trilinear is mag = linear and min = linear and mip = linear */
  73923. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  73924. /** mag = nearest and min = nearest and mip = nearest */
  73925. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  73926. /** mag = nearest and min = linear and mip = nearest */
  73927. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  73928. /** mag = nearest and min = linear and mip = linear */
  73929. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  73930. /** mag = nearest and min = linear and mip = none */
  73931. static readonly NEAREST_LINEAR: number;
  73932. /** mag = nearest and min = nearest and mip = none */
  73933. static readonly NEAREST_NEAREST: number;
  73934. /** mag = linear and min = nearest and mip = nearest */
  73935. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  73936. /** mag = linear and min = nearest and mip = linear */
  73937. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  73938. /** mag = linear and min = linear and mip = none */
  73939. static readonly LINEAR_LINEAR: number;
  73940. /** mag = linear and min = nearest and mip = none */
  73941. static readonly LINEAR_NEAREST: number;
  73942. /** Explicit coordinates mode */
  73943. static readonly EXPLICIT_MODE: number;
  73944. /** Spherical coordinates mode */
  73945. static readonly SPHERICAL_MODE: number;
  73946. /** Planar coordinates mode */
  73947. static readonly PLANAR_MODE: number;
  73948. /** Cubic coordinates mode */
  73949. static readonly CUBIC_MODE: number;
  73950. /** Projection coordinates mode */
  73951. static readonly PROJECTION_MODE: number;
  73952. /** Inverse Cubic coordinates mode */
  73953. static readonly SKYBOX_MODE: number;
  73954. /** Inverse Cubic coordinates mode */
  73955. static readonly INVCUBIC_MODE: number;
  73956. /** Equirectangular coordinates mode */
  73957. static readonly EQUIRECTANGULAR_MODE: number;
  73958. /** Equirectangular Fixed coordinates mode */
  73959. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  73960. /** Equirectangular Fixed Mirrored coordinates mode */
  73961. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73962. /** Texture is not repeating outside of 0..1 UVs */
  73963. static readonly CLAMP_ADDRESSMODE: number;
  73964. /** Texture is repeating outside of 0..1 UVs */
  73965. static readonly WRAP_ADDRESSMODE: number;
  73966. /** Texture is repeating and mirrored */
  73967. static readonly MIRROR_ADDRESSMODE: number;
  73968. /**
  73969. * 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
  73970. */
  73971. static UseSerializedUrlIfAny: boolean;
  73972. /**
  73973. * Define the url of the texture.
  73974. */
  73975. url: Nullable<string>;
  73976. /**
  73977. * Define an offset on the texture to offset the u coordinates of the UVs
  73978. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  73979. */
  73980. uOffset: number;
  73981. /**
  73982. * Define an offset on the texture to offset the v coordinates of the UVs
  73983. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  73984. */
  73985. vOffset: number;
  73986. /**
  73987. * Define an offset on the texture to scale the u coordinates of the UVs
  73988. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  73989. */
  73990. uScale: number;
  73991. /**
  73992. * Define an offset on the texture to scale the v coordinates of the UVs
  73993. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  73994. */
  73995. vScale: number;
  73996. /**
  73997. * Define an offset on the texture to rotate around the u coordinates of the UVs
  73998. * @see http://doc.babylonjs.com/how_to/more_materials
  73999. */
  74000. uAng: number;
  74001. /**
  74002. * Define an offset on the texture to rotate around the v coordinates of the UVs
  74003. * @see http://doc.babylonjs.com/how_to/more_materials
  74004. */
  74005. vAng: number;
  74006. /**
  74007. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  74008. * @see http://doc.babylonjs.com/how_to/more_materials
  74009. */
  74010. wAng: number;
  74011. /**
  74012. * Defines the center of rotation (U)
  74013. */
  74014. uRotationCenter: number;
  74015. /**
  74016. * Defines the center of rotation (V)
  74017. */
  74018. vRotationCenter: number;
  74019. /**
  74020. * Defines the center of rotation (W)
  74021. */
  74022. wRotationCenter: number;
  74023. /**
  74024. * Are mip maps generated for this texture or not.
  74025. */
  74026. readonly noMipmap: boolean;
  74027. private _noMipmap;
  74028. /** @hidden */
  74029. _invertY: boolean;
  74030. private _rowGenerationMatrix;
  74031. private _cachedTextureMatrix;
  74032. private _projectionModeMatrix;
  74033. private _t0;
  74034. private _t1;
  74035. private _t2;
  74036. private _cachedUOffset;
  74037. private _cachedVOffset;
  74038. private _cachedUScale;
  74039. private _cachedVScale;
  74040. private _cachedUAng;
  74041. private _cachedVAng;
  74042. private _cachedWAng;
  74043. private _cachedProjectionMatrixId;
  74044. private _cachedCoordinatesMode;
  74045. /** @hidden */
  74046. protected _initialSamplingMode: number;
  74047. /** @hidden */
  74048. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  74049. private _deleteBuffer;
  74050. protected _format: Nullable<number>;
  74051. private _delayedOnLoad;
  74052. private _delayedOnError;
  74053. /**
  74054. * Observable triggered once the texture has been loaded.
  74055. */
  74056. onLoadObservable: Observable<Texture>;
  74057. protected _isBlocking: boolean;
  74058. /**
  74059. * Is the texture preventing material to render while loading.
  74060. * If false, a default texture will be used instead of the loading one during the preparation step.
  74061. */
  74062. isBlocking: boolean;
  74063. /**
  74064. * Get the current sampling mode associated with the texture.
  74065. */
  74066. readonly samplingMode: number;
  74067. /**
  74068. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  74069. */
  74070. readonly invertY: boolean;
  74071. /**
  74072. * Instantiates a new texture.
  74073. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74074. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74075. * @param url define the url of the picture to load as a texture
  74076. * @param scene define the scene the texture will belong to
  74077. * @param noMipmap define if the texture will require mip maps or not
  74078. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74079. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74080. * @param onLoad define a callback triggered when the texture has been loaded
  74081. * @param onError define a callback triggered when an error occurred during the loading session
  74082. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74083. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74084. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74085. */
  74086. 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);
  74087. /**
  74088. * Update the url (and optional buffer) of this texture if url was null during construction.
  74089. * @param url the url of the texture
  74090. * @param buffer the buffer of the texture (defaults to null)
  74091. * @param onLoad callback called when the texture is loaded (defaults to null)
  74092. */
  74093. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  74094. /**
  74095. * Finish the loading sequence of a texture flagged as delayed load.
  74096. * @hidden
  74097. */
  74098. delayLoad(): void;
  74099. private _prepareRowForTextureGeneration;
  74100. /**
  74101. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  74102. * @returns the transform matrix of the texture.
  74103. */
  74104. getTextureMatrix(): Matrix;
  74105. /**
  74106. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  74107. * @returns The reflection texture transform
  74108. */
  74109. getReflectionTextureMatrix(): Matrix;
  74110. /**
  74111. * Clones the texture.
  74112. * @returns the cloned texture
  74113. */
  74114. clone(): Texture;
  74115. /**
  74116. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74117. * @returns The JSON representation of the texture
  74118. */
  74119. serialize(): any;
  74120. /**
  74121. * Get the current class name of the texture useful for serialization or dynamic coding.
  74122. * @returns "Texture"
  74123. */
  74124. getClassName(): string;
  74125. /**
  74126. * Dispose the texture and release its associated resources.
  74127. */
  74128. dispose(): void;
  74129. /**
  74130. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  74131. * @param parsedTexture Define the JSON representation of the texture
  74132. * @param scene Define the scene the parsed texture should be instantiated in
  74133. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  74134. * @returns The parsed texture if successful
  74135. */
  74136. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  74137. /**
  74138. * Creates a texture from its base 64 representation.
  74139. * @param data Define the base64 payload without the data: prefix
  74140. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74141. * @param scene Define the scene the texture should belong to
  74142. * @param noMipmap Forces the texture to not create mip map information if true
  74143. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74144. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74145. * @param onLoad define a callback triggered when the texture has been loaded
  74146. * @param onError define a callback triggered when an error occurred during the loading session
  74147. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74148. * @returns the created texture
  74149. */
  74150. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  74151. /**
  74152. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  74153. * @param data Define the base64 payload without the data: prefix
  74154. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74155. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74156. * @param scene Define the scene the texture should belong to
  74157. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74158. * @param noMipmap Forces the texture to not create mip map information if true
  74159. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74160. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74161. * @param onLoad define a callback triggered when the texture has been loaded
  74162. * @param onError define a callback triggered when an error occurred during the loading session
  74163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74164. * @returns the created texture
  74165. */
  74166. 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;
  74167. }
  74168. }
  74169. declare module BABYLON {
  74170. /**
  74171. * Defines the options associated with the creation of a shader material.
  74172. */
  74173. export interface IShaderMaterialOptions {
  74174. /**
  74175. * Does the material work in alpha blend mode
  74176. */
  74177. needAlphaBlending: boolean;
  74178. /**
  74179. * Does the material work in alpha test mode
  74180. */
  74181. needAlphaTesting: boolean;
  74182. /**
  74183. * The list of attribute names used in the shader
  74184. */
  74185. attributes: string[];
  74186. /**
  74187. * The list of unifrom names used in the shader
  74188. */
  74189. uniforms: string[];
  74190. /**
  74191. * The list of UBO names used in the shader
  74192. */
  74193. uniformBuffers: string[];
  74194. /**
  74195. * The list of sampler names used in the shader
  74196. */
  74197. samplers: string[];
  74198. /**
  74199. * The list of defines used in the shader
  74200. */
  74201. defines: string[];
  74202. }
  74203. /**
  74204. * 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.
  74205. *
  74206. * This returned material effects how the mesh will look based on the code in the shaders.
  74207. *
  74208. * @see http://doc.babylonjs.com/how_to/shader_material
  74209. */
  74210. export class ShaderMaterial extends Material {
  74211. private _shaderPath;
  74212. private _options;
  74213. private _textures;
  74214. private _textureArrays;
  74215. private _floats;
  74216. private _ints;
  74217. private _floatsArrays;
  74218. private _colors3;
  74219. private _colors3Arrays;
  74220. private _colors4;
  74221. private _vectors2;
  74222. private _vectors3;
  74223. private _vectors4;
  74224. private _matrices;
  74225. private _matrices3x3;
  74226. private _matrices2x2;
  74227. private _vectors2Arrays;
  74228. private _vectors3Arrays;
  74229. private _cachedWorldViewMatrix;
  74230. private _renderId;
  74231. /**
  74232. * Instantiate a new shader material.
  74233. * 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.
  74234. * This returned material effects how the mesh will look based on the code in the shaders.
  74235. * @see http://doc.babylonjs.com/how_to/shader_material
  74236. * @param name Define the name of the material in the scene
  74237. * @param scene Define the scene the material belongs to
  74238. * @param shaderPath Defines the route to the shader code in one of three ways:
  74239. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74240. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74241. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74242. * @param options Define the options used to create the shader
  74243. */
  74244. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74245. /**
  74246. * Gets the current class name of the material e.g. "ShaderMaterial"
  74247. * Mainly use in serialization.
  74248. * @returns the class name
  74249. */
  74250. getClassName(): string;
  74251. /**
  74252. * Specifies if the material will require alpha blending
  74253. * @returns a boolean specifying if alpha blending is needed
  74254. */
  74255. needAlphaBlending(): boolean;
  74256. /**
  74257. * Specifies if this material should be rendered in alpha test mode
  74258. * @returns a boolean specifying if an alpha test is needed.
  74259. */
  74260. needAlphaTesting(): boolean;
  74261. private _checkUniform;
  74262. /**
  74263. * Set a texture in the shader.
  74264. * @param name Define the name of the uniform samplers as defined in the shader
  74265. * @param texture Define the texture to bind to this sampler
  74266. * @return the material itself allowing "fluent" like uniform updates
  74267. */
  74268. setTexture(name: string, texture: Texture): ShaderMaterial;
  74269. /**
  74270. * Set a texture array in the shader.
  74271. * @param name Define the name of the uniform sampler array as defined in the shader
  74272. * @param textures Define the list of textures to bind to this sampler
  74273. * @return the material itself allowing "fluent" like uniform updates
  74274. */
  74275. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74276. /**
  74277. * Set a float in the shader.
  74278. * @param name Define the name of the uniform as defined in the shader
  74279. * @param value Define the value to give to the uniform
  74280. * @return the material itself allowing "fluent" like uniform updates
  74281. */
  74282. setFloat(name: string, value: number): ShaderMaterial;
  74283. /**
  74284. * Set a int in the shader.
  74285. * @param name Define the name of the uniform as defined in the shader
  74286. * @param value Define the value to give to the uniform
  74287. * @return the material itself allowing "fluent" like uniform updates
  74288. */
  74289. setInt(name: string, value: number): ShaderMaterial;
  74290. /**
  74291. * Set an array of floats in the shader.
  74292. * @param name Define the name of the uniform as defined in the shader
  74293. * @param value Define the value to give to the uniform
  74294. * @return the material itself allowing "fluent" like uniform updates
  74295. */
  74296. setFloats(name: string, value: number[]): ShaderMaterial;
  74297. /**
  74298. * Set a vec3 in the shader from a Color3.
  74299. * @param name Define the name of the uniform as defined in the shader
  74300. * @param value Define the value to give to the uniform
  74301. * @return the material itself allowing "fluent" like uniform updates
  74302. */
  74303. setColor3(name: string, value: Color3): ShaderMaterial;
  74304. /**
  74305. * Set a vec3 array in the shader from a Color3 array.
  74306. * @param name Define the name of the uniform as defined in the shader
  74307. * @param value Define the value to give to the uniform
  74308. * @return the material itself allowing "fluent" like uniform updates
  74309. */
  74310. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74311. /**
  74312. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  74318. /**
  74319. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  74325. /**
  74326. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  74332. /**
  74333. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  74339. /**
  74340. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74346. /**
  74347. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74353. /**
  74354. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74360. /**
  74361. * Set a vec2 array in the shader from a number array.
  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. setArray2(name: string, value: number[]): ShaderMaterial;
  74367. /**
  74368. * Set a vec3 array in the shader from a number array.
  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. setArray3(name: string, value: number[]): ShaderMaterial;
  74374. private _checkCache;
  74375. /**
  74376. * Checks if the material is ready to render the requested mesh
  74377. * @param mesh Define the mesh to render
  74378. * @param useInstances Define whether or not the material is used with instances
  74379. * @returns true if ready, otherwise false
  74380. */
  74381. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74382. /**
  74383. * Binds the world matrix to the material
  74384. * @param world defines the world transformation matrix
  74385. */
  74386. bindOnlyWorldMatrix(world: Matrix): void;
  74387. /**
  74388. * Binds the material to the mesh
  74389. * @param world defines the world transformation matrix
  74390. * @param mesh defines the mesh to bind the material to
  74391. */
  74392. bind(world: Matrix, mesh?: Mesh): void;
  74393. /**
  74394. * Gets the active textures from the material
  74395. * @returns an array of textures
  74396. */
  74397. getActiveTextures(): BaseTexture[];
  74398. /**
  74399. * Specifies if the material uses a texture
  74400. * @param texture defines the texture to check against the material
  74401. * @returns a boolean specifying if the material uses the texture
  74402. */
  74403. hasTexture(texture: BaseTexture): boolean;
  74404. /**
  74405. * Makes a duplicate of the material, and gives it a new name
  74406. * @param name defines the new name for the duplicated material
  74407. * @returns the cloned material
  74408. */
  74409. clone(name: string): ShaderMaterial;
  74410. /**
  74411. * Disposes the material
  74412. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74413. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74414. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74415. */
  74416. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74417. /**
  74418. * Serializes this material in a JSON representation
  74419. * @returns the serialized material object
  74420. */
  74421. serialize(): any;
  74422. /**
  74423. * Creates a shader material from parsed shader material data
  74424. * @param source defines the JSON represnetation of the material
  74425. * @param scene defines the hosting scene
  74426. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74427. * @returns a new material
  74428. */
  74429. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74430. }
  74431. }
  74432. declare module BABYLON {
  74433. /** @hidden */
  74434. export var colorPixelShader: {
  74435. name: string;
  74436. shader: string;
  74437. };
  74438. }
  74439. declare module BABYLON {
  74440. /** @hidden */
  74441. export var colorVertexShader: {
  74442. name: string;
  74443. shader: string;
  74444. };
  74445. }
  74446. declare module BABYLON {
  74447. /**
  74448. * Line mesh
  74449. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74450. */
  74451. export class LinesMesh extends Mesh {
  74452. /**
  74453. * If vertex color should be applied to the mesh
  74454. */
  74455. useVertexColor?: boolean | undefined;
  74456. /**
  74457. * If vertex alpha should be applied to the mesh
  74458. */
  74459. useVertexAlpha?: boolean | undefined;
  74460. /**
  74461. * Color of the line (Default: White)
  74462. */
  74463. color: Color3;
  74464. /**
  74465. * Alpha of the line (Default: 1)
  74466. */
  74467. alpha: number;
  74468. /**
  74469. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74470. * This margin is expressed in world space coordinates, so its value may vary.
  74471. * Default value is 0.1
  74472. */
  74473. intersectionThreshold: number;
  74474. private _colorShader;
  74475. /**
  74476. * Creates a new LinesMesh
  74477. * @param name defines the name
  74478. * @param scene defines the hosting scene
  74479. * @param parent defines the parent mesh if any
  74480. * @param source defines the optional source LinesMesh used to clone data from
  74481. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74482. * When false, achieved by calling a clone(), also passing False.
  74483. * This will make creation of children, recursive.
  74484. * @param useVertexColor defines if this LinesMesh supports vertex color
  74485. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74486. */
  74487. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74488. /**
  74489. * If vertex color should be applied to the mesh
  74490. */
  74491. useVertexColor?: boolean | undefined,
  74492. /**
  74493. * If vertex alpha should be applied to the mesh
  74494. */
  74495. useVertexAlpha?: boolean | undefined);
  74496. /**
  74497. * Returns the string "LineMesh"
  74498. */
  74499. getClassName(): string;
  74500. /**
  74501. * @hidden
  74502. */
  74503. /**
  74504. * @hidden
  74505. */
  74506. material: Material;
  74507. /**
  74508. * @hidden
  74509. */
  74510. readonly checkCollisions: boolean;
  74511. /** @hidden */
  74512. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74513. /** @hidden */
  74514. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74515. /**
  74516. * Disposes of the line mesh
  74517. * @param doNotRecurse If children should be disposed
  74518. */
  74519. dispose(doNotRecurse?: boolean): void;
  74520. /**
  74521. * Returns a new LineMesh object cloned from the current one.
  74522. */
  74523. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74524. /**
  74525. * Creates a new InstancedLinesMesh object from the mesh model.
  74526. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74527. * @param name defines the name of the new instance
  74528. * @returns a new InstancedLinesMesh
  74529. */
  74530. createInstance(name: string): InstancedLinesMesh;
  74531. }
  74532. /**
  74533. * Creates an instance based on a source LinesMesh
  74534. */
  74535. export class InstancedLinesMesh extends InstancedMesh {
  74536. /**
  74537. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74538. * This margin is expressed in world space coordinates, so its value may vary.
  74539. * Initilized with the intersectionThreshold value of the source LinesMesh
  74540. */
  74541. intersectionThreshold: number;
  74542. constructor(name: string, source: LinesMesh);
  74543. /**
  74544. * Returns the string "InstancedLinesMesh".
  74545. */
  74546. getClassName(): string;
  74547. }
  74548. }
  74549. declare module BABYLON {
  74550. /**
  74551. * Mesh representing the gorund
  74552. */
  74553. export class GroundMesh extends Mesh {
  74554. /** If octree should be generated */
  74555. generateOctree: boolean;
  74556. private _heightQuads;
  74557. /** @hidden */
  74558. _subdivisionsX: number;
  74559. /** @hidden */
  74560. _subdivisionsY: number;
  74561. /** @hidden */
  74562. _width: number;
  74563. /** @hidden */
  74564. _height: number;
  74565. /** @hidden */
  74566. _minX: number;
  74567. /** @hidden */
  74568. _maxX: number;
  74569. /** @hidden */
  74570. _minZ: number;
  74571. /** @hidden */
  74572. _maxZ: number;
  74573. constructor(name: string, scene: Scene);
  74574. /**
  74575. * "GroundMesh"
  74576. * @returns "GroundMesh"
  74577. */
  74578. getClassName(): string;
  74579. /**
  74580. * The minimum of x and y subdivisions
  74581. */
  74582. readonly subdivisions: number;
  74583. /**
  74584. * X subdivisions
  74585. */
  74586. readonly subdivisionsX: number;
  74587. /**
  74588. * Y subdivisions
  74589. */
  74590. readonly subdivisionsY: number;
  74591. /**
  74592. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  74593. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  74594. * @param chunksCount the number of subdivisions for x and y
  74595. * @param octreeBlocksSize (Default: 32)
  74596. */
  74597. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  74598. /**
  74599. * Returns a height (y) value in the Worl system :
  74600. * the ground altitude at the coordinates (x, z) expressed in the World system.
  74601. * @param x x coordinate
  74602. * @param z z coordinate
  74603. * @returns the ground y position if (x, z) are outside the ground surface.
  74604. */
  74605. getHeightAtCoordinates(x: number, z: number): number;
  74606. /**
  74607. * Returns a normalized vector (Vector3) orthogonal to the ground
  74608. * at the ground coordinates (x, z) expressed in the World system.
  74609. * @param x x coordinate
  74610. * @param z z coordinate
  74611. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  74612. */
  74613. getNormalAtCoordinates(x: number, z: number): Vector3;
  74614. /**
  74615. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  74616. * at the ground coordinates (x, z) expressed in the World system.
  74617. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  74618. * @param x x coordinate
  74619. * @param z z coordinate
  74620. * @param ref vector to store the result
  74621. * @returns the GroundMesh.
  74622. */
  74623. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  74624. /**
  74625. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  74626. * if the ground has been updated.
  74627. * This can be used in the render loop.
  74628. * @returns the GroundMesh.
  74629. */
  74630. updateCoordinateHeights(): GroundMesh;
  74631. private _getFacetAt;
  74632. private _initHeightQuads;
  74633. private _computeHeightQuads;
  74634. /**
  74635. * Serializes this ground mesh
  74636. * @param serializationObject object to write serialization to
  74637. */
  74638. serialize(serializationObject: any): void;
  74639. /**
  74640. * Parses a serialized ground mesh
  74641. * @param parsedMesh the serialized mesh
  74642. * @param scene the scene to create the ground mesh in
  74643. * @returns the created ground mesh
  74644. */
  74645. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  74646. }
  74647. }
  74648. declare module BABYLON {
  74649. /**
  74650. * Interface for Physics-Joint data
  74651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74652. */
  74653. export interface PhysicsJointData {
  74654. /**
  74655. * The main pivot of the joint
  74656. */
  74657. mainPivot?: Vector3;
  74658. /**
  74659. * The connected pivot of the joint
  74660. */
  74661. connectedPivot?: Vector3;
  74662. /**
  74663. * The main axis of the joint
  74664. */
  74665. mainAxis?: Vector3;
  74666. /**
  74667. * The connected axis of the joint
  74668. */
  74669. connectedAxis?: Vector3;
  74670. /**
  74671. * The collision of the joint
  74672. */
  74673. collision?: boolean;
  74674. /**
  74675. * Native Oimo/Cannon/Energy data
  74676. */
  74677. nativeParams?: any;
  74678. }
  74679. /**
  74680. * This is a holder class for the physics joint created by the physics plugin
  74681. * It holds a set of functions to control the underlying joint
  74682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74683. */
  74684. export class PhysicsJoint {
  74685. /**
  74686. * The type of the physics joint
  74687. */
  74688. type: number;
  74689. /**
  74690. * The data for the physics joint
  74691. */
  74692. jointData: PhysicsJointData;
  74693. private _physicsJoint;
  74694. protected _physicsPlugin: IPhysicsEnginePlugin;
  74695. /**
  74696. * Initializes the physics joint
  74697. * @param type The type of the physics joint
  74698. * @param jointData The data for the physics joint
  74699. */
  74700. constructor(
  74701. /**
  74702. * The type of the physics joint
  74703. */
  74704. type: number,
  74705. /**
  74706. * The data for the physics joint
  74707. */
  74708. jointData: PhysicsJointData);
  74709. /**
  74710. * Gets the physics joint
  74711. */
  74712. /**
  74713. * Sets the physics joint
  74714. */
  74715. physicsJoint: any;
  74716. /**
  74717. * Sets the physics plugin
  74718. */
  74719. physicsPlugin: IPhysicsEnginePlugin;
  74720. /**
  74721. * Execute a function that is physics-plugin specific.
  74722. * @param {Function} func the function that will be executed.
  74723. * It accepts two parameters: the physics world and the physics joint
  74724. */
  74725. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  74726. /**
  74727. * Distance-Joint type
  74728. */
  74729. static DistanceJoint: number;
  74730. /**
  74731. * Hinge-Joint type
  74732. */
  74733. static HingeJoint: number;
  74734. /**
  74735. * Ball-and-Socket joint type
  74736. */
  74737. static BallAndSocketJoint: number;
  74738. /**
  74739. * Wheel-Joint type
  74740. */
  74741. static WheelJoint: number;
  74742. /**
  74743. * Slider-Joint type
  74744. */
  74745. static SliderJoint: number;
  74746. /**
  74747. * Prismatic-Joint type
  74748. */
  74749. static PrismaticJoint: number;
  74750. /**
  74751. * Universal-Joint type
  74752. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  74753. */
  74754. static UniversalJoint: number;
  74755. /**
  74756. * Hinge-Joint 2 type
  74757. */
  74758. static Hinge2Joint: number;
  74759. /**
  74760. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  74761. */
  74762. static PointToPointJoint: number;
  74763. /**
  74764. * Spring-Joint type
  74765. */
  74766. static SpringJoint: number;
  74767. /**
  74768. * Lock-Joint type
  74769. */
  74770. static LockJoint: number;
  74771. }
  74772. /**
  74773. * A class representing a physics distance joint
  74774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74775. */
  74776. export class DistanceJoint extends PhysicsJoint {
  74777. /**
  74778. *
  74779. * @param jointData The data for the Distance-Joint
  74780. */
  74781. constructor(jointData: DistanceJointData);
  74782. /**
  74783. * Update the predefined distance.
  74784. * @param maxDistance The maximum preferred distance
  74785. * @param minDistance The minimum preferred distance
  74786. */
  74787. updateDistance(maxDistance: number, minDistance?: number): void;
  74788. }
  74789. /**
  74790. * Represents a Motor-Enabled Joint
  74791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74792. */
  74793. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  74794. /**
  74795. * Initializes the Motor-Enabled Joint
  74796. * @param type The type of the joint
  74797. * @param jointData The physica joint data for the joint
  74798. */
  74799. constructor(type: number, jointData: PhysicsJointData);
  74800. /**
  74801. * Set the motor values.
  74802. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74803. * @param force the force to apply
  74804. * @param maxForce max force for this motor.
  74805. */
  74806. setMotor(force?: number, maxForce?: number): void;
  74807. /**
  74808. * Set the motor's limits.
  74809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74810. * @param upperLimit The upper limit of the motor
  74811. * @param lowerLimit The lower limit of the motor
  74812. */
  74813. setLimit(upperLimit: number, lowerLimit?: number): void;
  74814. }
  74815. /**
  74816. * This class represents a single physics Hinge-Joint
  74817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74818. */
  74819. export class HingeJoint extends MotorEnabledJoint {
  74820. /**
  74821. * Initializes the Hinge-Joint
  74822. * @param jointData The joint data for the Hinge-Joint
  74823. */
  74824. constructor(jointData: PhysicsJointData);
  74825. /**
  74826. * Set the motor values.
  74827. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74828. * @param {number} force the force to apply
  74829. * @param {number} maxForce max force for this motor.
  74830. */
  74831. setMotor(force?: number, maxForce?: number): void;
  74832. /**
  74833. * Set the motor's limits.
  74834. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74835. * @param upperLimit The upper limit of the motor
  74836. * @param lowerLimit The lower limit of the motor
  74837. */
  74838. setLimit(upperLimit: number, lowerLimit?: number): void;
  74839. }
  74840. /**
  74841. * This class represents a dual hinge physics joint (same as wheel joint)
  74842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74843. */
  74844. export class Hinge2Joint extends MotorEnabledJoint {
  74845. /**
  74846. * Initializes the Hinge2-Joint
  74847. * @param jointData The joint data for the Hinge2-Joint
  74848. */
  74849. constructor(jointData: PhysicsJointData);
  74850. /**
  74851. * Set the motor values.
  74852. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74853. * @param {number} force the force to apply
  74854. * @param {number} maxForce max force for this motor.
  74855. * @param {motorIndex} the motor's index, 0 or 1.
  74856. */
  74857. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74858. /**
  74859. * Set the motor limits.
  74860. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74861. * @param {number} upperLimit the upper limit
  74862. * @param {number} lowerLimit lower limit
  74863. * @param {motorIndex} the motor's index, 0 or 1.
  74864. */
  74865. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74866. }
  74867. /**
  74868. * Interface for a motor enabled joint
  74869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74870. */
  74871. export interface IMotorEnabledJoint {
  74872. /**
  74873. * Physics joint
  74874. */
  74875. physicsJoint: any;
  74876. /**
  74877. * Sets the motor of the motor-enabled joint
  74878. * @param force The force of the motor
  74879. * @param maxForce The maximum force of the motor
  74880. * @param motorIndex The index of the motor
  74881. */
  74882. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74883. /**
  74884. * Sets the limit of the motor
  74885. * @param upperLimit The upper limit of the motor
  74886. * @param lowerLimit The lower limit of the motor
  74887. * @param motorIndex The index of the motor
  74888. */
  74889. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74890. }
  74891. /**
  74892. * Joint data for a Distance-Joint
  74893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74894. */
  74895. export interface DistanceJointData extends PhysicsJointData {
  74896. /**
  74897. * Max distance the 2 joint objects can be apart
  74898. */
  74899. maxDistance: number;
  74900. }
  74901. /**
  74902. * Joint data from a spring joint
  74903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74904. */
  74905. export interface SpringJointData extends PhysicsJointData {
  74906. /**
  74907. * Length of the spring
  74908. */
  74909. length: number;
  74910. /**
  74911. * Stiffness of the spring
  74912. */
  74913. stiffness: number;
  74914. /**
  74915. * Damping of the spring
  74916. */
  74917. damping: number;
  74918. /** this callback will be called when applying the force to the impostors. */
  74919. forceApplicationCallback: () => void;
  74920. }
  74921. }
  74922. declare module BABYLON {
  74923. /**
  74924. * Interface used to describe a physics joint
  74925. */
  74926. export interface PhysicsImpostorJoint {
  74927. /** Defines the main impostor to which the joint is linked */
  74928. mainImpostor: PhysicsImpostor;
  74929. /** Defines the impostor that is connected to the main impostor using this joint */
  74930. connectedImpostor: PhysicsImpostor;
  74931. /** Defines the joint itself */
  74932. joint: PhysicsJoint;
  74933. }
  74934. /** @hidden */
  74935. export interface IPhysicsEnginePlugin {
  74936. world: any;
  74937. name: string;
  74938. setGravity(gravity: Vector3): void;
  74939. setTimeStep(timeStep: number): void;
  74940. getTimeStep(): number;
  74941. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  74942. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74943. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74944. generatePhysicsBody(impostor: PhysicsImpostor): void;
  74945. removePhysicsBody(impostor: PhysicsImpostor): void;
  74946. generateJoint(joint: PhysicsImpostorJoint): void;
  74947. removeJoint(joint: PhysicsImpostorJoint): void;
  74948. isSupported(): boolean;
  74949. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  74950. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  74951. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74952. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74953. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74954. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74955. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  74956. getBodyMass(impostor: PhysicsImpostor): number;
  74957. getBodyFriction(impostor: PhysicsImpostor): number;
  74958. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  74959. getBodyRestitution(impostor: PhysicsImpostor): number;
  74960. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  74961. sleepBody(impostor: PhysicsImpostor): void;
  74962. wakeUpBody(impostor: PhysicsImpostor): void;
  74963. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  74964. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  74965. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74966. getRadius(impostor: PhysicsImpostor): number;
  74967. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  74968. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  74969. dispose(): void;
  74970. }
  74971. /**
  74972. * Interface used to define a physics engine
  74973. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  74974. */
  74975. export interface IPhysicsEngine {
  74976. /**
  74977. * Gets the gravity vector used by the simulation
  74978. */
  74979. gravity: Vector3;
  74980. /**
  74981. * Sets the gravity vector used by the simulation
  74982. * @param gravity defines the gravity vector to use
  74983. */
  74984. setGravity(gravity: Vector3): void;
  74985. /**
  74986. * Set the time step of the physics engine.
  74987. * Default is 1/60.
  74988. * To slow it down, enter 1/600 for example.
  74989. * To speed it up, 1/30
  74990. * @param newTimeStep the new timestep to apply to this world.
  74991. */
  74992. setTimeStep(newTimeStep: number): void;
  74993. /**
  74994. * Get the time step of the physics engine.
  74995. * @returns the current time step
  74996. */
  74997. getTimeStep(): number;
  74998. /**
  74999. * Release all resources
  75000. */
  75001. dispose(): void;
  75002. /**
  75003. * Gets the name of the current physics plugin
  75004. * @returns the name of the plugin
  75005. */
  75006. getPhysicsPluginName(): string;
  75007. /**
  75008. * Adding a new impostor for the impostor tracking.
  75009. * This will be done by the impostor itself.
  75010. * @param impostor the impostor to add
  75011. */
  75012. addImpostor(impostor: PhysicsImpostor): void;
  75013. /**
  75014. * Remove an impostor from the engine.
  75015. * This impostor and its mesh will not longer be updated by the physics engine.
  75016. * @param impostor the impostor to remove
  75017. */
  75018. removeImpostor(impostor: PhysicsImpostor): void;
  75019. /**
  75020. * Add a joint to the physics engine
  75021. * @param mainImpostor defines the main impostor to which the joint is added.
  75022. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75023. * @param joint defines the joint that will connect both impostors.
  75024. */
  75025. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75026. /**
  75027. * Removes a joint from the simulation
  75028. * @param mainImpostor defines the impostor used with the joint
  75029. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75030. * @param joint defines the joint to remove
  75031. */
  75032. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75033. /**
  75034. * Gets the current plugin used to run the simulation
  75035. * @returns current plugin
  75036. */
  75037. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75038. /**
  75039. * Gets the list of physic impostors
  75040. * @returns an array of PhysicsImpostor
  75041. */
  75042. getImpostors(): Array<PhysicsImpostor>;
  75043. /**
  75044. * Gets the impostor for a physics enabled object
  75045. * @param object defines the object impersonated by the impostor
  75046. * @returns the PhysicsImpostor or null if not found
  75047. */
  75048. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75049. /**
  75050. * Gets the impostor for a physics body object
  75051. * @param body defines physics body used by the impostor
  75052. * @returns the PhysicsImpostor or null if not found
  75053. */
  75054. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75055. /**
  75056. * Called by the scene. No need to call it.
  75057. * @param delta defines the timespam between frames
  75058. */
  75059. _step(delta: number): void;
  75060. }
  75061. }
  75062. declare module BABYLON {
  75063. /**
  75064. * The interface for the physics imposter parameters
  75065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75066. */
  75067. export interface PhysicsImpostorParameters {
  75068. /**
  75069. * The mass of the physics imposter
  75070. */
  75071. mass: number;
  75072. /**
  75073. * The friction of the physics imposter
  75074. */
  75075. friction?: number;
  75076. /**
  75077. * The coefficient of restitution of the physics imposter
  75078. */
  75079. restitution?: number;
  75080. /**
  75081. * The native options of the physics imposter
  75082. */
  75083. nativeOptions?: any;
  75084. /**
  75085. * Specifies if the parent should be ignored
  75086. */
  75087. ignoreParent?: boolean;
  75088. /**
  75089. * Specifies if bi-directional transformations should be disabled
  75090. */
  75091. disableBidirectionalTransformation?: boolean;
  75092. }
  75093. /**
  75094. * Interface for a physics-enabled object
  75095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75096. */
  75097. export interface IPhysicsEnabledObject {
  75098. /**
  75099. * The position of the physics-enabled object
  75100. */
  75101. position: Vector3;
  75102. /**
  75103. * The rotation of the physics-enabled object
  75104. */
  75105. rotationQuaternion: Nullable<Quaternion>;
  75106. /**
  75107. * The scale of the physics-enabled object
  75108. */
  75109. scaling: Vector3;
  75110. /**
  75111. * The rotation of the physics-enabled object
  75112. */
  75113. rotation?: Vector3;
  75114. /**
  75115. * The parent of the physics-enabled object
  75116. */
  75117. parent?: any;
  75118. /**
  75119. * The bounding info of the physics-enabled object
  75120. * @returns The bounding info of the physics-enabled object
  75121. */
  75122. getBoundingInfo(): BoundingInfo;
  75123. /**
  75124. * Computes the world matrix
  75125. * @param force Specifies if the world matrix should be computed by force
  75126. * @returns A world matrix
  75127. */
  75128. computeWorldMatrix(force: boolean): Matrix;
  75129. /**
  75130. * Gets the world matrix
  75131. * @returns A world matrix
  75132. */
  75133. getWorldMatrix?(): Matrix;
  75134. /**
  75135. * Gets the child meshes
  75136. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75137. * @returns An array of abstract meshes
  75138. */
  75139. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75140. /**
  75141. * Gets the vertex data
  75142. * @param kind The type of vertex data
  75143. * @returns A nullable array of numbers, or a float32 array
  75144. */
  75145. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75146. /**
  75147. * Gets the indices from the mesh
  75148. * @returns A nullable array of index arrays
  75149. */
  75150. getIndices?(): Nullable<IndicesArray>;
  75151. /**
  75152. * Gets the scene from the mesh
  75153. * @returns the indices array or null
  75154. */
  75155. getScene?(): Scene;
  75156. /**
  75157. * Gets the absolute position from the mesh
  75158. * @returns the absolute position
  75159. */
  75160. getAbsolutePosition(): Vector3;
  75161. /**
  75162. * Gets the absolute pivot point from the mesh
  75163. * @returns the absolute pivot point
  75164. */
  75165. getAbsolutePivotPoint(): Vector3;
  75166. /**
  75167. * Rotates the mesh
  75168. * @param axis The axis of rotation
  75169. * @param amount The amount of rotation
  75170. * @param space The space of the rotation
  75171. * @returns The rotation transform node
  75172. */
  75173. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75174. /**
  75175. * Translates the mesh
  75176. * @param axis The axis of translation
  75177. * @param distance The distance of translation
  75178. * @param space The space of the translation
  75179. * @returns The transform node
  75180. */
  75181. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75182. /**
  75183. * Sets the absolute position of the mesh
  75184. * @param absolutePosition The absolute position of the mesh
  75185. * @returns The transform node
  75186. */
  75187. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75188. /**
  75189. * Gets the class name of the mesh
  75190. * @returns The class name
  75191. */
  75192. getClassName(): string;
  75193. }
  75194. /**
  75195. * Represents a physics imposter
  75196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75197. */
  75198. export class PhysicsImpostor {
  75199. /**
  75200. * The physics-enabled object used as the physics imposter
  75201. */
  75202. object: IPhysicsEnabledObject;
  75203. /**
  75204. * The type of the physics imposter
  75205. */
  75206. type: number;
  75207. private _options;
  75208. private _scene?;
  75209. /**
  75210. * The default object size of the imposter
  75211. */
  75212. static DEFAULT_OBJECT_SIZE: Vector3;
  75213. /**
  75214. * The identity quaternion of the imposter
  75215. */
  75216. static IDENTITY_QUATERNION: Quaternion;
  75217. /** @hidden */
  75218. _pluginData: any;
  75219. private _physicsEngine;
  75220. private _physicsBody;
  75221. private _bodyUpdateRequired;
  75222. private _onBeforePhysicsStepCallbacks;
  75223. private _onAfterPhysicsStepCallbacks;
  75224. /** @hidden */
  75225. _onPhysicsCollideCallbacks: Array<{
  75226. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  75227. otherImpostors: Array<PhysicsImpostor>;
  75228. }>;
  75229. private _deltaPosition;
  75230. private _deltaRotation;
  75231. private _deltaRotationConjugated;
  75232. private _parent;
  75233. private _isDisposed;
  75234. private static _tmpVecs;
  75235. private static _tmpQuat;
  75236. /**
  75237. * Specifies if the physics imposter is disposed
  75238. */
  75239. readonly isDisposed: boolean;
  75240. /**
  75241. * Gets the mass of the physics imposter
  75242. */
  75243. mass: number;
  75244. /**
  75245. * Gets the coefficient of friction
  75246. */
  75247. /**
  75248. * Sets the coefficient of friction
  75249. */
  75250. friction: number;
  75251. /**
  75252. * Gets the coefficient of restitution
  75253. */
  75254. /**
  75255. * Sets the coefficient of restitution
  75256. */
  75257. restitution: number;
  75258. /**
  75259. * The unique id of the physics imposter
  75260. * set by the physics engine when adding this impostor to the array
  75261. */
  75262. uniqueId: number;
  75263. private _joints;
  75264. /**
  75265. * Initializes the physics imposter
  75266. * @param object The physics-enabled object used as the physics imposter
  75267. * @param type The type of the physics imposter
  75268. * @param _options The options for the physics imposter
  75269. * @param _scene The Babylon scene
  75270. */
  75271. constructor(
  75272. /**
  75273. * The physics-enabled object used as the physics imposter
  75274. */
  75275. object: IPhysicsEnabledObject,
  75276. /**
  75277. * The type of the physics imposter
  75278. */
  75279. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  75280. /**
  75281. * This function will completly initialize this impostor.
  75282. * It will create a new body - but only if this mesh has no parent.
  75283. * If it has, this impostor will not be used other than to define the impostor
  75284. * of the child mesh.
  75285. * @hidden
  75286. */
  75287. _init(): void;
  75288. private _getPhysicsParent;
  75289. /**
  75290. * Should a new body be generated.
  75291. * @returns boolean specifying if body initialization is required
  75292. */
  75293. isBodyInitRequired(): boolean;
  75294. /**
  75295. * Sets the updated scaling
  75296. * @param updated Specifies if the scaling is updated
  75297. */
  75298. setScalingUpdated(): void;
  75299. /**
  75300. * Force a regeneration of this or the parent's impostor's body.
  75301. * Use under cautious - This will remove all joints already implemented.
  75302. */
  75303. forceUpdate(): void;
  75304. /**
  75305. * Gets the body that holds this impostor. Either its own, or its parent.
  75306. */
  75307. /**
  75308. * Set the physics body. Used mainly by the physics engine/plugin
  75309. */
  75310. physicsBody: any;
  75311. /**
  75312. * Get the parent of the physics imposter
  75313. * @returns Physics imposter or null
  75314. */
  75315. /**
  75316. * Sets the parent of the physics imposter
  75317. */
  75318. parent: Nullable<PhysicsImpostor>;
  75319. /**
  75320. * Resets the update flags
  75321. */
  75322. resetUpdateFlags(): void;
  75323. /**
  75324. * Gets the object extend size
  75325. * @returns the object extend size
  75326. */
  75327. getObjectExtendSize(): Vector3;
  75328. /**
  75329. * Gets the object center
  75330. * @returns The object center
  75331. */
  75332. getObjectCenter(): Vector3;
  75333. /**
  75334. * Get a specific parametes from the options parameter
  75335. * @param paramName The object parameter name
  75336. * @returns The object parameter
  75337. */
  75338. getParam(paramName: string): any;
  75339. /**
  75340. * Sets a specific parameter in the options given to the physics plugin
  75341. * @param paramName The parameter name
  75342. * @param value The value of the parameter
  75343. */
  75344. setParam(paramName: string, value: number): void;
  75345. /**
  75346. * Specifically change the body's mass option. Won't recreate the physics body object
  75347. * @param mass The mass of the physics imposter
  75348. */
  75349. setMass(mass: number): void;
  75350. /**
  75351. * Gets the linear velocity
  75352. * @returns linear velocity or null
  75353. */
  75354. getLinearVelocity(): Nullable<Vector3>;
  75355. /**
  75356. * Sets the linear velocity
  75357. * @param velocity linear velocity or null
  75358. */
  75359. setLinearVelocity(velocity: Nullable<Vector3>): void;
  75360. /**
  75361. * Gets the angular velocity
  75362. * @returns angular velocity or null
  75363. */
  75364. getAngularVelocity(): Nullable<Vector3>;
  75365. /**
  75366. * Sets the angular velocity
  75367. * @param velocity The velocity or null
  75368. */
  75369. setAngularVelocity(velocity: Nullable<Vector3>): void;
  75370. /**
  75371. * Execute a function with the physics plugin native code
  75372. * Provide a function the will have two variables - the world object and the physics body object
  75373. * @param func The function to execute with the physics plugin native code
  75374. */
  75375. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  75376. /**
  75377. * Register a function that will be executed before the physics world is stepping forward
  75378. * @param func The function to execute before the physics world is stepped forward
  75379. */
  75380. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75381. /**
  75382. * Unregister a function that will be executed before the physics world is stepping forward
  75383. * @param func The function to execute before the physics world is stepped forward
  75384. */
  75385. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75386. /**
  75387. * Register a function that will be executed after the physics step
  75388. * @param func The function to execute after physics step
  75389. */
  75390. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75391. /**
  75392. * Unregisters a function that will be executed after the physics step
  75393. * @param func The function to execute after physics step
  75394. */
  75395. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75396. /**
  75397. * register a function that will be executed when this impostor collides against a different body
  75398. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  75399. * @param func Callback that is executed on collision
  75400. */
  75401. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  75402. /**
  75403. * Unregisters the physics imposter on contact
  75404. * @param collideAgainst The physics object to collide against
  75405. * @param func Callback to execute on collision
  75406. */
  75407. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  75408. private _tmpQuat;
  75409. private _tmpQuat2;
  75410. /**
  75411. * Get the parent rotation
  75412. * @returns The parent rotation
  75413. */
  75414. getParentsRotation(): Quaternion;
  75415. /**
  75416. * this function is executed by the physics engine.
  75417. */
  75418. beforeStep: () => void;
  75419. /**
  75420. * this function is executed by the physics engine
  75421. */
  75422. afterStep: () => void;
  75423. /**
  75424. * Legacy collision detection event support
  75425. */
  75426. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  75427. /**
  75428. * event and body object due to cannon's event-based architecture.
  75429. */
  75430. onCollide: (e: {
  75431. body: any;
  75432. }) => void;
  75433. /**
  75434. * Apply a force
  75435. * @param force The force to apply
  75436. * @param contactPoint The contact point for the force
  75437. * @returns The physics imposter
  75438. */
  75439. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75440. /**
  75441. * Apply an impulse
  75442. * @param force The impulse force
  75443. * @param contactPoint The contact point for the impulse force
  75444. * @returns The physics imposter
  75445. */
  75446. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75447. /**
  75448. * A help function to create a joint
  75449. * @param otherImpostor A physics imposter used to create a joint
  75450. * @param jointType The type of joint
  75451. * @param jointData The data for the joint
  75452. * @returns The physics imposter
  75453. */
  75454. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  75455. /**
  75456. * Add a joint to this impostor with a different impostor
  75457. * @param otherImpostor A physics imposter used to add a joint
  75458. * @param joint The joint to add
  75459. * @returns The physics imposter
  75460. */
  75461. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  75462. /**
  75463. * Will keep this body still, in a sleep mode.
  75464. * @returns the physics imposter
  75465. */
  75466. sleep(): PhysicsImpostor;
  75467. /**
  75468. * Wake the body up.
  75469. * @returns The physics imposter
  75470. */
  75471. wakeUp(): PhysicsImpostor;
  75472. /**
  75473. * Clones the physics imposter
  75474. * @param newObject The physics imposter clones to this physics-enabled object
  75475. * @returns A nullable physics imposter
  75476. */
  75477. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75478. /**
  75479. * Disposes the physics imposter
  75480. */
  75481. dispose(): void;
  75482. /**
  75483. * Sets the delta position
  75484. * @param position The delta position amount
  75485. */
  75486. setDeltaPosition(position: Vector3): void;
  75487. /**
  75488. * Sets the delta rotation
  75489. * @param rotation The delta rotation amount
  75490. */
  75491. setDeltaRotation(rotation: Quaternion): void;
  75492. /**
  75493. * Gets the box size of the physics imposter and stores the result in the input parameter
  75494. * @param result Stores the box size
  75495. * @returns The physics imposter
  75496. */
  75497. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  75498. /**
  75499. * Gets the radius of the physics imposter
  75500. * @returns Radius of the physics imposter
  75501. */
  75502. getRadius(): number;
  75503. /**
  75504. * Sync a bone with this impostor
  75505. * @param bone The bone to sync to the impostor.
  75506. * @param boneMesh The mesh that the bone is influencing.
  75507. * @param jointPivot The pivot of the joint / bone in local space.
  75508. * @param distToJoint Optional distance from the impostor to the joint.
  75509. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75510. */
  75511. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  75512. /**
  75513. * Sync impostor to a bone
  75514. * @param bone The bone that the impostor will be synced to.
  75515. * @param boneMesh The mesh that the bone is influencing.
  75516. * @param jointPivot The pivot of the joint / bone in local space.
  75517. * @param distToJoint Optional distance from the impostor to the joint.
  75518. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75519. * @param boneAxis Optional vector3 axis the bone is aligned with
  75520. */
  75521. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  75522. /**
  75523. * No-Imposter type
  75524. */
  75525. static NoImpostor: number;
  75526. /**
  75527. * Sphere-Imposter type
  75528. */
  75529. static SphereImpostor: number;
  75530. /**
  75531. * Box-Imposter type
  75532. */
  75533. static BoxImpostor: number;
  75534. /**
  75535. * Plane-Imposter type
  75536. */
  75537. static PlaneImpostor: number;
  75538. /**
  75539. * Mesh-imposter type
  75540. */
  75541. static MeshImpostor: number;
  75542. /**
  75543. * Cylinder-Imposter type
  75544. */
  75545. static CylinderImpostor: number;
  75546. /**
  75547. * Particle-Imposter type
  75548. */
  75549. static ParticleImpostor: number;
  75550. /**
  75551. * Heightmap-Imposter type
  75552. */
  75553. static HeightmapImpostor: number;
  75554. }
  75555. }
  75556. declare module BABYLON {
  75557. /**
  75558. * Class used to represent a specific level of detail of a mesh
  75559. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75560. */
  75561. export class MeshLODLevel {
  75562. /** Defines the distance where this level should star being displayed */
  75563. distance: number;
  75564. /** Defines the mesh to use to render this level */
  75565. mesh: Nullable<Mesh>;
  75566. /**
  75567. * Creates a new LOD level
  75568. * @param distance defines the distance where this level should star being displayed
  75569. * @param mesh defines the mesh to use to render this level
  75570. */
  75571. constructor(
  75572. /** Defines the distance where this level should star being displayed */
  75573. distance: number,
  75574. /** Defines the mesh to use to render this level */
  75575. mesh: Nullable<Mesh>);
  75576. }
  75577. /**
  75578. * @hidden
  75579. **/
  75580. export class _CreationDataStorage {
  75581. closePath?: boolean;
  75582. closeArray?: boolean;
  75583. idx: number[];
  75584. dashSize: number;
  75585. gapSize: number;
  75586. path3D: Path3D;
  75587. pathArray: Vector3[][];
  75588. arc: number;
  75589. radius: number;
  75590. cap: number;
  75591. tessellation: number;
  75592. }
  75593. /**
  75594. * @hidden
  75595. **/
  75596. class _InstanceDataStorage {
  75597. visibleInstances: any;
  75598. renderIdForInstances: number[];
  75599. batchCache: _InstancesBatch;
  75600. instancesBufferSize: number;
  75601. instancesBuffer: Nullable<Buffer>;
  75602. instancesData: Float32Array;
  75603. overridenInstanceCount: number;
  75604. }
  75605. /**
  75606. * @hidden
  75607. **/
  75608. export class _InstancesBatch {
  75609. mustReturn: boolean;
  75610. visibleInstances: Nullable<InstancedMesh[]>[];
  75611. renderSelf: boolean[];
  75612. }
  75613. /**
  75614. * Class used to represent renderable models
  75615. */
  75616. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  75617. /**
  75618. * Mesh side orientation : usually the external or front surface
  75619. */
  75620. static readonly FRONTSIDE: number;
  75621. /**
  75622. * Mesh side orientation : usually the internal or back surface
  75623. */
  75624. static readonly BACKSIDE: number;
  75625. /**
  75626. * Mesh side orientation : both internal and external or front and back surfaces
  75627. */
  75628. static readonly DOUBLESIDE: number;
  75629. /**
  75630. * Mesh side orientation : by default, `FRONTSIDE`
  75631. */
  75632. static readonly DEFAULTSIDE: number;
  75633. /**
  75634. * Mesh cap setting : no cap
  75635. */
  75636. static readonly NO_CAP: number;
  75637. /**
  75638. * Mesh cap setting : one cap at the beginning of the mesh
  75639. */
  75640. static readonly CAP_START: number;
  75641. /**
  75642. * Mesh cap setting : one cap at the end of the mesh
  75643. */
  75644. static readonly CAP_END: number;
  75645. /**
  75646. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  75647. */
  75648. static readonly CAP_ALL: number;
  75649. /**
  75650. * Gets the default side orientation.
  75651. * @param orientation the orientation to value to attempt to get
  75652. * @returns the default orientation
  75653. * @hidden
  75654. */
  75655. static _GetDefaultSideOrientation(orientation?: number): number;
  75656. private _onBeforeRenderObservable;
  75657. private _onBeforeBindObservable;
  75658. private _onAfterRenderObservable;
  75659. private _onBeforeDrawObservable;
  75660. /**
  75661. * An event triggered before rendering the mesh
  75662. */
  75663. readonly onBeforeRenderObservable: Observable<Mesh>;
  75664. /**
  75665. * An event triggered before binding the mesh
  75666. */
  75667. readonly onBeforeBindObservable: Observable<Mesh>;
  75668. /**
  75669. * An event triggered after rendering the mesh
  75670. */
  75671. readonly onAfterRenderObservable: Observable<Mesh>;
  75672. /**
  75673. * An event triggered before drawing the mesh
  75674. */
  75675. readonly onBeforeDrawObservable: Observable<Mesh>;
  75676. private _onBeforeDrawObserver;
  75677. /**
  75678. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  75679. */
  75680. onBeforeDraw: () => void;
  75681. /**
  75682. * Gets the delay loading state of the mesh (when delay loading is turned on)
  75683. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  75684. */
  75685. delayLoadState: number;
  75686. /**
  75687. * Gets the list of instances created from this mesh
  75688. * it is not supposed to be modified manually.
  75689. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  75690. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75691. */
  75692. instances: InstancedMesh[];
  75693. /**
  75694. * Gets the file containing delay loading data for this mesh
  75695. */
  75696. delayLoadingFile: string;
  75697. /** @hidden */
  75698. _binaryInfo: any;
  75699. private _LODLevels;
  75700. /**
  75701. * User defined function used to change how LOD level selection is done
  75702. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75703. */
  75704. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  75705. private _morphTargetManager;
  75706. /**
  75707. * Gets or sets the morph target manager
  75708. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75709. */
  75710. morphTargetManager: Nullable<MorphTargetManager>;
  75711. /** @hidden */
  75712. _creationDataStorage: Nullable<_CreationDataStorage>;
  75713. /** @hidden */
  75714. _geometry: Nullable<Geometry>;
  75715. /** @hidden */
  75716. _delayInfo: Array<string>;
  75717. /** @hidden */
  75718. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  75719. /** @hidden */
  75720. _instanceDataStorage: _InstanceDataStorage;
  75721. private _effectiveMaterial;
  75722. /** @hidden */
  75723. _shouldGenerateFlatShading: boolean;
  75724. private _preActivateId;
  75725. /** @hidden */
  75726. _originalBuilderSideOrientation: number;
  75727. /**
  75728. * Use this property to change the original side orientation defined at construction time
  75729. */
  75730. overrideMaterialSideOrientation: Nullable<number>;
  75731. private _areNormalsFrozen;
  75732. private _sourcePositions;
  75733. private _sourceNormals;
  75734. private _source;
  75735. private meshMap;
  75736. /**
  75737. * Gets the source mesh (the one used to clone this one from)
  75738. */
  75739. readonly source: Nullable<Mesh>;
  75740. /**
  75741. * Gets or sets a boolean indicating that this mesh does not use index buffer
  75742. */
  75743. isUnIndexed: boolean;
  75744. /**
  75745. * @constructor
  75746. * @param name The value used by scene.getMeshByName() to do a lookup.
  75747. * @param scene The scene to add this mesh to.
  75748. * @param parent The parent of this mesh, if it has one
  75749. * @param source An optional Mesh from which geometry is shared, cloned.
  75750. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75751. * When false, achieved by calling a clone(), also passing False.
  75752. * This will make creation of children, recursive.
  75753. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  75754. */
  75755. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  75756. /**
  75757. * Gets the class name
  75758. * @returns the string "Mesh".
  75759. */
  75760. getClassName(): string;
  75761. /** @hidden */
  75762. readonly _isMesh: boolean;
  75763. /**
  75764. * Returns a description of this mesh
  75765. * @param fullDetails define if full details about this mesh must be used
  75766. * @returns a descriptive string representing this mesh
  75767. */
  75768. toString(fullDetails?: boolean): string;
  75769. /** @hidden */
  75770. _unBindEffect(): void;
  75771. /**
  75772. * Gets a boolean indicating if this mesh has LOD
  75773. */
  75774. readonly hasLODLevels: boolean;
  75775. /**
  75776. * Gets the list of MeshLODLevel associated with the current mesh
  75777. * @returns an array of MeshLODLevel
  75778. */
  75779. getLODLevels(): MeshLODLevel[];
  75780. private _sortLODLevels;
  75781. /**
  75782. * Add a mesh as LOD level triggered at the given distance.
  75783. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75784. * @param distance The distance from the center of the object to show this level
  75785. * @param mesh The mesh to be added as LOD level (can be null)
  75786. * @return This mesh (for chaining)
  75787. */
  75788. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  75789. /**
  75790. * Returns the LOD level mesh at the passed distance or null if not found.
  75791. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75792. * @param distance The distance from the center of the object to show this level
  75793. * @returns a Mesh or `null`
  75794. */
  75795. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  75796. /**
  75797. * Remove a mesh from the LOD array
  75798. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75799. * @param mesh defines the mesh to be removed
  75800. * @return This mesh (for chaining)
  75801. */
  75802. removeLODLevel(mesh: Mesh): Mesh;
  75803. /**
  75804. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  75805. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75806. * @param camera defines the camera to use to compute distance
  75807. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  75808. * @return This mesh (for chaining)
  75809. */
  75810. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  75811. /**
  75812. * Gets the mesh internal Geometry object
  75813. */
  75814. readonly geometry: Nullable<Geometry>;
  75815. /**
  75816. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  75817. * @returns the total number of vertices
  75818. */
  75819. getTotalVertices(): number;
  75820. /**
  75821. * Returns the content of an associated vertex buffer
  75822. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75823. * - VertexBuffer.PositionKind
  75824. * - VertexBuffer.UVKind
  75825. * - VertexBuffer.UV2Kind
  75826. * - VertexBuffer.UV3Kind
  75827. * - VertexBuffer.UV4Kind
  75828. * - VertexBuffer.UV5Kind
  75829. * - VertexBuffer.UV6Kind
  75830. * - VertexBuffer.ColorKind
  75831. * - VertexBuffer.MatricesIndicesKind
  75832. * - VertexBuffer.MatricesIndicesExtraKind
  75833. * - VertexBuffer.MatricesWeightsKind
  75834. * - VertexBuffer.MatricesWeightsExtraKind
  75835. * @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
  75836. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  75837. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  75838. */
  75839. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  75840. /**
  75841. * Returns the mesh VertexBuffer object from the requested `kind`
  75842. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75843. * - VertexBuffer.PositionKind
  75844. * - VertexBuffer.UVKind
  75845. * - VertexBuffer.UV2Kind
  75846. * - VertexBuffer.UV3Kind
  75847. * - VertexBuffer.UV4Kind
  75848. * - VertexBuffer.UV5Kind
  75849. * - VertexBuffer.UV6Kind
  75850. * - VertexBuffer.ColorKind
  75851. * - VertexBuffer.MatricesIndicesKind
  75852. * - VertexBuffer.MatricesIndicesExtraKind
  75853. * - VertexBuffer.MatricesWeightsKind
  75854. * - VertexBuffer.MatricesWeightsExtraKind
  75855. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  75856. */
  75857. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  75858. /**
  75859. * Tests if a specific vertex buffer is associated with this mesh
  75860. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75861. * - VertexBuffer.PositionKind
  75862. * - VertexBuffer.UVKind
  75863. * - VertexBuffer.UV2Kind
  75864. * - VertexBuffer.UV3Kind
  75865. * - VertexBuffer.UV4Kind
  75866. * - VertexBuffer.UV5Kind
  75867. * - VertexBuffer.UV6Kind
  75868. * - VertexBuffer.ColorKind
  75869. * - VertexBuffer.MatricesIndicesKind
  75870. * - VertexBuffer.MatricesIndicesExtraKind
  75871. * - VertexBuffer.MatricesWeightsKind
  75872. * - VertexBuffer.MatricesWeightsExtraKind
  75873. * @returns a boolean
  75874. */
  75875. isVerticesDataPresent(kind: string): boolean;
  75876. /**
  75877. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  75878. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75879. * - VertexBuffer.PositionKind
  75880. * - VertexBuffer.UVKind
  75881. * - VertexBuffer.UV2Kind
  75882. * - VertexBuffer.UV3Kind
  75883. * - VertexBuffer.UV4Kind
  75884. * - VertexBuffer.UV5Kind
  75885. * - VertexBuffer.UV6Kind
  75886. * - VertexBuffer.ColorKind
  75887. * - VertexBuffer.MatricesIndicesKind
  75888. * - VertexBuffer.MatricesIndicesExtraKind
  75889. * - VertexBuffer.MatricesWeightsKind
  75890. * - VertexBuffer.MatricesWeightsExtraKind
  75891. * @returns a boolean
  75892. */
  75893. isVertexBufferUpdatable(kind: string): boolean;
  75894. /**
  75895. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  75896. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75897. * - VertexBuffer.PositionKind
  75898. * - VertexBuffer.UVKind
  75899. * - VertexBuffer.UV2Kind
  75900. * - VertexBuffer.UV3Kind
  75901. * - VertexBuffer.UV4Kind
  75902. * - VertexBuffer.UV5Kind
  75903. * - VertexBuffer.UV6Kind
  75904. * - VertexBuffer.ColorKind
  75905. * - VertexBuffer.MatricesIndicesKind
  75906. * - VertexBuffer.MatricesIndicesExtraKind
  75907. * - VertexBuffer.MatricesWeightsKind
  75908. * - VertexBuffer.MatricesWeightsExtraKind
  75909. * @returns an array of strings
  75910. */
  75911. getVerticesDataKinds(): string[];
  75912. /**
  75913. * Returns a positive integer : the total number of indices in this mesh geometry.
  75914. * @returns the numner of indices or zero if the mesh has no geometry.
  75915. */
  75916. getTotalIndices(): number;
  75917. /**
  75918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75919. * @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.
  75920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  75921. * @returns the indices array or an empty array if the mesh has no geometry
  75922. */
  75923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  75924. readonly isBlocked: boolean;
  75925. /**
  75926. * Determine if the current mesh is ready to be rendered
  75927. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75928. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  75929. * @returns true if all associated assets are ready (material, textures, shaders)
  75930. */
  75931. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  75932. /**
  75933. * 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.
  75934. */
  75935. readonly areNormalsFrozen: boolean;
  75936. /**
  75937. * 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.
  75938. * @returns the current mesh
  75939. */
  75940. freezeNormals(): Mesh;
  75941. /**
  75942. * 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
  75943. * @returns the current mesh
  75944. */
  75945. unfreezeNormals(): Mesh;
  75946. /**
  75947. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  75948. */
  75949. overridenInstanceCount: number;
  75950. /** @hidden */
  75951. _preActivate(): Mesh;
  75952. /** @hidden */
  75953. _preActivateForIntermediateRendering(renderId: number): Mesh;
  75954. /** @hidden */
  75955. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  75956. /**
  75957. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75958. * This means the mesh underlying bounding box and sphere are recomputed.
  75959. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75960. * @returns the current mesh
  75961. */
  75962. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  75963. /** @hidden */
  75964. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  75965. /**
  75966. * This function will subdivide the mesh into multiple submeshes
  75967. * @param count defines the expected number of submeshes
  75968. */
  75969. subdivide(count: number): void;
  75970. /**
  75971. * Copy a FloatArray into a specific associated vertex buffer
  75972. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75973. * - VertexBuffer.PositionKind
  75974. * - VertexBuffer.UVKind
  75975. * - VertexBuffer.UV2Kind
  75976. * - VertexBuffer.UV3Kind
  75977. * - VertexBuffer.UV4Kind
  75978. * - VertexBuffer.UV5Kind
  75979. * - VertexBuffer.UV6Kind
  75980. * - VertexBuffer.ColorKind
  75981. * - VertexBuffer.MatricesIndicesKind
  75982. * - VertexBuffer.MatricesIndicesExtraKind
  75983. * - VertexBuffer.MatricesWeightsKind
  75984. * - VertexBuffer.MatricesWeightsExtraKind
  75985. * @param data defines the data source
  75986. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75987. * @param stride defines the data stride size (can be null)
  75988. * @returns the current mesh
  75989. */
  75990. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75991. /**
  75992. * Flags an associated vertex buffer as updatable
  75993. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  75994. * - VertexBuffer.PositionKind
  75995. * - VertexBuffer.UVKind
  75996. * - VertexBuffer.UV2Kind
  75997. * - VertexBuffer.UV3Kind
  75998. * - VertexBuffer.UV4Kind
  75999. * - VertexBuffer.UV5Kind
  76000. * - VertexBuffer.UV6Kind
  76001. * - VertexBuffer.ColorKind
  76002. * - VertexBuffer.MatricesIndicesKind
  76003. * - VertexBuffer.MatricesIndicesExtraKind
  76004. * - VertexBuffer.MatricesWeightsKind
  76005. * - VertexBuffer.MatricesWeightsExtraKind
  76006. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76007. */
  76008. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76009. /**
  76010. * Sets the mesh global Vertex Buffer
  76011. * @param buffer defines the buffer to use
  76012. * @returns the current mesh
  76013. */
  76014. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76015. /**
  76016. * Update a specific associated vertex buffer
  76017. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76018. * - VertexBuffer.PositionKind
  76019. * - VertexBuffer.UVKind
  76020. * - VertexBuffer.UV2Kind
  76021. * - VertexBuffer.UV3Kind
  76022. * - VertexBuffer.UV4Kind
  76023. * - VertexBuffer.UV5Kind
  76024. * - VertexBuffer.UV6Kind
  76025. * - VertexBuffer.ColorKind
  76026. * - VertexBuffer.MatricesIndicesKind
  76027. * - VertexBuffer.MatricesIndicesExtraKind
  76028. * - VertexBuffer.MatricesWeightsKind
  76029. * - VertexBuffer.MatricesWeightsExtraKind
  76030. * @param data defines the data source
  76031. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76032. * @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)
  76033. * @returns the current mesh
  76034. */
  76035. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76036. /**
  76037. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76038. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76039. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76040. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76041. * @returns the current mesh
  76042. */
  76043. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76044. /**
  76045. * Creates a un-shared specific occurence of the geometry for the mesh.
  76046. * @returns the current mesh
  76047. */
  76048. makeGeometryUnique(): Mesh;
  76049. /**
  76050. * Set the index buffer of this mesh
  76051. * @param indices defines the source data
  76052. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76053. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76054. * @returns the current mesh
  76055. */
  76056. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76057. /**
  76058. * Update the current index buffer
  76059. * @param indices defines the source data
  76060. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76061. * @returns the current mesh
  76062. */
  76063. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  76064. /**
  76065. * Invert the geometry to move from a right handed system to a left handed one.
  76066. * @returns the current mesh
  76067. */
  76068. toLeftHanded(): Mesh;
  76069. /** @hidden */
  76070. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76071. /** @hidden */
  76072. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  76073. /**
  76074. * Registers for this mesh a javascript function called just before the rendering process
  76075. * @param func defines the function to call before rendering this mesh
  76076. * @returns the current mesh
  76077. */
  76078. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76079. /**
  76080. * Disposes a previously registered javascript function called before the rendering
  76081. * @param func defines the function to remove
  76082. * @returns the current mesh
  76083. */
  76084. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76085. /**
  76086. * Registers for this mesh a javascript function called just after the rendering is complete
  76087. * @param func defines the function to call after rendering this mesh
  76088. * @returns the current mesh
  76089. */
  76090. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76091. /**
  76092. * Disposes a previously registered javascript function called after the rendering.
  76093. * @param func defines the function to remove
  76094. * @returns the current mesh
  76095. */
  76096. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76097. /** @hidden */
  76098. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  76099. /** @hidden */
  76100. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  76101. /** @hidden */
  76102. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  76103. /**
  76104. * 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
  76105. * @param subMesh defines the subMesh to render
  76106. * @param enableAlphaMode defines if alpha mode can be changed
  76107. * @returns the current mesh
  76108. */
  76109. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  76110. private _onBeforeDraw;
  76111. /**
  76112. * Renormalize the mesh and patch it up if there are no weights
  76113. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  76114. * However in the case of zero weights then we set just a single influence to 1.
  76115. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  76116. */
  76117. cleanMatrixWeights(): void;
  76118. private normalizeSkinFourWeights;
  76119. private normalizeSkinWeightsAndExtra;
  76120. /**
  76121. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  76122. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  76123. * the user know there was an issue with importing the mesh
  76124. * @returns a validation object with skinned, valid and report string
  76125. */
  76126. validateSkinning(): {
  76127. skinned: boolean;
  76128. valid: boolean;
  76129. report: string;
  76130. };
  76131. /** @hidden */
  76132. _checkDelayState(): Mesh;
  76133. private _queueLoad;
  76134. /**
  76135. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  76136. * A mesh is in the frustum if its bounding box intersects the frustum
  76137. * @param frustumPlanes defines the frustum to test
  76138. * @returns true if the mesh is in the frustum planes
  76139. */
  76140. isInFrustum(frustumPlanes: Plane[]): boolean;
  76141. /**
  76142. * Sets the mesh material by the material or multiMaterial `id` property
  76143. * @param id is a string identifying the material or the multiMaterial
  76144. * @returns the current mesh
  76145. */
  76146. setMaterialByID(id: string): Mesh;
  76147. /**
  76148. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  76149. * @returns an array of IAnimatable
  76150. */
  76151. getAnimatables(): IAnimatable[];
  76152. /**
  76153. * Modifies the mesh geometry according to the passed transformation matrix.
  76154. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  76155. * The mesh normals are modified using the same transformation.
  76156. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76157. * @param transform defines the transform matrix to use
  76158. * @see http://doc.babylonjs.com/resources/baking_transformations
  76159. * @returns the current mesh
  76160. */
  76161. bakeTransformIntoVertices(transform: Matrix): Mesh;
  76162. /**
  76163. * Modifies the mesh geometry according to its own current World Matrix.
  76164. * The mesh World Matrix is then reset.
  76165. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  76166. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76167. * @see http://doc.babylonjs.com/resources/baking_transformations
  76168. * @returns the current mesh
  76169. */
  76170. bakeCurrentTransformIntoVertices(): Mesh;
  76171. /** @hidden */
  76172. readonly _positions: Nullable<Vector3[]>;
  76173. /** @hidden */
  76174. _resetPointsArrayCache(): Mesh;
  76175. /** @hidden */
  76176. _generatePointsArray(): boolean;
  76177. /**
  76178. * Returns a new Mesh object generated from the current mesh properties.
  76179. * This method must not get confused with createInstance()
  76180. * @param name is a string, the name given to the new mesh
  76181. * @param newParent can be any Node object (default `null`)
  76182. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  76183. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  76184. * @returns a new mesh
  76185. */
  76186. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  76187. /**
  76188. * Releases resources associated with this mesh.
  76189. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76190. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76191. */
  76192. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76193. /**
  76194. * Modifies the mesh geometry according to a displacement map.
  76195. * 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.
  76196. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76197. * @param url is a string, the URL from the image file is to be downloaded.
  76198. * @param minHeight is the lower limit of the displacement.
  76199. * @param maxHeight is the upper limit of the displacement.
  76200. * @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.
  76201. * @param uvOffset is an optional vector2 used to offset UV.
  76202. * @param uvScale is an optional vector2 used to scale UV.
  76203. * @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.
  76204. * @returns the Mesh.
  76205. */
  76206. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76207. /**
  76208. * Modifies the mesh geometry according to a displacementMap buffer.
  76209. * 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.
  76210. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76211. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  76212. * @param heightMapWidth is the width of the buffer image.
  76213. * @param heightMapHeight is the height of the buffer image.
  76214. * @param minHeight is the lower limit of the displacement.
  76215. * @param maxHeight is the upper limit of the displacement.
  76216. * @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.
  76217. * @param uvOffset is an optional vector2 used to offset UV.
  76218. * @param uvScale is an optional vector2 used to scale UV.
  76219. * @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.
  76220. * @returns the Mesh.
  76221. */
  76222. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76223. /**
  76224. * Modify the mesh to get a flat shading rendering.
  76225. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  76226. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  76227. * @returns current mesh
  76228. */
  76229. convertToFlatShadedMesh(): Mesh;
  76230. /**
  76231. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  76232. * In other words, more vertices, no more indices and a single bigger VBO.
  76233. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  76234. * @returns current mesh
  76235. */
  76236. convertToUnIndexedMesh(): Mesh;
  76237. /**
  76238. * Inverses facet orientations.
  76239. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  76240. * @param flipNormals will also inverts the normals
  76241. * @returns current mesh
  76242. */
  76243. flipFaces(flipNormals?: boolean): Mesh;
  76244. /** @hidden */
  76245. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  76246. /** @hidden */
  76247. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  76248. /**
  76249. * Creates a new InstancedMesh object from the mesh model.
  76250. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76251. * @param name defines the name of the new instance
  76252. * @returns a new InstancedMesh
  76253. */
  76254. createInstance(name: string): InstancedMesh;
  76255. /**
  76256. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  76257. * After this call, all the mesh instances have the same submeshes than the current mesh.
  76258. * @returns the current mesh
  76259. */
  76260. synchronizeInstances(): Mesh;
  76261. /**
  76262. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  76263. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  76264. * This should be used together with the simplification to avoid disappearing triangles.
  76265. * @param successCallback an optional success callback to be called after the optimization finished.
  76266. * @returns the current mesh
  76267. */
  76268. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  76269. /**
  76270. * Serialize current mesh
  76271. * @param serializationObject defines the object which will receive the serialization data
  76272. */
  76273. serialize(serializationObject: any): void;
  76274. /** @hidden */
  76275. _syncGeometryWithMorphTargetManager(): void;
  76276. /** @hidden */
  76277. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  76278. /**
  76279. * Returns a new Mesh object parsed from the source provided.
  76280. * @param parsedMesh is the source
  76281. * @param scene defines the hosting scene
  76282. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  76283. * @returns a new Mesh
  76284. */
  76285. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  76286. /**
  76287. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  76288. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76289. * @param name defines the name of the mesh to create
  76290. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  76291. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  76292. * @param closePath creates a seam between the first and the last points of each path of the path array
  76293. * @param offset is taken in account only if the `pathArray` is containing a single path
  76294. * @param scene defines the hosting scene
  76295. * @param updatable defines if the mesh must be flagged as updatable
  76296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76297. * @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)
  76298. * @returns a new Mesh
  76299. */
  76300. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76301. /**
  76302. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  76303. * @param name defines the name of the mesh to create
  76304. * @param radius sets the radius size (float) of the polygon (default 0.5)
  76305. * @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
  76306. * @param scene defines the hosting scene
  76307. * @param updatable defines if the mesh must be flagged as updatable
  76308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76309. * @returns a new Mesh
  76310. */
  76311. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76312. /**
  76313. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  76314. * @param name defines the name of the mesh to create
  76315. * @param size sets the size (float) of each box side (default 1)
  76316. * @param scene defines the hosting scene
  76317. * @param updatable defines if the mesh must be flagged as updatable
  76318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76319. * @returns a new Mesh
  76320. */
  76321. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76322. /**
  76323. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  76324. * @param name defines the name of the mesh to create
  76325. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  76326. * @param diameter sets the diameter size (float) of the sphere (default 1)
  76327. * @param scene defines the hosting scene
  76328. * @param updatable defines if the mesh must be flagged as updatable
  76329. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76330. * @returns a new Mesh
  76331. */
  76332. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76333. /**
  76334. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  76335. * @param name defines the name of the mesh to create
  76336. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  76337. * @param diameterTop set the top cap diameter (floats, default 1)
  76338. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  76339. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  76340. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  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 CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  76347. /**
  76348. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  76351. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  76352. * @param tessellation sets the number of torus sides (postive integer, default 16)
  76353. * @param scene defines the hosting scene
  76354. * @param updatable defines if the mesh must be flagged as updatable
  76355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76356. * @returns a new Mesh
  76357. */
  76358. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76359. /**
  76360. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  76361. * @param name defines the name of the mesh to create
  76362. * @param radius sets the global radius size (float) of the torus knot (default 2)
  76363. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  76364. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  76365. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  76366. * @param p the number of windings on X axis (positive integers, default 2)
  76367. * @param q the number of windings on Y axis (positive integers, default 3)
  76368. * @param scene defines the hosting scene
  76369. * @param updatable defines if the mesh must be flagged as updatable
  76370. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76371. * @returns a new Mesh
  76372. */
  76373. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76374. /**
  76375. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  76376. * @param name defines the name of the mesh to create
  76377. * @param points is an array successive Vector3
  76378. * @param scene defines the hosting scene
  76379. * @param updatable defines if the mesh must be flagged as updatable
  76380. * @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).
  76381. * @returns a new Mesh
  76382. */
  76383. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  76384. /**
  76385. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  76386. * @param name defines the name of the mesh to create
  76387. * @param points is an array successive Vector3
  76388. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  76389. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76390. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  76391. * @param scene defines the hosting scene
  76392. * @param updatable defines if the mesh must be flagged as updatable
  76393. * @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)
  76394. * @returns a new Mesh
  76395. */
  76396. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  76397. /**
  76398. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  76399. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  76400. * 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.
  76401. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76402. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76403. * Remember you can only change the shape positions, not their number when updating a polygon.
  76404. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  76405. * @param name defines the name of the mesh to create
  76406. * @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
  76407. * @param scene defines the hosting scene
  76408. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76409. * @param updatable defines if the mesh must be flagged as updatable
  76410. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76411. * @param earcutInjection can be used to inject your own earcut reference
  76412. * @returns a new Mesh
  76413. */
  76414. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76415. /**
  76416. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  76417. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  76418. * @param name defines the name of the mesh to create
  76419. * @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
  76420. * @param depth defines the height of extrusion
  76421. * @param scene defines the hosting scene
  76422. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76423. * @param updatable defines if the mesh must be flagged as updatable
  76424. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76425. * @param earcutInjection can be used to inject your own earcut reference
  76426. * @returns a new Mesh
  76427. */
  76428. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76429. /**
  76430. * Creates an extruded shape mesh.
  76431. * 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
  76432. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76433. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76434. * @param name defines the name of the mesh to create
  76435. * @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
  76436. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76437. * @param scale is the value to scale the shape
  76438. * @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
  76439. * @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
  76440. * @param scene defines the hosting scene
  76441. * @param updatable defines if the mesh must be flagged as updatable
  76442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76443. * @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)
  76444. * @returns a new Mesh
  76445. */
  76446. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76447. /**
  76448. * Creates an custom extruded shape mesh.
  76449. * The custom extrusion is a parametric shape.
  76450. * It has no predefined shape. Its final shape will depend on the input parameters.
  76451. * Please consider using the same method from the MeshBuilder class instead
  76452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76453. * @param name defines the name of the mesh to create
  76454. * @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
  76455. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76456. * @param scaleFunction is a custom Javascript function called on each path point
  76457. * @param rotationFunction is a custom Javascript function called on each path point
  76458. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  76459. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  76460. * @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
  76461. * @param scene defines the hosting scene
  76462. * @param updatable defines if the mesh must be flagged as updatable
  76463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76464. * @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)
  76465. * @returns a new Mesh
  76466. */
  76467. 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;
  76468. /**
  76469. * Creates lathe mesh.
  76470. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  76471. * Please consider using the same method from the MeshBuilder class instead
  76472. * @param name defines the name of the mesh to create
  76473. * @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
  76474. * @param radius is the radius value of the lathe
  76475. * @param tessellation is the side number of the lathe.
  76476. * @param scene defines the hosting scene
  76477. * @param updatable defines if the mesh must be flagged as updatable
  76478. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76479. * @returns a new Mesh
  76480. */
  76481. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76482. /**
  76483. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  76484. * @param name defines the name of the mesh to create
  76485. * @param size sets the size (float) of both sides of the plane at once (default 1)
  76486. * @param scene defines the hosting scene
  76487. * @param updatable defines if the mesh must be flagged as updatable
  76488. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76489. * @returns a new Mesh
  76490. */
  76491. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76492. /**
  76493. * Creates a ground mesh.
  76494. * Please consider using the same method from the MeshBuilder class instead
  76495. * @param name defines the name of the mesh to create
  76496. * @param width set the width of the ground
  76497. * @param height set the height of the ground
  76498. * @param subdivisions sets the number of subdivisions per side
  76499. * @param scene defines the hosting scene
  76500. * @param updatable defines if the mesh must be flagged as updatable
  76501. * @returns a new Mesh
  76502. */
  76503. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  76504. /**
  76505. * Creates a tiled ground mesh.
  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 xmin set the ground minimum X coordinate
  76509. * @param zmin set the ground minimum Y coordinate
  76510. * @param xmax set the ground maximum X coordinate
  76511. * @param zmax set the ground maximum Z coordinate
  76512. * @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
  76513. * @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
  76514. * @param scene defines the hosting scene
  76515. * @param updatable defines if the mesh must be flagged as updatable
  76516. * @returns a new Mesh
  76517. */
  76518. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  76519. w: number;
  76520. h: number;
  76521. }, precision: {
  76522. w: number;
  76523. h: number;
  76524. }, scene: Scene, updatable?: boolean): Mesh;
  76525. /**
  76526. * Creates a ground mesh from a height map.
  76527. * Please consider using the same method from the MeshBuilder class instead
  76528. * @see http://doc.babylonjs.com/babylon101/height_map
  76529. * @param name defines the name of the mesh to create
  76530. * @param url sets the URL of the height map image resource
  76531. * @param width set the ground width size
  76532. * @param height set the ground height size
  76533. * @param subdivisions sets the number of subdivision per side
  76534. * @param minHeight is the minimum altitude on the ground
  76535. * @param maxHeight is the maximum altitude on the ground
  76536. * @param scene defines the hosting scene
  76537. * @param updatable defines if the mesh must be flagged as updatable
  76538. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  76539. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  76540. * @returns a new Mesh
  76541. */
  76542. 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;
  76543. /**
  76544. * Creates a tube mesh.
  76545. * The tube is a parametric shape.
  76546. * It has no predefined shape. Its final shape will depend on the input parameters.
  76547. * Please consider using the same method from the MeshBuilder class instead
  76548. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76549. * @param name defines the name of the mesh to create
  76550. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  76551. * @param radius sets the tube radius size
  76552. * @param tessellation is the number of sides on the tubular surface
  76553. * @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
  76554. * @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
  76555. * @param scene defines the hosting scene
  76556. * @param updatable defines if the mesh must be flagged as updatable
  76557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76558. * @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)
  76559. * @returns a new Mesh
  76560. */
  76561. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  76562. (i: number, distance: number): number;
  76563. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76564. /**
  76565. * Creates a polyhedron mesh.
  76566. * Please consider using the same method from the MeshBuilder class instead.
  76567. * * 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
  76568. * * The parameter `size` (positive float, default 1) sets the polygon size
  76569. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76570. * * 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`
  76571. * * 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
  76572. * * 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)`)
  76573. * * 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
  76574. * * 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
  76575. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76576. * * If you create a double-sided mesh, you can choose what parts of 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
  76577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76578. * @param name defines the name of the mesh to create
  76579. * @param options defines the options used to create the mesh
  76580. * @param scene defines the hosting scene
  76581. * @returns a new Mesh
  76582. */
  76583. static CreatePolyhedron(name: string, options: {
  76584. type?: number;
  76585. size?: number;
  76586. sizeX?: number;
  76587. sizeY?: number;
  76588. sizeZ?: number;
  76589. custom?: any;
  76590. faceUV?: Vector4[];
  76591. faceColors?: Color4[];
  76592. updatable?: boolean;
  76593. sideOrientation?: number;
  76594. }, scene: Scene): Mesh;
  76595. /**
  76596. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76597. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76598. * * 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`)
  76599. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76600. * * 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
  76601. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76602. * * If you create a double-sided mesh, you can choose what parts of 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
  76603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76604. * @param name defines the name of the mesh
  76605. * @param options defines the options used to create the mesh
  76606. * @param scene defines the hosting scene
  76607. * @returns a new Mesh
  76608. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76609. */
  76610. static CreateIcoSphere(name: string, options: {
  76611. radius?: number;
  76612. flat?: boolean;
  76613. subdivisions?: number;
  76614. sideOrientation?: number;
  76615. updatable?: boolean;
  76616. }, scene: Scene): Mesh;
  76617. /**
  76618. * Creates a decal mesh.
  76619. * Please consider using the same method from the MeshBuilder class instead.
  76620. * A decal is a mesh usually applied as a model onto the surface of another mesh
  76621. * @param name defines the name of the mesh
  76622. * @param sourceMesh defines the mesh receiving the decal
  76623. * @param position sets the position of the decal in world coordinates
  76624. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  76625. * @param size sets the decal scaling
  76626. * @param angle sets the angle to rotate the decal
  76627. * @returns a new Mesh
  76628. */
  76629. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  76630. /**
  76631. * Prepare internal position array for software CPU skinning
  76632. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  76633. */
  76634. setPositionsForCPUSkinning(): Float32Array;
  76635. /**
  76636. * Prepare internal normal array for software CPU skinning
  76637. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  76638. */
  76639. setNormalsForCPUSkinning(): Float32Array;
  76640. /**
  76641. * Updates the vertex buffer by applying transformation from the bones
  76642. * @param skeleton defines the skeleton to apply to current mesh
  76643. * @returns the current mesh
  76644. */
  76645. applySkeleton(skeleton: Skeleton): Mesh;
  76646. /**
  76647. * 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
  76648. * @param meshes defines the list of meshes to scan
  76649. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  76650. */
  76651. static MinMax(meshes: AbstractMesh[]): {
  76652. min: Vector3;
  76653. max: Vector3;
  76654. };
  76655. /**
  76656. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  76657. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  76658. * @returns a vector3
  76659. */
  76660. static Center(meshesOrMinMaxVector: {
  76661. min: Vector3;
  76662. max: Vector3;
  76663. } | AbstractMesh[]): Vector3;
  76664. /**
  76665. * Merge the array of meshes into a single mesh for performance reasons.
  76666. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  76667. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  76668. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  76669. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  76670. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  76671. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  76672. * @returns a new mesh
  76673. */
  76674. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  76675. /** @hidden */
  76676. addInstance(instance: InstancedMesh): void;
  76677. /** @hidden */
  76678. removeInstance(instance: InstancedMesh): void;
  76679. }
  76680. }
  76681. declare module BABYLON {
  76682. /**
  76683. * Base class for the main features of a material in Babylon.js
  76684. */
  76685. export class Material implements IAnimatable {
  76686. /**
  76687. * Returns the triangle fill mode
  76688. */
  76689. static readonly TriangleFillMode: number;
  76690. /**
  76691. * Returns the wireframe mode
  76692. */
  76693. static readonly WireFrameFillMode: number;
  76694. /**
  76695. * Returns the point fill mode
  76696. */
  76697. static readonly PointFillMode: number;
  76698. /**
  76699. * Returns the point list draw mode
  76700. */
  76701. static readonly PointListDrawMode: number;
  76702. /**
  76703. * Returns the line list draw mode
  76704. */
  76705. static readonly LineListDrawMode: number;
  76706. /**
  76707. * Returns the line loop draw mode
  76708. */
  76709. static readonly LineLoopDrawMode: number;
  76710. /**
  76711. * Returns the line strip draw mode
  76712. */
  76713. static readonly LineStripDrawMode: number;
  76714. /**
  76715. * Returns the triangle strip draw mode
  76716. */
  76717. static readonly TriangleStripDrawMode: number;
  76718. /**
  76719. * Returns the triangle fan draw mode
  76720. */
  76721. static readonly TriangleFanDrawMode: number;
  76722. /**
  76723. * Stores the clock-wise side orientation
  76724. */
  76725. static readonly ClockWiseSideOrientation: number;
  76726. /**
  76727. * Stores the counter clock-wise side orientation
  76728. */
  76729. static readonly CounterClockWiseSideOrientation: number;
  76730. /**
  76731. * The dirty texture flag value
  76732. */
  76733. static readonly TextureDirtyFlag: number;
  76734. /**
  76735. * The dirty light flag value
  76736. */
  76737. static readonly LightDirtyFlag: number;
  76738. /**
  76739. * The dirty fresnel flag value
  76740. */
  76741. static readonly FresnelDirtyFlag: number;
  76742. /**
  76743. * The dirty attribute flag value
  76744. */
  76745. static readonly AttributesDirtyFlag: number;
  76746. /**
  76747. * The dirty misc flag value
  76748. */
  76749. static readonly MiscDirtyFlag: number;
  76750. /**
  76751. * The all dirty flag value
  76752. */
  76753. static readonly AllDirtyFlag: number;
  76754. /**
  76755. * The ID of the material
  76756. */
  76757. id: string;
  76758. /**
  76759. * Gets or sets the unique id of the material
  76760. */
  76761. uniqueId: number;
  76762. /**
  76763. * The name of the material
  76764. */
  76765. name: string;
  76766. /**
  76767. * Gets or sets user defined metadata
  76768. */
  76769. metadata: any;
  76770. /**
  76771. * For internal use only. Please do not use.
  76772. */
  76773. reservedDataStore: any;
  76774. /**
  76775. * Specifies if the ready state should be checked on each call
  76776. */
  76777. checkReadyOnEveryCall: boolean;
  76778. /**
  76779. * Specifies if the ready state should be checked once
  76780. */
  76781. checkReadyOnlyOnce: boolean;
  76782. /**
  76783. * The state of the material
  76784. */
  76785. state: string;
  76786. /**
  76787. * The alpha value of the material
  76788. */
  76789. protected _alpha: number;
  76790. /**
  76791. * Sets the alpha value of the material
  76792. */
  76793. /**
  76794. * Gets the alpha value of the material
  76795. */
  76796. alpha: number;
  76797. /**
  76798. * Specifies if back face culling is enabled
  76799. */
  76800. protected _backFaceCulling: boolean;
  76801. /**
  76802. * Sets the back-face culling state
  76803. */
  76804. /**
  76805. * Gets the back-face culling state
  76806. */
  76807. backFaceCulling: boolean;
  76808. /**
  76809. * Stores the value for side orientation
  76810. */
  76811. sideOrientation: number;
  76812. /**
  76813. * Callback triggered when the material is compiled
  76814. */
  76815. onCompiled: (effect: Effect) => void;
  76816. /**
  76817. * Callback triggered when an error occurs
  76818. */
  76819. onError: (effect: Effect, errors: string) => void;
  76820. /**
  76821. * Callback triggered to get the render target textures
  76822. */
  76823. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  76824. /**
  76825. * Gets a boolean indicating that current material needs to register RTT
  76826. */
  76827. readonly hasRenderTargetTextures: boolean;
  76828. /**
  76829. * Specifies if the material should be serialized
  76830. */
  76831. doNotSerialize: boolean;
  76832. /**
  76833. * @hidden
  76834. */
  76835. _storeEffectOnSubMeshes: boolean;
  76836. /**
  76837. * Stores the animations for the material
  76838. */
  76839. animations: Array<Animation>;
  76840. /**
  76841. * An event triggered when the material is disposed
  76842. */
  76843. onDisposeObservable: Observable<Material>;
  76844. /**
  76845. * An observer which watches for dispose events
  76846. */
  76847. private _onDisposeObserver;
  76848. private _onUnBindObservable;
  76849. /**
  76850. * Called during a dispose event
  76851. */
  76852. onDispose: () => void;
  76853. private _onBindObservable;
  76854. /**
  76855. * An event triggered when the material is bound
  76856. */
  76857. readonly onBindObservable: Observable<AbstractMesh>;
  76858. /**
  76859. * An observer which watches for bind events
  76860. */
  76861. private _onBindObserver;
  76862. /**
  76863. * Called during a bind event
  76864. */
  76865. onBind: (Mesh: AbstractMesh) => void;
  76866. /**
  76867. * An event triggered when the material is unbound
  76868. */
  76869. readonly onUnBindObservable: Observable<Material>;
  76870. /**
  76871. * Stores the value of the alpha mode
  76872. */
  76873. private _alphaMode;
  76874. /**
  76875. * Sets the value of the alpha mode.
  76876. *
  76877. * | Value | Type | Description |
  76878. * | --- | --- | --- |
  76879. * | 0 | ALPHA_DISABLE | |
  76880. * | 1 | ALPHA_ADD | |
  76881. * | 2 | ALPHA_COMBINE | |
  76882. * | 3 | ALPHA_SUBTRACT | |
  76883. * | 4 | ALPHA_MULTIPLY | |
  76884. * | 5 | ALPHA_MAXIMIZED | |
  76885. * | 6 | ALPHA_ONEONE | |
  76886. * | 7 | ALPHA_PREMULTIPLIED | |
  76887. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  76888. * | 9 | ALPHA_INTERPOLATE | |
  76889. * | 10 | ALPHA_SCREENMODE | |
  76890. *
  76891. */
  76892. /**
  76893. * Gets the value of the alpha mode
  76894. */
  76895. alphaMode: number;
  76896. /**
  76897. * Stores the state of the need depth pre-pass value
  76898. */
  76899. private _needDepthPrePass;
  76900. /**
  76901. * Sets the need depth pre-pass value
  76902. */
  76903. /**
  76904. * Gets the depth pre-pass value
  76905. */
  76906. needDepthPrePass: boolean;
  76907. /**
  76908. * Specifies if depth writing should be disabled
  76909. */
  76910. disableDepthWrite: boolean;
  76911. /**
  76912. * Specifies if depth writing should be forced
  76913. */
  76914. forceDepthWrite: boolean;
  76915. /**
  76916. * Specifies if there should be a separate pass for culling
  76917. */
  76918. separateCullingPass: boolean;
  76919. /**
  76920. * Stores the state specifing if fog should be enabled
  76921. */
  76922. private _fogEnabled;
  76923. /**
  76924. * Sets the state for enabling fog
  76925. */
  76926. /**
  76927. * Gets the value of the fog enabled state
  76928. */
  76929. fogEnabled: boolean;
  76930. /**
  76931. * Stores the size of points
  76932. */
  76933. pointSize: number;
  76934. /**
  76935. * Stores the z offset value
  76936. */
  76937. zOffset: number;
  76938. /**
  76939. * Gets a value specifying if wireframe mode is enabled
  76940. */
  76941. /**
  76942. * Sets the state of wireframe mode
  76943. */
  76944. wireframe: boolean;
  76945. /**
  76946. * Gets the value specifying if point clouds are enabled
  76947. */
  76948. /**
  76949. * Sets the state of point cloud mode
  76950. */
  76951. pointsCloud: boolean;
  76952. /**
  76953. * Gets the material fill mode
  76954. */
  76955. /**
  76956. * Sets the material fill mode
  76957. */
  76958. fillMode: number;
  76959. /**
  76960. * @hidden
  76961. * Stores the effects for the material
  76962. */
  76963. _effect: Nullable<Effect>;
  76964. /**
  76965. * @hidden
  76966. * Specifies if the material was previously ready
  76967. */
  76968. _wasPreviouslyReady: boolean;
  76969. /**
  76970. * Specifies if uniform buffers should be used
  76971. */
  76972. private _useUBO;
  76973. /**
  76974. * Stores a reference to the scene
  76975. */
  76976. private _scene;
  76977. /**
  76978. * Stores the fill mode state
  76979. */
  76980. private _fillMode;
  76981. /**
  76982. * Specifies if the depth write state should be cached
  76983. */
  76984. private _cachedDepthWriteState;
  76985. /**
  76986. * Stores the uniform buffer
  76987. */
  76988. protected _uniformBuffer: UniformBuffer;
  76989. /** @hidden */
  76990. _indexInSceneMaterialArray: number;
  76991. /** @hidden */
  76992. meshMap: Nullable<{
  76993. [id: string]: AbstractMesh | undefined;
  76994. }>;
  76995. /**
  76996. * Creates a material instance
  76997. * @param name defines the name of the material
  76998. * @param scene defines the scene to reference
  76999. * @param doNotAdd specifies if the material should be added to the scene
  77000. */
  77001. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  77002. /**
  77003. * Returns a string representation of the current material
  77004. * @param fullDetails defines a boolean indicating which levels of logging is desired
  77005. * @returns a string with material information
  77006. */
  77007. toString(fullDetails?: boolean): string;
  77008. /**
  77009. * Gets the class name of the material
  77010. * @returns a string with the class name of the material
  77011. */
  77012. getClassName(): string;
  77013. /**
  77014. * Specifies if updates for the material been locked
  77015. */
  77016. readonly isFrozen: boolean;
  77017. /**
  77018. * Locks updates for the material
  77019. */
  77020. freeze(): void;
  77021. /**
  77022. * Unlocks updates for the material
  77023. */
  77024. unfreeze(): void;
  77025. /**
  77026. * Specifies if the material is ready to be used
  77027. * @param mesh defines the mesh to check
  77028. * @param useInstances specifies if instances should be used
  77029. * @returns a boolean indicating if the material is ready to be used
  77030. */
  77031. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77032. /**
  77033. * Specifies that the submesh is ready to be used
  77034. * @param mesh defines the mesh to check
  77035. * @param subMesh defines which submesh to check
  77036. * @param useInstances specifies that instances should be used
  77037. * @returns a boolean indicating that the submesh is ready or not
  77038. */
  77039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77040. /**
  77041. * Returns the material effect
  77042. * @returns the effect associated with the material
  77043. */
  77044. getEffect(): Nullable<Effect>;
  77045. /**
  77046. * Returns the current scene
  77047. * @returns a Scene
  77048. */
  77049. getScene(): Scene;
  77050. /**
  77051. * Specifies if the material will require alpha blending
  77052. * @returns a boolean specifying if alpha blending is needed
  77053. */
  77054. needAlphaBlending(): boolean;
  77055. /**
  77056. * Specifies if the mesh will require alpha blending
  77057. * @param mesh defines the mesh to check
  77058. * @returns a boolean specifying if alpha blending is needed for the mesh
  77059. */
  77060. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  77061. /**
  77062. * Specifies if this material should be rendered in alpha test mode
  77063. * @returns a boolean specifying if an alpha test is needed.
  77064. */
  77065. needAlphaTesting(): boolean;
  77066. /**
  77067. * Gets the texture used for the alpha test
  77068. * @returns the texture to use for alpha testing
  77069. */
  77070. getAlphaTestTexture(): Nullable<BaseTexture>;
  77071. /**
  77072. * Marks the material to indicate that it needs to be re-calculated
  77073. */
  77074. markDirty(): void;
  77075. /** @hidden */
  77076. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  77077. /**
  77078. * Binds the material to the mesh
  77079. * @param world defines the world transformation matrix
  77080. * @param mesh defines the mesh to bind the material to
  77081. */
  77082. bind(world: Matrix, mesh?: Mesh): void;
  77083. /**
  77084. * Binds the submesh to the material
  77085. * @param world defines the world transformation matrix
  77086. * @param mesh defines the mesh containing the submesh
  77087. * @param subMesh defines the submesh to bind the material to
  77088. */
  77089. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  77090. /**
  77091. * Binds the world matrix to the material
  77092. * @param world defines the world transformation matrix
  77093. */
  77094. bindOnlyWorldMatrix(world: Matrix): void;
  77095. /**
  77096. * Binds the scene's uniform buffer to the effect.
  77097. * @param effect defines the effect to bind to the scene uniform buffer
  77098. * @param sceneUbo defines the uniform buffer storing scene data
  77099. */
  77100. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  77101. /**
  77102. * Binds the view matrix to the effect
  77103. * @param effect defines the effect to bind the view matrix to
  77104. */
  77105. bindView(effect: Effect): void;
  77106. /**
  77107. * Binds the view projection matrix to the effect
  77108. * @param effect defines the effect to bind the view projection matrix to
  77109. */
  77110. bindViewProjection(effect: Effect): void;
  77111. /**
  77112. * Specifies if material alpha testing should be turned on for the mesh
  77113. * @param mesh defines the mesh to check
  77114. */
  77115. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  77116. /**
  77117. * Processes to execute after binding the material to a mesh
  77118. * @param mesh defines the rendered mesh
  77119. */
  77120. protected _afterBind(mesh?: Mesh): void;
  77121. /**
  77122. * Unbinds the material from the mesh
  77123. */
  77124. unbind(): void;
  77125. /**
  77126. * Gets the active textures from the material
  77127. * @returns an array of textures
  77128. */
  77129. getActiveTextures(): BaseTexture[];
  77130. /**
  77131. * Specifies if the material uses a texture
  77132. * @param texture defines the texture to check against the material
  77133. * @returns a boolean specifying if the material uses the texture
  77134. */
  77135. hasTexture(texture: BaseTexture): boolean;
  77136. /**
  77137. * Makes a duplicate of the material, and gives it a new name
  77138. * @param name defines the new name for the duplicated material
  77139. * @returns the cloned material
  77140. */
  77141. clone(name: string): Nullable<Material>;
  77142. /**
  77143. * Gets the meshes bound to the material
  77144. * @returns an array of meshes bound to the material
  77145. */
  77146. getBindedMeshes(): AbstractMesh[];
  77147. /**
  77148. * Force shader compilation
  77149. * @param mesh defines the mesh associated with this material
  77150. * @param onCompiled defines a function to execute once the material is compiled
  77151. * @param options defines the options to configure the compilation
  77152. */
  77153. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  77154. clipPlane: boolean;
  77155. }>): void;
  77156. /**
  77157. * Force shader compilation
  77158. * @param mesh defines the mesh that will use this material
  77159. * @param options defines additional options for compiling the shaders
  77160. * @returns a promise that resolves when the compilation completes
  77161. */
  77162. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  77163. clipPlane: boolean;
  77164. }>): Promise<void>;
  77165. private static readonly _ImageProcessingDirtyCallBack;
  77166. private static readonly _TextureDirtyCallBack;
  77167. private static readonly _FresnelDirtyCallBack;
  77168. private static readonly _MiscDirtyCallBack;
  77169. private static readonly _LightsDirtyCallBack;
  77170. private static readonly _AttributeDirtyCallBack;
  77171. private static _FresnelAndMiscDirtyCallBack;
  77172. private static _TextureAndMiscDirtyCallBack;
  77173. private static readonly _DirtyCallbackArray;
  77174. private static readonly _RunDirtyCallBacks;
  77175. /**
  77176. * Marks a define in the material to indicate that it needs to be re-computed
  77177. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  77178. */
  77179. markAsDirty(flag: number): void;
  77180. /**
  77181. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  77182. * @param func defines a function which checks material defines against the submeshes
  77183. */
  77184. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  77185. /**
  77186. * Indicates that image processing needs to be re-calculated for all submeshes
  77187. */
  77188. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  77189. /**
  77190. * Indicates that textures need to be re-calculated for all submeshes
  77191. */
  77192. protected _markAllSubMeshesAsTexturesDirty(): void;
  77193. /**
  77194. * Indicates that fresnel needs to be re-calculated for all submeshes
  77195. */
  77196. protected _markAllSubMeshesAsFresnelDirty(): void;
  77197. /**
  77198. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  77199. */
  77200. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  77201. /**
  77202. * Indicates that lights need to be re-calculated for all submeshes
  77203. */
  77204. protected _markAllSubMeshesAsLightsDirty(): void;
  77205. /**
  77206. * Indicates that attributes need to be re-calculated for all submeshes
  77207. */
  77208. protected _markAllSubMeshesAsAttributesDirty(): void;
  77209. /**
  77210. * Indicates that misc needs to be re-calculated for all submeshes
  77211. */
  77212. protected _markAllSubMeshesAsMiscDirty(): void;
  77213. /**
  77214. * Indicates that textures and misc need to be re-calculated for all submeshes
  77215. */
  77216. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  77217. /**
  77218. * Disposes the material
  77219. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77220. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77221. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77222. */
  77223. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77224. /** @hidden */
  77225. private releaseVertexArrayObject;
  77226. /**
  77227. * Serializes this material
  77228. * @returns the serialized material object
  77229. */
  77230. serialize(): any;
  77231. /**
  77232. * Creates a material from parsed material data
  77233. * @param parsedMaterial defines parsed material data
  77234. * @param scene defines the hosting scene
  77235. * @param rootUrl defines the root URL to use to load textures
  77236. * @returns a new material
  77237. */
  77238. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  77239. }
  77240. }
  77241. declare module BABYLON {
  77242. /**
  77243. * Base class for submeshes
  77244. */
  77245. export class BaseSubMesh {
  77246. /** @hidden */
  77247. _materialDefines: Nullable<MaterialDefines>;
  77248. /** @hidden */
  77249. _materialEffect: Nullable<Effect>;
  77250. /**
  77251. * Gets associated effect
  77252. */
  77253. readonly effect: Nullable<Effect>;
  77254. /**
  77255. * Sets associated effect (effect used to render this submesh)
  77256. * @param effect defines the effect to associate with
  77257. * @param defines defines the set of defines used to compile this effect
  77258. */
  77259. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  77260. }
  77261. /**
  77262. * Defines a subdivision inside a mesh
  77263. */
  77264. export class SubMesh extends BaseSubMesh implements ICullable {
  77265. /** the material index to use */
  77266. materialIndex: number;
  77267. /** vertex index start */
  77268. verticesStart: number;
  77269. /** vertices count */
  77270. verticesCount: number;
  77271. /** index start */
  77272. indexStart: number;
  77273. /** indices count */
  77274. indexCount: number;
  77275. /** @hidden */
  77276. _linesIndexCount: number;
  77277. private _mesh;
  77278. private _renderingMesh;
  77279. private _boundingInfo;
  77280. private _linesIndexBuffer;
  77281. /** @hidden */
  77282. _lastColliderWorldVertices: Nullable<Vector3[]>;
  77283. /** @hidden */
  77284. _trianglePlanes: Plane[];
  77285. /** @hidden */
  77286. _lastColliderTransformMatrix: Matrix;
  77287. /** @hidden */
  77288. _renderId: number;
  77289. /** @hidden */
  77290. _alphaIndex: number;
  77291. /** @hidden */
  77292. _distanceToCamera: number;
  77293. /** @hidden */
  77294. _id: number;
  77295. private _currentMaterial;
  77296. /**
  77297. * Add a new submesh to a mesh
  77298. * @param materialIndex defines the material index to use
  77299. * @param verticesStart defines vertex index start
  77300. * @param verticesCount defines vertices count
  77301. * @param indexStart defines index start
  77302. * @param indexCount defines indices count
  77303. * @param mesh defines the parent mesh
  77304. * @param renderingMesh defines an optional rendering mesh
  77305. * @param createBoundingBox defines if bounding box should be created for this submesh
  77306. * @returns the new submesh
  77307. */
  77308. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  77309. /**
  77310. * Creates a new submesh
  77311. * @param materialIndex defines the material index to use
  77312. * @param verticesStart defines vertex index start
  77313. * @param verticesCount defines vertices count
  77314. * @param indexStart defines index start
  77315. * @param indexCount defines indices count
  77316. * @param mesh defines the parent mesh
  77317. * @param renderingMesh defines an optional rendering mesh
  77318. * @param createBoundingBox defines if bounding box should be created for this submesh
  77319. */
  77320. constructor(
  77321. /** the material index to use */
  77322. materialIndex: number,
  77323. /** vertex index start */
  77324. verticesStart: number,
  77325. /** vertices count */
  77326. verticesCount: number,
  77327. /** index start */
  77328. indexStart: number,
  77329. /** indices count */
  77330. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  77331. /**
  77332. * Returns true if this submesh covers the entire parent mesh
  77333. * @ignorenaming
  77334. */
  77335. readonly IsGlobal: boolean;
  77336. /**
  77337. * Returns the submesh BoudingInfo object
  77338. * @returns current bounding info (or mesh's one if the submesh is global)
  77339. */
  77340. getBoundingInfo(): BoundingInfo;
  77341. /**
  77342. * Sets the submesh BoundingInfo
  77343. * @param boundingInfo defines the new bounding info to use
  77344. * @returns the SubMesh
  77345. */
  77346. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  77347. /**
  77348. * Returns the mesh of the current submesh
  77349. * @return the parent mesh
  77350. */
  77351. getMesh(): AbstractMesh;
  77352. /**
  77353. * Returns the rendering mesh of the submesh
  77354. * @returns the rendering mesh (could be different from parent mesh)
  77355. */
  77356. getRenderingMesh(): Mesh;
  77357. /**
  77358. * Returns the submesh material
  77359. * @returns null or the current material
  77360. */
  77361. getMaterial(): Nullable<Material>;
  77362. /**
  77363. * Sets a new updated BoundingInfo object to the submesh
  77364. * @returns the SubMesh
  77365. */
  77366. refreshBoundingInfo(): SubMesh;
  77367. /** @hidden */
  77368. _checkCollision(collider: Collider): boolean;
  77369. /**
  77370. * Updates the submesh BoundingInfo
  77371. * @param world defines the world matrix to use to update the bounding info
  77372. * @returns the submesh
  77373. */
  77374. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  77375. /**
  77376. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  77377. * @param frustumPlanes defines the frustum planes
  77378. * @returns true if the submesh is intersecting with the frustum
  77379. */
  77380. isInFrustum(frustumPlanes: Plane[]): boolean;
  77381. /**
  77382. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  77383. * @param frustumPlanes defines the frustum planes
  77384. * @returns true if the submesh is inside the frustum
  77385. */
  77386. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77387. /**
  77388. * Renders the submesh
  77389. * @param enableAlphaMode defines if alpha needs to be used
  77390. * @returns the submesh
  77391. */
  77392. render(enableAlphaMode: boolean): SubMesh;
  77393. /**
  77394. * @hidden
  77395. */
  77396. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  77397. /**
  77398. * Checks if the submesh intersects with a ray
  77399. * @param ray defines the ray to test
  77400. * @returns true is the passed ray intersects the submesh bounding box
  77401. */
  77402. canIntersects(ray: Ray): boolean;
  77403. /**
  77404. * Intersects current submesh with a ray
  77405. * @param ray defines the ray to test
  77406. * @param positions defines mesh's positions array
  77407. * @param indices defines mesh's indices array
  77408. * @param fastCheck defines if only bounding info should be used
  77409. * @returns intersection info or null if no intersection
  77410. */
  77411. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  77412. /** @hidden */
  77413. private _intersectLines;
  77414. /** @hidden */
  77415. private _intersectTriangles;
  77416. /** @hidden */
  77417. _rebuild(): void;
  77418. /**
  77419. * Creates a new submesh from the passed mesh
  77420. * @param newMesh defines the new hosting mesh
  77421. * @param newRenderingMesh defines an optional rendering mesh
  77422. * @returns the new submesh
  77423. */
  77424. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  77425. /**
  77426. * Release associated resources
  77427. */
  77428. dispose(): void;
  77429. /**
  77430. * Gets the class name
  77431. * @returns the string "SubMesh".
  77432. */
  77433. getClassName(): string;
  77434. /**
  77435. * Creates a new submesh from indices data
  77436. * @param materialIndex the index of the main mesh material
  77437. * @param startIndex the index where to start the copy in the mesh indices array
  77438. * @param indexCount the number of indices to copy then from the startIndex
  77439. * @param mesh the main mesh to create the submesh from
  77440. * @param renderingMesh the optional rendering mesh
  77441. * @returns a new submesh
  77442. */
  77443. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  77444. }
  77445. }
  77446. declare module BABYLON {
  77447. /**
  77448. * Class used to store geometry data (vertex buffers + index buffer)
  77449. */
  77450. export class Geometry implements IGetSetVerticesData {
  77451. /**
  77452. * Gets or sets the ID of the geometry
  77453. */
  77454. id: string;
  77455. /**
  77456. * Gets or sets the unique ID of the geometry
  77457. */
  77458. uniqueId: number;
  77459. /**
  77460. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77461. */
  77462. delayLoadState: number;
  77463. /**
  77464. * Gets the file containing the data to load when running in delay load state
  77465. */
  77466. delayLoadingFile: Nullable<string>;
  77467. /**
  77468. * Callback called when the geometry is updated
  77469. */
  77470. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  77471. private _scene;
  77472. private _engine;
  77473. private _meshes;
  77474. private _totalVertices;
  77475. /** @hidden */
  77476. _indices: IndicesArray;
  77477. /** @hidden */
  77478. _vertexBuffers: {
  77479. [key: string]: VertexBuffer;
  77480. };
  77481. private _isDisposed;
  77482. private _extend;
  77483. private _boundingBias;
  77484. /** @hidden */
  77485. _delayInfo: Array<string>;
  77486. private _indexBuffer;
  77487. private _indexBufferIsUpdatable;
  77488. /** @hidden */
  77489. _boundingInfo: Nullable<BoundingInfo>;
  77490. /** @hidden */
  77491. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  77492. /** @hidden */
  77493. _softwareSkinningFrameId: number;
  77494. private _vertexArrayObjects;
  77495. private _updatable;
  77496. /** @hidden */
  77497. _positions: Nullable<Vector3[]>;
  77498. /**
  77499. * 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
  77500. */
  77501. /**
  77502. * 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
  77503. */
  77504. boundingBias: Vector2;
  77505. /**
  77506. * Static function used to attach a new empty geometry to a mesh
  77507. * @param mesh defines the mesh to attach the geometry to
  77508. * @returns the new Geometry
  77509. */
  77510. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  77511. /**
  77512. * Creates a new geometry
  77513. * @param id defines the unique ID
  77514. * @param scene defines the hosting scene
  77515. * @param vertexData defines the VertexData used to get geometry data
  77516. * @param updatable defines if geometry must be updatable (false by default)
  77517. * @param mesh defines the mesh that will be associated with the geometry
  77518. */
  77519. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  77520. /**
  77521. * Gets the current extend of the geometry
  77522. */
  77523. readonly extend: {
  77524. minimum: Vector3;
  77525. maximum: Vector3;
  77526. };
  77527. /**
  77528. * Gets the hosting scene
  77529. * @returns the hosting Scene
  77530. */
  77531. getScene(): Scene;
  77532. /**
  77533. * Gets the hosting engine
  77534. * @returns the hosting Engine
  77535. */
  77536. getEngine(): Engine;
  77537. /**
  77538. * Defines if the geometry is ready to use
  77539. * @returns true if the geometry is ready to be used
  77540. */
  77541. isReady(): boolean;
  77542. /**
  77543. * Gets a value indicating that the geometry should not be serialized
  77544. */
  77545. readonly doNotSerialize: boolean;
  77546. /** @hidden */
  77547. _rebuild(): void;
  77548. /**
  77549. * Affects all geometry data in one call
  77550. * @param vertexData defines the geometry data
  77551. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77552. */
  77553. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  77554. /**
  77555. * Set specific vertex data
  77556. * @param kind defines the data kind (Position, normal, etc...)
  77557. * @param data defines the vertex data to use
  77558. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77559. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77560. */
  77561. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  77562. /**
  77563. * Removes a specific vertex data
  77564. * @param kind defines the data kind (Position, normal, etc...)
  77565. */
  77566. removeVerticesData(kind: string): void;
  77567. /**
  77568. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77569. * @param buffer defines the vertex buffer to use
  77570. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77571. */
  77572. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  77573. /**
  77574. * Update a specific vertex buffer
  77575. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77576. * It will do nothing if the buffer is not updatable
  77577. * @param kind defines the data kind (Position, normal, etc...)
  77578. * @param data defines the data to use
  77579. * @param offset defines the offset in the target buffer where to store the data
  77580. * @param useBytes set to true if the offset is in bytes
  77581. */
  77582. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  77583. /**
  77584. * Update a specific vertex buffer
  77585. * This function will create a new buffer if the current one is not updatable
  77586. * @param kind defines the data kind (Position, normal, etc...)
  77587. * @param data defines the data to use
  77588. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77589. */
  77590. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  77591. private _updateBoundingInfo;
  77592. /** @hidden */
  77593. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  77594. /**
  77595. * Gets total number of vertices
  77596. * @returns the total number of vertices
  77597. */
  77598. getTotalVertices(): number;
  77599. /**
  77600. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77601. * @param kind defines the data kind (Position, normal, etc...)
  77602. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77603. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77604. * @returns a float array containing vertex data
  77605. */
  77606. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77607. /**
  77608. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77609. * @param kind defines the data kind (Position, normal, etc...)
  77610. * @returns true if the vertex buffer with the specified kind is updatable
  77611. */
  77612. isVertexBufferUpdatable(kind: string): boolean;
  77613. /**
  77614. * Gets a specific vertex buffer
  77615. * @param kind defines the data kind (Position, normal, etc...)
  77616. * @returns a VertexBuffer
  77617. */
  77618. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77619. /**
  77620. * Returns all vertex buffers
  77621. * @return an object holding all vertex buffers indexed by kind
  77622. */
  77623. getVertexBuffers(): Nullable<{
  77624. [key: string]: VertexBuffer;
  77625. }>;
  77626. /**
  77627. * Gets a boolean indicating if specific vertex buffer is present
  77628. * @param kind defines the data kind (Position, normal, etc...)
  77629. * @returns true if data is present
  77630. */
  77631. isVerticesDataPresent(kind: string): boolean;
  77632. /**
  77633. * Gets a list of all attached data kinds (Position, normal, etc...)
  77634. * @returns a list of string containing all kinds
  77635. */
  77636. getVerticesDataKinds(): string[];
  77637. /**
  77638. * Update index buffer
  77639. * @param indices defines the indices to store in the index buffer
  77640. * @param offset defines the offset in the target buffer where to store the data
  77641. */
  77642. updateIndices(indices: IndicesArray, offset?: number): void;
  77643. /**
  77644. * Creates a new index buffer
  77645. * @param indices defines the indices to store in the index buffer
  77646. * @param totalVertices defines the total number of vertices (could be null)
  77647. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77648. */
  77649. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  77650. /**
  77651. * Return the total number of indices
  77652. * @returns the total number of indices
  77653. */
  77654. getTotalIndices(): number;
  77655. /**
  77656. * Gets the index buffer array
  77657. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77659. * @returns the index buffer array
  77660. */
  77661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77662. /**
  77663. * Gets the index buffer
  77664. * @return the index buffer
  77665. */
  77666. getIndexBuffer(): Nullable<WebGLBuffer>;
  77667. /** @hidden */
  77668. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  77669. /**
  77670. * Release the associated resources for a specific mesh
  77671. * @param mesh defines the source mesh
  77672. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77673. */
  77674. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  77675. /**
  77676. * Apply current geometry to a given mesh
  77677. * @param mesh defines the mesh to apply geometry to
  77678. */
  77679. applyToMesh(mesh: Mesh): void;
  77680. private _updateExtend;
  77681. private _applyToMesh;
  77682. private notifyUpdate;
  77683. /**
  77684. * Load the geometry if it was flagged as delay loaded
  77685. * @param scene defines the hosting scene
  77686. * @param onLoaded defines a callback called when the geometry is loaded
  77687. */
  77688. load(scene: Scene, onLoaded?: () => void): void;
  77689. private _queueLoad;
  77690. /**
  77691. * Invert the geometry to move from a right handed system to a left handed one.
  77692. */
  77693. toLeftHanded(): void;
  77694. /** @hidden */
  77695. _resetPointsArrayCache(): void;
  77696. /** @hidden */
  77697. _generatePointsArray(): boolean;
  77698. /**
  77699. * Gets a value indicating if the geometry is disposed
  77700. * @returns true if the geometry was disposed
  77701. */
  77702. isDisposed(): boolean;
  77703. private _disposeVertexArrayObjects;
  77704. /**
  77705. * Free all associated resources
  77706. */
  77707. dispose(): void;
  77708. /**
  77709. * Clone the current geometry into a new geometry
  77710. * @param id defines the unique ID of the new geometry
  77711. * @returns a new geometry object
  77712. */
  77713. copy(id: string): Geometry;
  77714. /**
  77715. * Serialize the current geometry info (and not the vertices data) into a JSON object
  77716. * @return a JSON representation of the current geometry data (without the vertices data)
  77717. */
  77718. serialize(): any;
  77719. private toNumberArray;
  77720. /**
  77721. * Serialize all vertices data into a JSON oject
  77722. * @returns a JSON representation of the current geometry data
  77723. */
  77724. serializeVerticeData(): any;
  77725. /**
  77726. * Extracts a clone of a mesh geometry
  77727. * @param mesh defines the source mesh
  77728. * @param id defines the unique ID of the new geometry object
  77729. * @returns the new geometry object
  77730. */
  77731. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  77732. /**
  77733. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  77734. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  77735. * Be aware Math.random() could cause collisions, but:
  77736. * "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"
  77737. * @returns a string containing a new GUID
  77738. */
  77739. static RandomId(): string;
  77740. /** @hidden */
  77741. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  77742. private static _CleanMatricesWeights;
  77743. /**
  77744. * Create a new geometry from persisted data (Using .babylon file format)
  77745. * @param parsedVertexData defines the persisted data
  77746. * @param scene defines the hosting scene
  77747. * @param rootUrl defines the root url to use to load assets (like delayed data)
  77748. * @returns the new geometry object
  77749. */
  77750. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  77751. }
  77752. }
  77753. declare module BABYLON {
  77754. /**
  77755. * Define an interface for all classes that will get and set the data on vertices
  77756. */
  77757. export interface IGetSetVerticesData {
  77758. /**
  77759. * Gets a boolean indicating if specific vertex data is present
  77760. * @param kind defines the vertex data kind to use
  77761. * @returns true is data kind is present
  77762. */
  77763. isVerticesDataPresent(kind: string): boolean;
  77764. /**
  77765. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77766. * @param kind defines the data kind (Position, normal, etc...)
  77767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77769. * @returns a float array containing vertex data
  77770. */
  77771. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77772. /**
  77773. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77774. * @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.
  77775. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77776. * @returns the indices array or an empty array if the mesh has no geometry
  77777. */
  77778. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77779. /**
  77780. * Set specific vertex data
  77781. * @param kind defines the data kind (Position, normal, etc...)
  77782. * @param data defines the vertex data to use
  77783. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77784. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77785. */
  77786. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  77787. /**
  77788. * Update a specific associated vertex buffer
  77789. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77790. * - VertexBuffer.PositionKind
  77791. * - VertexBuffer.UVKind
  77792. * - VertexBuffer.UV2Kind
  77793. * - VertexBuffer.UV3Kind
  77794. * - VertexBuffer.UV4Kind
  77795. * - VertexBuffer.UV5Kind
  77796. * - VertexBuffer.UV6Kind
  77797. * - VertexBuffer.ColorKind
  77798. * - VertexBuffer.MatricesIndicesKind
  77799. * - VertexBuffer.MatricesIndicesExtraKind
  77800. * - VertexBuffer.MatricesWeightsKind
  77801. * - VertexBuffer.MatricesWeightsExtraKind
  77802. * @param data defines the data source
  77803. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77804. * @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)
  77805. */
  77806. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  77807. /**
  77808. * Creates a new index buffer
  77809. * @param indices defines the indices to store in the index buffer
  77810. * @param totalVertices defines the total number of vertices (could be null)
  77811. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77812. */
  77813. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  77814. }
  77815. /**
  77816. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  77817. */
  77818. export class VertexData {
  77819. /**
  77820. * Mesh side orientation : usually the external or front surface
  77821. */
  77822. static readonly FRONTSIDE: number;
  77823. /**
  77824. * Mesh side orientation : usually the internal or back surface
  77825. */
  77826. static readonly BACKSIDE: number;
  77827. /**
  77828. * Mesh side orientation : both internal and external or front and back surfaces
  77829. */
  77830. static readonly DOUBLESIDE: number;
  77831. /**
  77832. * Mesh side orientation : by default, `FRONTSIDE`
  77833. */
  77834. static readonly DEFAULTSIDE: number;
  77835. /**
  77836. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  77837. */
  77838. positions: Nullable<FloatArray>;
  77839. /**
  77840. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  77841. */
  77842. normals: Nullable<FloatArray>;
  77843. /**
  77844. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  77845. */
  77846. tangents: Nullable<FloatArray>;
  77847. /**
  77848. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77849. */
  77850. uvs: Nullable<FloatArray>;
  77851. /**
  77852. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77853. */
  77854. uvs2: Nullable<FloatArray>;
  77855. /**
  77856. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77857. */
  77858. uvs3: Nullable<FloatArray>;
  77859. /**
  77860. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77861. */
  77862. uvs4: Nullable<FloatArray>;
  77863. /**
  77864. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77865. */
  77866. uvs5: Nullable<FloatArray>;
  77867. /**
  77868. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77869. */
  77870. uvs6: Nullable<FloatArray>;
  77871. /**
  77872. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  77873. */
  77874. colors: Nullable<FloatArray>;
  77875. /**
  77876. * 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).
  77877. */
  77878. matricesIndices: Nullable<FloatArray>;
  77879. /**
  77880. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  77881. */
  77882. matricesWeights: Nullable<FloatArray>;
  77883. /**
  77884. * An array extending the number of possible indices
  77885. */
  77886. matricesIndicesExtra: Nullable<FloatArray>;
  77887. /**
  77888. * An array extending the number of possible weights when the number of indices is extended
  77889. */
  77890. matricesWeightsExtra: Nullable<FloatArray>;
  77891. /**
  77892. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  77893. */
  77894. indices: Nullable<IndicesArray>;
  77895. /**
  77896. * Uses the passed data array to set the set the values for the specified kind of data
  77897. * @param data a linear array of floating numbers
  77898. * @param kind the type of data that is being set, eg positions, colors etc
  77899. */
  77900. set(data: FloatArray, kind: string): void;
  77901. /**
  77902. * Associates the vertexData to the passed Mesh.
  77903. * Sets it as updatable or not (default `false`)
  77904. * @param mesh the mesh the vertexData is applied to
  77905. * @param updatable when used and having the value true allows new data to update the vertexData
  77906. * @returns the VertexData
  77907. */
  77908. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  77909. /**
  77910. * Associates the vertexData to the passed Geometry.
  77911. * Sets it as updatable or not (default `false`)
  77912. * @param geometry the geometry the vertexData is applied to
  77913. * @param updatable when used and having the value true allows new data to update the vertexData
  77914. * @returns VertexData
  77915. */
  77916. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  77917. /**
  77918. * Updates the associated mesh
  77919. * @param mesh the mesh to be updated
  77920. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77921. * @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
  77922. * @returns VertexData
  77923. */
  77924. updateMesh(mesh: Mesh): VertexData;
  77925. /**
  77926. * Updates the associated geometry
  77927. * @param geometry the geometry to be updated
  77928. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77929. * @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
  77930. * @returns VertexData.
  77931. */
  77932. updateGeometry(geometry: Geometry): VertexData;
  77933. private _applyTo;
  77934. private _update;
  77935. /**
  77936. * Transforms each position and each normal of the vertexData according to the passed Matrix
  77937. * @param matrix the transforming matrix
  77938. * @returns the VertexData
  77939. */
  77940. transform(matrix: Matrix): VertexData;
  77941. /**
  77942. * Merges the passed VertexData into the current one
  77943. * @param other the VertexData to be merged into the current one
  77944. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  77945. * @returns the modified VertexData
  77946. */
  77947. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  77948. private _mergeElement;
  77949. private _validate;
  77950. /**
  77951. * Serializes the VertexData
  77952. * @returns a serialized object
  77953. */
  77954. serialize(): any;
  77955. /**
  77956. * Extracts the vertexData from a mesh
  77957. * @param mesh the mesh from which to extract the VertexData
  77958. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  77959. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77960. * @returns the object VertexData associated to the passed mesh
  77961. */
  77962. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77963. /**
  77964. * Extracts the vertexData from the geometry
  77965. * @param geometry the geometry from which to extract the VertexData
  77966. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  77967. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77968. * @returns the object VertexData associated to the passed mesh
  77969. */
  77970. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77971. private static _ExtractFrom;
  77972. /**
  77973. * Creates the VertexData for a Ribbon
  77974. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  77975. * * pathArray array of paths, each of which an array of successive Vector3
  77976. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  77977. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  77978. * * 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
  77979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77980. * * 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)
  77981. * * 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)
  77982. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  77983. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  77984. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  77985. * @returns the VertexData of the ribbon
  77986. */
  77987. static CreateRibbon(options: {
  77988. pathArray: Vector3[][];
  77989. closeArray?: boolean;
  77990. closePath?: boolean;
  77991. offset?: number;
  77992. sideOrientation?: number;
  77993. frontUVs?: Vector4;
  77994. backUVs?: Vector4;
  77995. invertUV?: boolean;
  77996. uvs?: Vector2[];
  77997. colors?: Color4[];
  77998. }): VertexData;
  77999. /**
  78000. * Creates the VertexData for a box
  78001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78002. * * size sets the width, height and depth of the box to the value of size, optional default 1
  78003. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  78004. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  78005. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  78006. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  78007. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  78008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78009. * * 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)
  78010. * * 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)
  78011. * @returns the VertexData of the box
  78012. */
  78013. static CreateBox(options: {
  78014. size?: number;
  78015. width?: number;
  78016. height?: number;
  78017. depth?: number;
  78018. faceUV?: Vector4[];
  78019. faceColors?: Color4[];
  78020. sideOrientation?: number;
  78021. frontUVs?: Vector4;
  78022. backUVs?: Vector4;
  78023. }): VertexData;
  78024. /**
  78025. * Creates the VertexData for an ellipsoid, defaults to a sphere
  78026. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78027. * * segments sets the number of horizontal strips optional, default 32
  78028. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  78029. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  78030. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  78031. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  78032. * * 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
  78033. * * 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
  78034. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78035. * * 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)
  78036. * * 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)
  78037. * @returns the VertexData of the ellipsoid
  78038. */
  78039. static CreateSphere(options: {
  78040. segments?: number;
  78041. diameter?: number;
  78042. diameterX?: number;
  78043. diameterY?: number;
  78044. diameterZ?: number;
  78045. arc?: number;
  78046. slice?: number;
  78047. sideOrientation?: number;
  78048. frontUVs?: Vector4;
  78049. backUVs?: Vector4;
  78050. }): VertexData;
  78051. /**
  78052. * Creates the VertexData for a cylinder, cone or prism
  78053. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78054. * * height sets the height (y direction) of the cylinder, optional, default 2
  78055. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  78056. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  78057. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  78058. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78059. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  78060. * * 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
  78061. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78062. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78063. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  78064. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  78065. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78066. * * 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)
  78067. * * 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)
  78068. * @returns the VertexData of the cylinder, cone or prism
  78069. */
  78070. static CreateCylinder(options: {
  78071. height?: number;
  78072. diameterTop?: number;
  78073. diameterBottom?: number;
  78074. diameter?: number;
  78075. tessellation?: number;
  78076. subdivisions?: number;
  78077. arc?: number;
  78078. faceColors?: Color4[];
  78079. faceUV?: Vector4[];
  78080. hasRings?: boolean;
  78081. enclose?: boolean;
  78082. sideOrientation?: number;
  78083. frontUVs?: Vector4;
  78084. backUVs?: Vector4;
  78085. }): VertexData;
  78086. /**
  78087. * Creates the VertexData for a torus
  78088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78089. * * diameter the diameter of the torus, optional default 1
  78090. * * thickness the diameter of the tube forming the torus, optional default 0.5
  78091. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78093. * * 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)
  78094. * * 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)
  78095. * @returns the VertexData of the torus
  78096. */
  78097. static CreateTorus(options: {
  78098. diameter?: number;
  78099. thickness?: number;
  78100. tessellation?: number;
  78101. sideOrientation?: number;
  78102. frontUVs?: Vector4;
  78103. backUVs?: Vector4;
  78104. }): VertexData;
  78105. /**
  78106. * Creates the VertexData of the LineSystem
  78107. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  78108. * - lines an array of lines, each line being an array of successive Vector3
  78109. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  78110. * @returns the VertexData of the LineSystem
  78111. */
  78112. static CreateLineSystem(options: {
  78113. lines: Vector3[][];
  78114. colors?: Nullable<Color4[][]>;
  78115. }): VertexData;
  78116. /**
  78117. * Create the VertexData for a DashedLines
  78118. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  78119. * - points an array successive Vector3
  78120. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  78121. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  78122. * - dashNb the intended total number of dashes, optional, default 200
  78123. * @returns the VertexData for the DashedLines
  78124. */
  78125. static CreateDashedLines(options: {
  78126. points: Vector3[];
  78127. dashSize?: number;
  78128. gapSize?: number;
  78129. dashNb?: number;
  78130. }): VertexData;
  78131. /**
  78132. * Creates the VertexData for a Ground
  78133. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78134. * - width the width (x direction) of the ground, optional, default 1
  78135. * - height the height (z direction) of the ground, optional, default 1
  78136. * - subdivisions the number of subdivisions per side, optional, default 1
  78137. * @returns the VertexData of the Ground
  78138. */
  78139. static CreateGround(options: {
  78140. width?: number;
  78141. height?: number;
  78142. subdivisions?: number;
  78143. subdivisionsX?: number;
  78144. subdivisionsY?: number;
  78145. }): VertexData;
  78146. /**
  78147. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  78148. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78149. * * xmin the ground minimum X coordinate, optional, default -1
  78150. * * zmin the ground minimum Z coordinate, optional, default -1
  78151. * * xmax the ground maximum X coordinate, optional, default 1
  78152. * * zmax the ground maximum Z coordinate, optional, default 1
  78153. * * 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}
  78154. * * 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}
  78155. * @returns the VertexData of the TiledGround
  78156. */
  78157. static CreateTiledGround(options: {
  78158. xmin: number;
  78159. zmin: number;
  78160. xmax: number;
  78161. zmax: number;
  78162. subdivisions?: {
  78163. w: number;
  78164. h: number;
  78165. };
  78166. precision?: {
  78167. w: number;
  78168. h: number;
  78169. };
  78170. }): VertexData;
  78171. /**
  78172. * Creates the VertexData of the Ground designed from a heightmap
  78173. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  78174. * * width the width (x direction) of the ground
  78175. * * height the height (z direction) of the ground
  78176. * * subdivisions the number of subdivisions per side
  78177. * * minHeight the minimum altitude on the ground, optional, default 0
  78178. * * maxHeight the maximum altitude on the ground, optional default 1
  78179. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  78180. * * buffer the array holding the image color data
  78181. * * bufferWidth the width of image
  78182. * * bufferHeight the height of image
  78183. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  78184. * @returns the VertexData of the Ground designed from a heightmap
  78185. */
  78186. static CreateGroundFromHeightMap(options: {
  78187. width: number;
  78188. height: number;
  78189. subdivisions: number;
  78190. minHeight: number;
  78191. maxHeight: number;
  78192. colorFilter: Color3;
  78193. buffer: Uint8Array;
  78194. bufferWidth: number;
  78195. bufferHeight: number;
  78196. alphaFilter: number;
  78197. }): VertexData;
  78198. /**
  78199. * Creates the VertexData for a Plane
  78200. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  78201. * * size sets the width and height of the plane to the value of size, optional default 1
  78202. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  78203. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  78204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78205. * * 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)
  78206. * * 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)
  78207. * @returns the VertexData of the box
  78208. */
  78209. static CreatePlane(options: {
  78210. size?: number;
  78211. width?: number;
  78212. height?: number;
  78213. sideOrientation?: number;
  78214. frontUVs?: Vector4;
  78215. backUVs?: Vector4;
  78216. }): VertexData;
  78217. /**
  78218. * Creates the VertexData of the Disc or regular Polygon
  78219. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  78220. * * radius the radius of the disc, optional default 0.5
  78221. * * tessellation the number of polygon sides, optional, default 64
  78222. * * 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
  78223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78224. * * 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)
  78225. * * 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)
  78226. * @returns the VertexData of the box
  78227. */
  78228. static CreateDisc(options: {
  78229. radius?: number;
  78230. tessellation?: number;
  78231. arc?: number;
  78232. sideOrientation?: number;
  78233. frontUVs?: Vector4;
  78234. backUVs?: Vector4;
  78235. }): VertexData;
  78236. /**
  78237. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  78238. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  78239. * @param polygon a mesh built from polygonTriangulation.build()
  78240. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78241. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78242. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78243. * @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)
  78244. * @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)
  78245. * @returns the VertexData of the Polygon
  78246. */
  78247. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  78248. /**
  78249. * Creates the VertexData of the IcoSphere
  78250. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  78251. * * radius the radius of the IcoSphere, optional default 1
  78252. * * radiusX allows stretching in the x direction, optional, default radius
  78253. * * radiusY allows stretching in the y direction, optional, default radius
  78254. * * radiusZ allows stretching in the z direction, optional, default radius
  78255. * * flat when true creates a flat shaded mesh, optional, default true
  78256. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78258. * * 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)
  78259. * * 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)
  78260. * @returns the VertexData of the IcoSphere
  78261. */
  78262. static CreateIcoSphere(options: {
  78263. radius?: number;
  78264. radiusX?: number;
  78265. radiusY?: number;
  78266. radiusZ?: number;
  78267. flat?: boolean;
  78268. subdivisions?: number;
  78269. sideOrientation?: number;
  78270. frontUVs?: Vector4;
  78271. backUVs?: Vector4;
  78272. }): VertexData;
  78273. /**
  78274. * Creates the VertexData for a Polyhedron
  78275. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  78276. * * type provided types are:
  78277. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78278. * * 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)
  78279. * * size the size of the IcoSphere, optional default 1
  78280. * * sizeX allows stretching in the x direction, optional, default size
  78281. * * sizeY allows stretching in the y direction, optional, default size
  78282. * * sizeZ allows stretching in the z direction, optional, default size
  78283. * * 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
  78284. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78285. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78286. * * flat when true creates a flat shaded mesh, optional, default true
  78287. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78289. * * 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)
  78290. * * 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)
  78291. * @returns the VertexData of the Polyhedron
  78292. */
  78293. static CreatePolyhedron(options: {
  78294. type?: number;
  78295. size?: number;
  78296. sizeX?: number;
  78297. sizeY?: number;
  78298. sizeZ?: number;
  78299. custom?: any;
  78300. faceUV?: Vector4[];
  78301. faceColors?: Color4[];
  78302. flat?: boolean;
  78303. sideOrientation?: number;
  78304. frontUVs?: Vector4;
  78305. backUVs?: Vector4;
  78306. }): VertexData;
  78307. /**
  78308. * Creates the VertexData for a TorusKnot
  78309. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  78310. * * radius the radius of the torus knot, optional, default 2
  78311. * * tube the thickness of the tube, optional, default 0.5
  78312. * * radialSegments the number of sides on each tube segments, optional, default 32
  78313. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  78314. * * p the number of windings around the z axis, optional, default 2
  78315. * * q the number of windings around the x axis, optional, default 3
  78316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78317. * * 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)
  78318. * * 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)
  78319. * @returns the VertexData of the Torus Knot
  78320. */
  78321. static CreateTorusKnot(options: {
  78322. radius?: number;
  78323. tube?: number;
  78324. radialSegments?: number;
  78325. tubularSegments?: number;
  78326. p?: number;
  78327. q?: number;
  78328. sideOrientation?: number;
  78329. frontUVs?: Vector4;
  78330. backUVs?: Vector4;
  78331. }): VertexData;
  78332. /**
  78333. * Compute normals for given positions and indices
  78334. * @param positions an array of vertex positions, [...., x, y, z, ......]
  78335. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  78336. * @param normals an array of vertex normals, [...., x, y, z, ......]
  78337. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  78338. * * facetNormals : optional array of facet normals (vector3)
  78339. * * facetPositions : optional array of facet positions (vector3)
  78340. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  78341. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  78342. * * bInfo : optional bounding info, required for facetPartitioning computation
  78343. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  78344. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  78345. * * useRightHandedSystem: optional boolean to for right handed system computation
  78346. * * depthSort : optional boolean to enable the facet depth sort computation
  78347. * * distanceTo : optional Vector3 to compute the facet depth from this location
  78348. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  78349. */
  78350. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  78351. facetNormals?: any;
  78352. facetPositions?: any;
  78353. facetPartitioning?: any;
  78354. ratio?: number;
  78355. bInfo?: any;
  78356. bbSize?: Vector3;
  78357. subDiv?: any;
  78358. useRightHandedSystem?: boolean;
  78359. depthSort?: boolean;
  78360. distanceTo?: Vector3;
  78361. depthSortedFacets?: any;
  78362. }): void;
  78363. /** @hidden */
  78364. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  78365. /**
  78366. * Applies VertexData created from the imported parameters to the geometry
  78367. * @param parsedVertexData the parsed data from an imported file
  78368. * @param geometry the geometry to apply the VertexData to
  78369. */
  78370. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  78371. }
  78372. }
  78373. declare module BABYLON {
  78374. /**
  78375. * Class containing static functions to help procedurally build meshes
  78376. */
  78377. export class DiscBuilder {
  78378. /**
  78379. * Creates a plane polygonal mesh. By default, this is a disc
  78380. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78381. * * 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
  78382. * * 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
  78383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78386. * @param name defines the name of the mesh
  78387. * @param options defines the options used to create the mesh
  78388. * @param scene defines the hosting scene
  78389. * @returns the plane polygonal mesh
  78390. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78391. */
  78392. static CreateDisc(name: string, options: {
  78393. radius?: number;
  78394. tessellation?: number;
  78395. arc?: number;
  78396. updatable?: boolean;
  78397. sideOrientation?: number;
  78398. frontUVs?: Vector4;
  78399. backUVs?: Vector4;
  78400. }, scene?: Nullable<Scene>): Mesh;
  78401. }
  78402. }
  78403. declare module BABYLON {
  78404. /**
  78405. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  78406. *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.
  78407. * The SPS is also a particle system. It provides some methods to manage the particles.
  78408. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  78409. *
  78410. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  78411. */
  78412. export class SolidParticleSystem implements IDisposable {
  78413. /**
  78414. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  78415. * Example : var p = SPS.particles[i];
  78416. */
  78417. particles: SolidParticle[];
  78418. /**
  78419. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  78420. */
  78421. nbParticles: number;
  78422. /**
  78423. * If the particles must ever face the camera (default false). Useful for planar particles.
  78424. */
  78425. billboard: boolean;
  78426. /**
  78427. * Recompute normals when adding a shape
  78428. */
  78429. recomputeNormals: boolean;
  78430. /**
  78431. * This a counter ofr your own usage. It's not set by any SPS functions.
  78432. */
  78433. counter: number;
  78434. /**
  78435. * The SPS name. This name is also given to the underlying mesh.
  78436. */
  78437. name: string;
  78438. /**
  78439. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  78440. */
  78441. mesh: Mesh;
  78442. /**
  78443. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  78444. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  78445. */
  78446. vars: any;
  78447. /**
  78448. * This array is populated when the SPS is set as 'pickable'.
  78449. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  78450. * Each element of this array is an object `{idx: int, faceId: int}`.
  78451. * `idx` is the picked particle index in the `SPS.particles` array
  78452. * `faceId` is the picked face index counted within this particle.
  78453. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  78454. */
  78455. pickedParticles: {
  78456. idx: number;
  78457. faceId: number;
  78458. }[];
  78459. /**
  78460. * This array is populated when `enableDepthSort` is set to true.
  78461. * Each element of this array is an instance of the class DepthSortedParticle.
  78462. */
  78463. depthSortedParticles: DepthSortedParticle[];
  78464. /**
  78465. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  78466. * @hidden
  78467. */
  78468. _bSphereOnly: boolean;
  78469. /**
  78470. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  78471. * @hidden
  78472. */
  78473. _bSphereRadiusFactor: number;
  78474. private _scene;
  78475. private _positions;
  78476. private _indices;
  78477. private _normals;
  78478. private _colors;
  78479. private _uvs;
  78480. private _indices32;
  78481. private _positions32;
  78482. private _normals32;
  78483. private _fixedNormal32;
  78484. private _colors32;
  78485. private _uvs32;
  78486. private _index;
  78487. private _updatable;
  78488. private _pickable;
  78489. private _isVisibilityBoxLocked;
  78490. private _alwaysVisible;
  78491. private _depthSort;
  78492. private _shapeCounter;
  78493. private _copy;
  78494. private _color;
  78495. private _computeParticleColor;
  78496. private _computeParticleTexture;
  78497. private _computeParticleRotation;
  78498. private _computeParticleVertex;
  78499. private _computeBoundingBox;
  78500. private _depthSortParticles;
  78501. private _camera;
  78502. private _mustUnrotateFixedNormals;
  78503. private _particlesIntersect;
  78504. private _needs32Bits;
  78505. /**
  78506. * Creates a SPS (Solid Particle System) object.
  78507. * @param name (String) is the SPS name, this will be the underlying mesh name.
  78508. * @param scene (Scene) is the scene in which the SPS is added.
  78509. * @param options defines the options of the sps e.g.
  78510. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  78511. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  78512. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  78513. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  78514. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  78515. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  78516. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  78517. */
  78518. constructor(name: string, scene: Scene, options?: {
  78519. updatable?: boolean;
  78520. isPickable?: boolean;
  78521. enableDepthSort?: boolean;
  78522. particleIntersection?: boolean;
  78523. boundingSphereOnly?: boolean;
  78524. bSphereRadiusFactor?: number;
  78525. });
  78526. /**
  78527. * Builds the SPS underlying mesh. Returns a standard Mesh.
  78528. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  78529. * @returns the created mesh
  78530. */
  78531. buildMesh(): Mesh;
  78532. /**
  78533. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  78534. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  78535. * Thus the particles generated from `digest()` have their property `position` set yet.
  78536. * @param mesh ( Mesh ) is the mesh to be digested
  78537. * @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
  78538. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  78539. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  78540. * @returns the current SPS
  78541. */
  78542. digest(mesh: Mesh, options?: {
  78543. facetNb?: number;
  78544. number?: number;
  78545. delta?: number;
  78546. }): SolidParticleSystem;
  78547. private _unrotateFixedNormals;
  78548. private _resetCopy;
  78549. private _meshBuilder;
  78550. private _posToShape;
  78551. private _uvsToShapeUV;
  78552. private _addParticle;
  78553. /**
  78554. * Adds some particles to the SPS from the model shape. Returns the shape id.
  78555. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  78556. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  78557. * @param nb (positive integer) the number of particles to be created from this model
  78558. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  78559. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  78560. * @returns the number of shapes in the system
  78561. */
  78562. addShape(mesh: Mesh, nb: number, options?: {
  78563. positionFunction?: any;
  78564. vertexFunction?: any;
  78565. }): number;
  78566. private _rebuildParticle;
  78567. /**
  78568. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  78569. * @returns the SPS.
  78570. */
  78571. rebuildMesh(): SolidParticleSystem;
  78572. /**
  78573. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  78574. * This method calls `updateParticle()` for each particle of the SPS.
  78575. * For an animated SPS, it is usually called within the render loop.
  78576. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  78577. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  78578. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  78579. * @returns the SPS.
  78580. */
  78581. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  78582. /**
  78583. * Disposes the SPS.
  78584. */
  78585. dispose(): void;
  78586. /**
  78587. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  78588. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78589. * @returns the SPS.
  78590. */
  78591. refreshVisibleSize(): SolidParticleSystem;
  78592. /**
  78593. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  78594. * @param size the size (float) of the visibility box
  78595. * note : this doesn't lock the SPS mesh bounding box.
  78596. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78597. */
  78598. setVisibilityBox(size: number): void;
  78599. /**
  78600. * Gets whether the SPS as always visible or not
  78601. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78602. */
  78603. /**
  78604. * Sets the SPS as always visible or not
  78605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78606. */
  78607. isAlwaysVisible: boolean;
  78608. /**
  78609. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78610. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78611. */
  78612. /**
  78613. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78614. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78615. */
  78616. isVisibilityBoxLocked: boolean;
  78617. /**
  78618. * Tells to `setParticles()` to compute the particle rotations or not.
  78619. * Default value : true. The SPS is faster when it's set to false.
  78620. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78621. */
  78622. /**
  78623. * Gets if `setParticles()` computes the particle rotations or not.
  78624. * Default value : true. The SPS is faster when it's set to false.
  78625. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78626. */
  78627. computeParticleRotation: boolean;
  78628. /**
  78629. * Tells to `setParticles()` to compute the particle colors or not.
  78630. * Default value : true. The SPS is faster when it's set to false.
  78631. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78632. */
  78633. /**
  78634. * Gets if `setParticles()` computes the particle colors or not.
  78635. * Default value : true. The SPS is faster when it's set to false.
  78636. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78637. */
  78638. computeParticleColor: boolean;
  78639. /**
  78640. * Gets if `setParticles()` computes the particle textures or not.
  78641. * Default value : true. The SPS is faster when it's set to false.
  78642. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  78643. */
  78644. computeParticleTexture: boolean;
  78645. /**
  78646. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  78647. * Default value : false. The SPS is faster when it's set to false.
  78648. * Note : the particle custom vertex positions aren't stored values.
  78649. */
  78650. /**
  78651. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  78652. * Default value : false. The SPS is faster when it's set to false.
  78653. * Note : the particle custom vertex positions aren't stored values.
  78654. */
  78655. computeParticleVertex: boolean;
  78656. /**
  78657. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  78658. */
  78659. /**
  78660. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  78661. */
  78662. computeBoundingBox: boolean;
  78663. /**
  78664. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  78665. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78666. * Default : `true`
  78667. */
  78668. /**
  78669. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  78670. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78671. * Default : `true`
  78672. */
  78673. depthSortParticles: boolean;
  78674. /**
  78675. * This function does nothing. It may be overwritten to set all the particle first values.
  78676. * The SPS doesn't call this function, you may have to call it by your own.
  78677. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78678. */
  78679. initParticles(): void;
  78680. /**
  78681. * This function does nothing. It may be overwritten to recycle a particle.
  78682. * The SPS doesn't call this function, you may have to call it by your own.
  78683. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78684. * @param particle The particle to recycle
  78685. * @returns the recycled particle
  78686. */
  78687. recycleParticle(particle: SolidParticle): SolidParticle;
  78688. /**
  78689. * Updates a particle : this function should be overwritten by the user.
  78690. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  78691. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78692. * @example : just set a particle position or velocity and recycle conditions
  78693. * @param particle The particle to update
  78694. * @returns the updated particle
  78695. */
  78696. updateParticle(particle: SolidParticle): SolidParticle;
  78697. /**
  78698. * Updates a vertex of a particle : it can be overwritten by the user.
  78699. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  78700. * @param particle the current particle
  78701. * @param vertex the current index of the current particle
  78702. * @param pt the index of the current vertex in the particle shape
  78703. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  78704. * @example : just set a vertex particle position
  78705. * @returns the updated vertex
  78706. */
  78707. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  78708. /**
  78709. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  78710. * This does nothing and may be overwritten by the user.
  78711. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78712. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78713. * @param update the boolean update value actually passed to setParticles()
  78714. */
  78715. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78716. /**
  78717. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  78718. * This will be passed three parameters.
  78719. * This does nothing and may be overwritten by the user.
  78720. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78721. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78722. * @param update the boolean update value actually passed to setParticles()
  78723. */
  78724. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78725. }
  78726. }
  78727. declare module BABYLON {
  78728. /**
  78729. * Represents one particle of a solid particle system.
  78730. */
  78731. export class SolidParticle {
  78732. /**
  78733. * particle global index
  78734. */
  78735. idx: number;
  78736. /**
  78737. * The color of the particle
  78738. */
  78739. color: Nullable<Color4>;
  78740. /**
  78741. * The world space position of the particle.
  78742. */
  78743. position: Vector3;
  78744. /**
  78745. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  78746. */
  78747. rotation: Vector3;
  78748. /**
  78749. * The world space rotation quaternion of the particle.
  78750. */
  78751. rotationQuaternion: Nullable<Quaternion>;
  78752. /**
  78753. * The scaling of the particle.
  78754. */
  78755. scaling: Vector3;
  78756. /**
  78757. * The uvs of the particle.
  78758. */
  78759. uvs: Vector4;
  78760. /**
  78761. * The current speed of the particle.
  78762. */
  78763. velocity: Vector3;
  78764. /**
  78765. * The pivot point in the particle local space.
  78766. */
  78767. pivot: Vector3;
  78768. /**
  78769. * Must the particle be translated from its pivot point in its local space ?
  78770. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  78771. * Default : false
  78772. */
  78773. translateFromPivot: boolean;
  78774. /**
  78775. * Is the particle active or not ?
  78776. */
  78777. alive: boolean;
  78778. /**
  78779. * Is the particle visible or not ?
  78780. */
  78781. isVisible: boolean;
  78782. /**
  78783. * Index of this particle in the global "positions" array (Internal use)
  78784. * @hidden
  78785. */
  78786. _pos: number;
  78787. /**
  78788. * @hidden Index of this particle in the global "indices" array (Internal use)
  78789. */
  78790. _ind: number;
  78791. /**
  78792. * @hidden ModelShape of this particle (Internal use)
  78793. */
  78794. _model: ModelShape;
  78795. /**
  78796. * ModelShape id of this particle
  78797. */
  78798. shapeId: number;
  78799. /**
  78800. * Index of the particle in its shape id (Internal use)
  78801. */
  78802. idxInShape: number;
  78803. /**
  78804. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  78805. */
  78806. _modelBoundingInfo: BoundingInfo;
  78807. /**
  78808. * @hidden Particle BoundingInfo object (Internal use)
  78809. */
  78810. _boundingInfo: BoundingInfo;
  78811. /**
  78812. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  78813. */
  78814. _sps: SolidParticleSystem;
  78815. /**
  78816. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  78817. */
  78818. _stillInvisible: boolean;
  78819. /**
  78820. * @hidden Last computed particle rotation matrix
  78821. */
  78822. _rotationMatrix: number[];
  78823. /**
  78824. * Parent particle Id, if any.
  78825. * Default null.
  78826. */
  78827. parentId: Nullable<number>;
  78828. /**
  78829. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  78830. * The possible values are :
  78831. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78832. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78833. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78834. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78835. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78836. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  78837. * */
  78838. cullingStrategy: number;
  78839. /**
  78840. * @hidden Internal global position in the SPS.
  78841. */
  78842. _globalPosition: Vector3;
  78843. /**
  78844. * Creates a Solid Particle object.
  78845. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  78846. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  78847. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  78848. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  78849. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  78850. * @param shapeId (integer) is the model shape identifier in the SPS.
  78851. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  78852. * @param sps defines the sps it is associated to
  78853. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  78854. */
  78855. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  78856. /**
  78857. * Legacy support, changed scale to scaling
  78858. */
  78859. /**
  78860. * Legacy support, changed scale to scaling
  78861. */
  78862. scale: Vector3;
  78863. /**
  78864. * Legacy support, changed quaternion to rotationQuaternion
  78865. */
  78866. /**
  78867. * Legacy support, changed quaternion to rotationQuaternion
  78868. */
  78869. quaternion: Nullable<Quaternion>;
  78870. /**
  78871. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  78872. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  78873. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  78874. * @returns true if it intersects
  78875. */
  78876. intersectsMesh(target: Mesh | SolidParticle): boolean;
  78877. /**
  78878. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  78879. * A particle is in the frustum if its bounding box intersects the frustum
  78880. * @param frustumPlanes defines the frustum to test
  78881. * @returns true if the particle is in the frustum planes
  78882. */
  78883. isInFrustum(frustumPlanes: Plane[]): boolean;
  78884. /**
  78885. * get the rotation matrix of the particle
  78886. * @hidden
  78887. */
  78888. getRotationMatrix(m: Matrix): void;
  78889. }
  78890. /**
  78891. * Represents the shape of the model used by one particle of a solid particle system.
  78892. * SPS internal tool, don't use it manually.
  78893. */
  78894. export class ModelShape {
  78895. /**
  78896. * The shape id
  78897. * @hidden
  78898. */
  78899. shapeID: number;
  78900. /**
  78901. * flat array of model positions (internal use)
  78902. * @hidden
  78903. */
  78904. _shape: Vector3[];
  78905. /**
  78906. * flat array of model UVs (internal use)
  78907. * @hidden
  78908. */
  78909. _shapeUV: number[];
  78910. /**
  78911. * length of the shape in the model indices array (internal use)
  78912. * @hidden
  78913. */
  78914. _indicesLength: number;
  78915. /**
  78916. * Custom position function (internal use)
  78917. * @hidden
  78918. */
  78919. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  78920. /**
  78921. * Custom vertex function (internal use)
  78922. * @hidden
  78923. */
  78924. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  78925. /**
  78926. * 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.
  78927. * SPS internal tool, don't use it manually.
  78928. * @hidden
  78929. */
  78930. 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>);
  78931. }
  78932. /**
  78933. * Represents a Depth Sorted Particle in the solid particle system.
  78934. */
  78935. export class DepthSortedParticle {
  78936. /**
  78937. * Index of the particle in the "indices" array
  78938. */
  78939. ind: number;
  78940. /**
  78941. * Length of the particle shape in the "indices" array
  78942. */
  78943. indicesLength: number;
  78944. /**
  78945. * Squared distance from the particle to the camera
  78946. */
  78947. sqDistance: number;
  78948. }
  78949. }
  78950. declare module BABYLON {
  78951. /**
  78952. * Class used to store all common mesh properties
  78953. */
  78954. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  78955. /** No occlusion */
  78956. static OCCLUSION_TYPE_NONE: number;
  78957. /** Occlusion set to optimisitic */
  78958. static OCCLUSION_TYPE_OPTIMISTIC: number;
  78959. /** Occlusion set to strict */
  78960. static OCCLUSION_TYPE_STRICT: number;
  78961. /** Use an accurante occlusion algorithm */
  78962. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  78963. /** Use a conservative occlusion algorithm */
  78964. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  78965. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78966. * Test order :
  78967. * Is the bounding sphere outside the frustum ?
  78968. * If not, are the bounding box vertices outside the frustum ?
  78969. * It not, then the cullable object is in the frustum.
  78970. */
  78971. static readonly CULLINGSTRATEGY_STANDARD: number;
  78972. /** Culling strategy : Bounding Sphere Only.
  78973. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78974. * It's also less accurate than the standard because some not visible objects can still be selected.
  78975. * Test : is the bounding sphere outside the frustum ?
  78976. * If not, then the cullable object is in the frustum.
  78977. */
  78978. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78979. /** Culling strategy : Optimistic Inclusion.
  78980. * This in an inclusion test first, then the standard exclusion test.
  78981. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78982. * 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.
  78983. * Anyway, it's as accurate as the standard strategy.
  78984. * Test :
  78985. * Is the cullable object bounding sphere center in the frustum ?
  78986. * If not, apply the default culling strategy.
  78987. */
  78988. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78989. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78990. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78991. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78992. * 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.
  78993. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78994. * Test :
  78995. * Is the cullable object bounding sphere center in the frustum ?
  78996. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78997. */
  78998. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78999. /**
  79000. * No billboard
  79001. */
  79002. static readonly BILLBOARDMODE_NONE: number;
  79003. /** Billboard on X axis */
  79004. static readonly BILLBOARDMODE_X: number;
  79005. /** Billboard on Y axis */
  79006. static readonly BILLBOARDMODE_Y: number;
  79007. /** Billboard on Z axis */
  79008. static readonly BILLBOARDMODE_Z: number;
  79009. /** Billboard on all axes */
  79010. static readonly BILLBOARDMODE_ALL: number;
  79011. private _facetData;
  79012. /**
  79013. * The culling strategy to use to check whether the mesh must be rendered or not.
  79014. * This value can be changed at any time and will be used on the next render mesh selection.
  79015. * The possible values are :
  79016. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79017. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79018. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79019. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  79020. * Please read each static variable documentation to get details about the culling process.
  79021. * */
  79022. cullingStrategy: number;
  79023. /**
  79024. * Gets the number of facets in the mesh
  79025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79026. */
  79027. readonly facetNb: number;
  79028. /**
  79029. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  79030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79031. */
  79032. partitioningSubdivisions: number;
  79033. /**
  79034. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  79035. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  79036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79037. */
  79038. partitioningBBoxRatio: number;
  79039. /**
  79040. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  79041. * Works only for updatable meshes.
  79042. * Doesn't work with multi-materials
  79043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79044. */
  79045. mustDepthSortFacets: boolean;
  79046. /**
  79047. * The location (Vector3) where the facet depth sort must be computed from.
  79048. * By default, the active camera position.
  79049. * Used only when facet depth sort is enabled
  79050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79051. */
  79052. facetDepthSortFrom: Vector3;
  79053. /**
  79054. * gets a boolean indicating if facetData is enabled
  79055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79056. */
  79057. readonly isFacetDataEnabled: boolean;
  79058. /** @hidden */
  79059. _updateNonUniformScalingState(value: boolean): boolean;
  79060. /**
  79061. * An event triggered when this mesh collides with another one
  79062. */
  79063. onCollideObservable: Observable<AbstractMesh>;
  79064. private _onCollideObserver;
  79065. /** Set a function to call when this mesh collides with another one */
  79066. onCollide: () => void;
  79067. /**
  79068. * An event triggered when the collision's position changes
  79069. */
  79070. onCollisionPositionChangeObservable: Observable<Vector3>;
  79071. private _onCollisionPositionChangeObserver;
  79072. /** Set a function to call when the collision's position changes */
  79073. onCollisionPositionChange: () => void;
  79074. /**
  79075. * An event triggered when material is changed
  79076. */
  79077. onMaterialChangedObservable: Observable<AbstractMesh>;
  79078. /**
  79079. * Gets or sets the orientation for POV movement & rotation
  79080. */
  79081. definedFacingForward: boolean;
  79082. /** @hidden */
  79083. _occlusionQuery: Nullable<WebGLQuery>;
  79084. private _visibility;
  79085. /**
  79086. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79087. */
  79088. /**
  79089. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79090. */
  79091. visibility: number;
  79092. /** Gets or sets the alpha index used to sort transparent meshes
  79093. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  79094. */
  79095. alphaIndex: number;
  79096. /**
  79097. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  79098. */
  79099. isVisible: boolean;
  79100. /**
  79101. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79102. */
  79103. isPickable: boolean;
  79104. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  79105. showSubMeshesBoundingBox: boolean;
  79106. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  79107. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  79108. */
  79109. isBlocker: boolean;
  79110. /**
  79111. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  79112. */
  79113. enablePointerMoveEvents: boolean;
  79114. /**
  79115. * Specifies the rendering group id for this mesh (0 by default)
  79116. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79117. */
  79118. renderingGroupId: number;
  79119. private _material;
  79120. /** Gets or sets current material */
  79121. material: Nullable<Material>;
  79122. private _receiveShadows;
  79123. /**
  79124. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  79125. * @see http://doc.babylonjs.com/babylon101/shadows
  79126. */
  79127. receiveShadows: boolean;
  79128. /** Defines color to use when rendering outline */
  79129. outlineColor: Color3;
  79130. /** Define width to use when rendering outline */
  79131. outlineWidth: number;
  79132. /** Defines color to use when rendering overlay */
  79133. overlayColor: Color3;
  79134. /** Defines alpha to use when rendering overlay */
  79135. overlayAlpha: number;
  79136. private _hasVertexAlpha;
  79137. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  79138. hasVertexAlpha: boolean;
  79139. private _useVertexColors;
  79140. /** 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) */
  79141. useVertexColors: boolean;
  79142. private _computeBonesUsingShaders;
  79143. /**
  79144. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  79145. */
  79146. computeBonesUsingShaders: boolean;
  79147. private _numBoneInfluencers;
  79148. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  79149. numBoneInfluencers: number;
  79150. private _applyFog;
  79151. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  79152. applyFog: boolean;
  79153. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  79154. useOctreeForRenderingSelection: boolean;
  79155. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  79156. useOctreeForPicking: boolean;
  79157. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  79158. useOctreeForCollisions: boolean;
  79159. private _layerMask;
  79160. /**
  79161. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  79162. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  79163. */
  79164. layerMask: number;
  79165. /**
  79166. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  79167. */
  79168. alwaysSelectAsActiveMesh: boolean;
  79169. /**
  79170. * Gets or sets the current action manager
  79171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79172. */
  79173. actionManager: Nullable<AbstractActionManager>;
  79174. private _checkCollisions;
  79175. private _collisionMask;
  79176. private _collisionGroup;
  79177. /**
  79178. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  79179. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79180. */
  79181. ellipsoid: Vector3;
  79182. /**
  79183. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  79184. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79185. */
  79186. ellipsoidOffset: Vector3;
  79187. private _collider;
  79188. private _oldPositionForCollisions;
  79189. private _diffPositionForCollisions;
  79190. /**
  79191. * Gets or sets a collision mask used to mask collisions (default is -1).
  79192. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79193. */
  79194. collisionMask: number;
  79195. /**
  79196. * Gets or sets the current collision group mask (-1 by default).
  79197. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79198. */
  79199. collisionGroup: number;
  79200. /**
  79201. * Defines edge width used when edgesRenderer is enabled
  79202. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79203. */
  79204. edgesWidth: number;
  79205. /**
  79206. * Defines edge color used when edgesRenderer is enabled
  79207. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79208. */
  79209. edgesColor: Color4;
  79210. /** @hidden */
  79211. _edgesRenderer: Nullable<IEdgesRenderer>;
  79212. /** @hidden */
  79213. _masterMesh: Nullable<AbstractMesh>;
  79214. /** @hidden */
  79215. _boundingInfo: Nullable<BoundingInfo>;
  79216. /** @hidden */
  79217. _renderId: number;
  79218. /**
  79219. * Gets or sets the list of subMeshes
  79220. * @see http://doc.babylonjs.com/how_to/multi_materials
  79221. */
  79222. subMeshes: SubMesh[];
  79223. /** @hidden */
  79224. _intersectionsInProgress: AbstractMesh[];
  79225. /** @hidden */
  79226. _unIndexed: boolean;
  79227. /** @hidden */
  79228. _lightSources: Light[];
  79229. /** @hidden */
  79230. readonly _positions: Nullable<Vector3[]>;
  79231. /** @hidden */
  79232. _waitingActions: any;
  79233. /** @hidden */
  79234. _waitingFreezeWorldMatrix: Nullable<boolean>;
  79235. private _skeleton;
  79236. /** @hidden */
  79237. _bonesTransformMatrices: Nullable<Float32Array>;
  79238. /**
  79239. * Gets or sets a skeleton to apply skining transformations
  79240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79241. */
  79242. skeleton: Nullable<Skeleton>;
  79243. /**
  79244. * An event triggered when the mesh is rebuilt.
  79245. */
  79246. onRebuildObservable: Observable<AbstractMesh>;
  79247. /**
  79248. * Creates a new AbstractMesh
  79249. * @param name defines the name of the mesh
  79250. * @param scene defines the hosting scene
  79251. */
  79252. constructor(name: string, scene?: Nullable<Scene>);
  79253. /**
  79254. * Returns the string "AbstractMesh"
  79255. * @returns "AbstractMesh"
  79256. */
  79257. getClassName(): string;
  79258. /**
  79259. * Gets a string representation of the current mesh
  79260. * @param fullDetails defines a boolean indicating if full details must be included
  79261. * @returns a string representation of the current mesh
  79262. */
  79263. toString(fullDetails?: boolean): string;
  79264. /** @hidden */
  79265. _rebuild(): void;
  79266. /** @hidden */
  79267. _resyncLightSources(): void;
  79268. /** @hidden */
  79269. _resyncLighSource(light: Light): void;
  79270. /** @hidden */
  79271. _unBindEffect(): void;
  79272. /** @hidden */
  79273. _removeLightSource(light: Light): void;
  79274. private _markSubMeshesAsDirty;
  79275. /** @hidden */
  79276. _markSubMeshesAsLightDirty(): void;
  79277. /** @hidden */
  79278. _markSubMeshesAsAttributesDirty(): void;
  79279. /** @hidden */
  79280. _markSubMeshesAsMiscDirty(): void;
  79281. /**
  79282. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79283. */
  79284. scaling: Vector3;
  79285. /**
  79286. * Returns true if the mesh is blocked. Implemented by child classes
  79287. */
  79288. readonly isBlocked: boolean;
  79289. /**
  79290. * Returns the mesh itself by default. Implemented by child classes
  79291. * @param camera defines the camera to use to pick the right LOD level
  79292. * @returns the currentAbstractMesh
  79293. */
  79294. getLOD(camera: Camera): Nullable<AbstractMesh>;
  79295. /**
  79296. * Returns 0 by default. Implemented by child classes
  79297. * @returns an integer
  79298. */
  79299. getTotalVertices(): number;
  79300. /**
  79301. * Returns a positive integer : the total number of indices in this mesh geometry.
  79302. * @returns the numner of indices or zero if the mesh has no geometry.
  79303. */
  79304. getTotalIndices(): number;
  79305. /**
  79306. * Returns null by default. Implemented by child classes
  79307. * @returns null
  79308. */
  79309. getIndices(): Nullable<IndicesArray>;
  79310. /**
  79311. * Returns the array of the requested vertex data kind. Implemented by child classes
  79312. * @param kind defines the vertex data kind to use
  79313. * @returns null
  79314. */
  79315. getVerticesData(kind: string): Nullable<FloatArray>;
  79316. /**
  79317. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79318. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79319. * Note that a new underlying VertexBuffer object is created each call.
  79320. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79321. * @param kind defines vertex data kind:
  79322. * * VertexBuffer.PositionKind
  79323. * * VertexBuffer.UVKind
  79324. * * VertexBuffer.UV2Kind
  79325. * * VertexBuffer.UV3Kind
  79326. * * VertexBuffer.UV4Kind
  79327. * * VertexBuffer.UV5Kind
  79328. * * VertexBuffer.UV6Kind
  79329. * * VertexBuffer.ColorKind
  79330. * * VertexBuffer.MatricesIndicesKind
  79331. * * VertexBuffer.MatricesIndicesExtraKind
  79332. * * VertexBuffer.MatricesWeightsKind
  79333. * * VertexBuffer.MatricesWeightsExtraKind
  79334. * @param data defines the data source
  79335. * @param updatable defines if the data must be flagged as updatable (or static)
  79336. * @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
  79337. * @returns the current mesh
  79338. */
  79339. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  79340. /**
  79341. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79342. * If the mesh has no geometry, it is simply returned as it is.
  79343. * @param kind defines vertex data kind:
  79344. * * VertexBuffer.PositionKind
  79345. * * VertexBuffer.UVKind
  79346. * * VertexBuffer.UV2Kind
  79347. * * VertexBuffer.UV3Kind
  79348. * * VertexBuffer.UV4Kind
  79349. * * VertexBuffer.UV5Kind
  79350. * * VertexBuffer.UV6Kind
  79351. * * VertexBuffer.ColorKind
  79352. * * VertexBuffer.MatricesIndicesKind
  79353. * * VertexBuffer.MatricesIndicesExtraKind
  79354. * * VertexBuffer.MatricesWeightsKind
  79355. * * VertexBuffer.MatricesWeightsExtraKind
  79356. * @param data defines the data source
  79357. * @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
  79358. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79359. * @returns the current mesh
  79360. */
  79361. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  79362. /**
  79363. * Sets the mesh indices,
  79364. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79365. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79366. * @param totalVertices Defines the total number of vertices
  79367. * @returns the current mesh
  79368. */
  79369. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  79370. /**
  79371. * Gets a boolean indicating if specific vertex data is present
  79372. * @param kind defines the vertex data kind to use
  79373. * @returns true is data kind is present
  79374. */
  79375. isVerticesDataPresent(kind: string): boolean;
  79376. /**
  79377. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79378. * @returns a BoundingInfo
  79379. */
  79380. getBoundingInfo(): BoundingInfo;
  79381. /**
  79382. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79383. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79384. * @returns the current mesh
  79385. */
  79386. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  79387. /**
  79388. * Overwrite the current bounding info
  79389. * @param boundingInfo defines the new bounding info
  79390. * @returns the current mesh
  79391. */
  79392. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  79393. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79394. readonly useBones: boolean;
  79395. /** @hidden */
  79396. _preActivate(): void;
  79397. /** @hidden */
  79398. _preActivateForIntermediateRendering(renderId: number): void;
  79399. /** @hidden */
  79400. _activate(renderId: number): void;
  79401. /**
  79402. * Gets the current world matrix
  79403. * @returns a Matrix
  79404. */
  79405. getWorldMatrix(): Matrix;
  79406. /** @hidden */
  79407. _getWorldMatrixDeterminant(): number;
  79408. /**
  79409. * Perform relative position change from the point of view of behind the front of the mesh.
  79410. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79411. * Supports definition of mesh facing forward or backward
  79412. * @param amountRight defines the distance on the right axis
  79413. * @param amountUp defines the distance on the up axis
  79414. * @param amountForward defines the distance on the forward axis
  79415. * @returns the current mesh
  79416. */
  79417. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  79418. /**
  79419. * Calculate relative position change from the point of view of behind the front of the mesh.
  79420. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79421. * Supports definition of mesh facing forward or backward
  79422. * @param amountRight defines the distance on the right axis
  79423. * @param amountUp defines the distance on the up axis
  79424. * @param amountForward defines the distance on the forward axis
  79425. * @returns the new displacement vector
  79426. */
  79427. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  79428. /**
  79429. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79430. * Supports definition of mesh facing forward or backward
  79431. * @param flipBack defines the flip
  79432. * @param twirlClockwise defines the twirl
  79433. * @param tiltRight defines the tilt
  79434. * @returns the current mesh
  79435. */
  79436. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  79437. /**
  79438. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79439. * Supports definition of mesh facing forward or backward.
  79440. * @param flipBack defines the flip
  79441. * @param twirlClockwise defines the twirl
  79442. * @param tiltRight defines the tilt
  79443. * @returns the new rotation vector
  79444. */
  79445. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  79446. /**
  79447. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79448. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79449. * @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
  79450. * @returns the new bounding vectors
  79451. */
  79452. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  79453. min: Vector3;
  79454. max: Vector3;
  79455. };
  79456. /**
  79457. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79458. * This means the mesh underlying bounding box and sphere are recomputed.
  79459. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79460. * @returns the current mesh
  79461. */
  79462. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  79463. /** @hidden */
  79464. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  79465. /** @hidden */
  79466. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  79467. /** @hidden */
  79468. _updateBoundingInfo(): AbstractMesh;
  79469. /** @hidden */
  79470. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  79471. /** @hidden */
  79472. protected _afterComputeWorldMatrix(): void;
  79473. /**
  79474. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79475. * A mesh is in the frustum if its bounding box intersects the frustum
  79476. * @param frustumPlanes defines the frustum to test
  79477. * @returns true if the mesh is in the frustum planes
  79478. */
  79479. isInFrustum(frustumPlanes: Plane[]): boolean;
  79480. /**
  79481. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79482. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79483. * @param frustumPlanes defines the frustum to test
  79484. * @returns true if the mesh is completely in the frustum planes
  79485. */
  79486. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79487. /**
  79488. * True if the mesh intersects another mesh or a SolidParticle object
  79489. * @param mesh defines a target mesh or SolidParticle to test
  79490. * @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)
  79491. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79492. * @returns true if there is an intersection
  79493. */
  79494. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  79495. /**
  79496. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79497. * @param point defines the point to test
  79498. * @returns true if there is an intersection
  79499. */
  79500. intersectsPoint(point: Vector3): boolean;
  79501. /**
  79502. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79504. */
  79505. checkCollisions: boolean;
  79506. /**
  79507. * Gets Collider object used to compute collisions (not physics)
  79508. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79509. */
  79510. readonly collider: Collider;
  79511. /**
  79512. * Move the mesh using collision engine
  79513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79514. * @param displacement defines the requested displacement vector
  79515. * @returns the current mesh
  79516. */
  79517. moveWithCollisions(displacement: Vector3): AbstractMesh;
  79518. private _onCollisionPositionChange;
  79519. /** @hidden */
  79520. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  79521. /** @hidden */
  79522. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  79523. /** @hidden */
  79524. _checkCollision(collider: Collider): AbstractMesh;
  79525. /** @hidden */
  79526. _generatePointsArray(): boolean;
  79527. /**
  79528. * Checks if the passed Ray intersects with the mesh
  79529. * @param ray defines the ray to use
  79530. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79531. * @returns the picking info
  79532. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79533. */
  79534. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  79535. /**
  79536. * Clones the current mesh
  79537. * @param name defines the mesh name
  79538. * @param newParent defines the new mesh parent
  79539. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79540. * @returns the new mesh
  79541. */
  79542. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  79543. /**
  79544. * Disposes all the submeshes of the current meshnp
  79545. * @returns the current mesh
  79546. */
  79547. releaseSubMeshes(): AbstractMesh;
  79548. /**
  79549. * Releases resources associated with this abstract mesh.
  79550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79552. */
  79553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79554. /**
  79555. * Adds the passed mesh as a child to the current mesh
  79556. * @param mesh defines the child mesh
  79557. * @returns the current mesh
  79558. */
  79559. addChild(mesh: AbstractMesh): AbstractMesh;
  79560. /**
  79561. * Removes the passed mesh from the current mesh children list
  79562. * @param mesh defines the child mesh
  79563. * @returns the current mesh
  79564. */
  79565. removeChild(mesh: AbstractMesh): AbstractMesh;
  79566. /** @hidden */
  79567. private _initFacetData;
  79568. /**
  79569. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79570. * This method can be called within the render loop.
  79571. * 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
  79572. * @returns the current mesh
  79573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79574. */
  79575. updateFacetData(): AbstractMesh;
  79576. /**
  79577. * Returns the facetLocalNormals array.
  79578. * The normals are expressed in the mesh local spac
  79579. * @returns an array of Vector3
  79580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79581. */
  79582. getFacetLocalNormals(): Vector3[];
  79583. /**
  79584. * Returns the facetLocalPositions array.
  79585. * The facet positions are expressed in the mesh local space
  79586. * @returns an array of Vector3
  79587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79588. */
  79589. getFacetLocalPositions(): Vector3[];
  79590. /**
  79591. * Returns the facetLocalPartioning array
  79592. * @returns an array of array of numbers
  79593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79594. */
  79595. getFacetLocalPartitioning(): number[][];
  79596. /**
  79597. * Returns the i-th facet position in the world system.
  79598. * This method allocates a new Vector3 per call
  79599. * @param i defines the facet index
  79600. * @returns a new Vector3
  79601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79602. */
  79603. getFacetPosition(i: number): Vector3;
  79604. /**
  79605. * Sets the reference Vector3 with the i-th facet position in the world system
  79606. * @param i defines the facet index
  79607. * @param ref defines the target vector
  79608. * @returns the current mesh
  79609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79610. */
  79611. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  79612. /**
  79613. * Returns the i-th facet normal in the world system.
  79614. * This method allocates a new Vector3 per call
  79615. * @param i defines the facet index
  79616. * @returns a new Vector3
  79617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79618. */
  79619. getFacetNormal(i: number): Vector3;
  79620. /**
  79621. * Sets the reference Vector3 with the i-th facet normal in the world system
  79622. * @param i defines the facet index
  79623. * @param ref defines the target vector
  79624. * @returns the current mesh
  79625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79626. */
  79627. getFacetNormalToRef(i: number, ref: Vector3): this;
  79628. /**
  79629. * 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)
  79630. * @param x defines x coordinate
  79631. * @param y defines y coordinate
  79632. * @param z defines z coordinate
  79633. * @returns the array of facet indexes
  79634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79635. */
  79636. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  79637. /**
  79638. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  79639. * @param projected sets as the (x,y,z) world projection on the facet
  79640. * @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
  79641. * @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
  79642. * @param x defines x coordinate
  79643. * @param y defines y coordinate
  79644. * @param z defines z coordinate
  79645. * @returns the face index if found (or null instead)
  79646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79647. */
  79648. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79649. /**
  79650. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  79651. * @param projected sets as the (x,y,z) local projection on the facet
  79652. * @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
  79653. * @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
  79654. * @param x defines x coordinate
  79655. * @param y defines y coordinate
  79656. * @param z defines z coordinate
  79657. * @returns the face index if found (or null instead)
  79658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79659. */
  79660. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79661. /**
  79662. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  79663. * @returns the parameters
  79664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79665. */
  79666. getFacetDataParameters(): any;
  79667. /**
  79668. * Disables the feature FacetData and frees the related memory
  79669. * @returns the current mesh
  79670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79671. */
  79672. disableFacetData(): AbstractMesh;
  79673. /**
  79674. * Updates the AbstractMesh indices array
  79675. * @param indices defines the data source
  79676. * @returns the current mesh
  79677. */
  79678. updateIndices(indices: IndicesArray): AbstractMesh;
  79679. /**
  79680. * Creates new normals data for the mesh
  79681. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  79682. * @returns the current mesh
  79683. */
  79684. createNormals(updatable: boolean): AbstractMesh;
  79685. /**
  79686. * Align the mesh with a normal
  79687. * @param normal defines the normal to use
  79688. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  79689. * @returns the current mesh
  79690. */
  79691. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  79692. /** @hidden */
  79693. _checkOcclusionQuery(): boolean;
  79694. }
  79695. }
  79696. declare module BABYLON {
  79697. /**
  79698. * Class used to handle skinning animations
  79699. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79700. */
  79701. export class Skeleton implements IAnimatable {
  79702. /** defines the skeleton name */
  79703. name: string;
  79704. /** defines the skeleton Id */
  79705. id: string;
  79706. /**
  79707. * Defines the list of child bones
  79708. */
  79709. bones: Bone[];
  79710. /**
  79711. * Defines an estimate of the dimension of the skeleton at rest
  79712. */
  79713. dimensionsAtRest: Vector3;
  79714. /**
  79715. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79716. */
  79717. needInitialSkinMatrix: boolean;
  79718. /**
  79719. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79720. */
  79721. overrideMesh: Nullable<AbstractMesh>;
  79722. /**
  79723. * Gets the list of animations attached to this skeleton
  79724. */
  79725. animations: Array<Animation>;
  79726. private _scene;
  79727. private _isDirty;
  79728. private _transformMatrices;
  79729. private _transformMatrixTexture;
  79730. private _meshesWithPoseMatrix;
  79731. private _animatables;
  79732. private _identity;
  79733. private _synchronizedWithMesh;
  79734. private _ranges;
  79735. private _lastAbsoluteTransformsUpdateId;
  79736. private _canUseTextureForBones;
  79737. /** @hidden */
  79738. _numBonesWithLinkedTransformNode: number;
  79739. /**
  79740. * Specifies if the skeleton should be serialized
  79741. */
  79742. doNotSerialize: boolean;
  79743. /**
  79744. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79745. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79746. */
  79747. useTextureToStoreBoneMatrices: boolean;
  79748. private _animationPropertiesOverride;
  79749. /**
  79750. * Gets or sets the animation properties override
  79751. */
  79752. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79753. /**
  79754. * An observable triggered before computing the skeleton's matrices
  79755. */
  79756. onBeforeComputeObservable: Observable<Skeleton>;
  79757. /**
  79758. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79759. */
  79760. readonly isUsingTextureForMatrices: boolean;
  79761. /**
  79762. * Creates a new skeleton
  79763. * @param name defines the skeleton name
  79764. * @param id defines the skeleton Id
  79765. * @param scene defines the hosting scene
  79766. */
  79767. constructor(
  79768. /** defines the skeleton name */
  79769. name: string,
  79770. /** defines the skeleton Id */
  79771. id: string, scene: Scene);
  79772. /**
  79773. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79774. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79775. * @returns a Float32Array containing matrices data
  79776. */
  79777. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79778. /**
  79779. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79780. * @returns a raw texture containing the data
  79781. */
  79782. getTransformMatrixTexture(): Nullable<RawTexture>;
  79783. /**
  79784. * Gets the current hosting scene
  79785. * @returns a scene object
  79786. */
  79787. getScene(): Scene;
  79788. /**
  79789. * Gets a string representing the current skeleton data
  79790. * @param fullDetails defines a boolean indicating if we want a verbose version
  79791. * @returns a string representing the current skeleton data
  79792. */
  79793. toString(fullDetails?: boolean): string;
  79794. /**
  79795. * Get bone's index searching by name
  79796. * @param name defines bone's name to search for
  79797. * @return the indice of the bone. Returns -1 if not found
  79798. */
  79799. getBoneIndexByName(name: string): number;
  79800. /**
  79801. * Creater a new animation range
  79802. * @param name defines the name of the range
  79803. * @param from defines the start key
  79804. * @param to defines the end key
  79805. */
  79806. createAnimationRange(name: string, from: number, to: number): void;
  79807. /**
  79808. * Delete a specific animation range
  79809. * @param name defines the name of the range
  79810. * @param deleteFrames defines if frames must be removed as well
  79811. */
  79812. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79813. /**
  79814. * Gets a specific animation range
  79815. * @param name defines the name of the range to look for
  79816. * @returns the requested animation range or null if not found
  79817. */
  79818. getAnimationRange(name: string): Nullable<AnimationRange>;
  79819. /**
  79820. * Gets the list of all animation ranges defined on this skeleton
  79821. * @returns an array
  79822. */
  79823. getAnimationRanges(): Nullable<AnimationRange>[];
  79824. /**
  79825. * Copy animation range from a source skeleton.
  79826. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79827. * @param source defines the source skeleton
  79828. * @param name defines the name of the range to copy
  79829. * @param rescaleAsRequired defines if rescaling must be applied if required
  79830. * @returns true if operation was successful
  79831. */
  79832. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79833. /**
  79834. * Forces the skeleton to go to rest pose
  79835. */
  79836. returnToRest(): void;
  79837. private _getHighestAnimationFrame;
  79838. /**
  79839. * Begin a specific animation range
  79840. * @param name defines the name of the range to start
  79841. * @param loop defines if looping must be turned on (false by default)
  79842. * @param speedRatio defines the speed ratio to apply (1 by default)
  79843. * @param onAnimationEnd defines a callback which will be called when animation will end
  79844. * @returns a new animatable
  79845. */
  79846. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79847. /** @hidden */
  79848. _markAsDirty(): void;
  79849. /** @hidden */
  79850. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79851. /** @hidden */
  79852. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79853. private _computeTransformMatrices;
  79854. /**
  79855. * Build all resources required to render a skeleton
  79856. */
  79857. prepare(): void;
  79858. /**
  79859. * Gets the list of animatables currently running for this skeleton
  79860. * @returns an array of animatables
  79861. */
  79862. getAnimatables(): IAnimatable[];
  79863. /**
  79864. * Clone the current skeleton
  79865. * @param name defines the name of the new skeleton
  79866. * @param id defines the id of the enw skeleton
  79867. * @returns the new skeleton
  79868. */
  79869. clone(name: string, id: string): Skeleton;
  79870. /**
  79871. * Enable animation blending for this skeleton
  79872. * @param blendingSpeed defines the blending speed to apply
  79873. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79874. */
  79875. enableBlending(blendingSpeed?: number): void;
  79876. /**
  79877. * Releases all resources associated with the current skeleton
  79878. */
  79879. dispose(): void;
  79880. /**
  79881. * Serialize the skeleton in a JSON object
  79882. * @returns a JSON object
  79883. */
  79884. serialize(): any;
  79885. /**
  79886. * Creates a new skeleton from serialized data
  79887. * @param parsedSkeleton defines the serialized data
  79888. * @param scene defines the hosting scene
  79889. * @returns a new skeleton
  79890. */
  79891. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79892. /**
  79893. * Compute all node absolute transforms
  79894. * @param forceUpdate defines if computation must be done even if cache is up to date
  79895. */
  79896. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79897. /**
  79898. * Gets the root pose matrix
  79899. * @returns a matrix
  79900. */
  79901. getPoseMatrix(): Nullable<Matrix>;
  79902. /**
  79903. * Sorts bones per internal index
  79904. */
  79905. sortBones(): void;
  79906. private _sortBones;
  79907. }
  79908. }
  79909. declare module BABYLON {
  79910. /**
  79911. * Class used to store bone information
  79912. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79913. */
  79914. export class Bone extends Node {
  79915. /**
  79916. * defines the bone name
  79917. */
  79918. name: string;
  79919. private static _tmpVecs;
  79920. private static _tmpQuat;
  79921. private static _tmpMats;
  79922. /**
  79923. * Gets the list of child bones
  79924. */
  79925. children: Bone[];
  79926. /** Gets the animations associated with this bone */
  79927. animations: Animation[];
  79928. /**
  79929. * Gets or sets bone length
  79930. */
  79931. length: number;
  79932. /**
  79933. * @hidden Internal only
  79934. * Set this value to map this bone to a different index in the transform matrices
  79935. * Set this value to -1 to exclude the bone from the transform matrices
  79936. */
  79937. _index: Nullable<number>;
  79938. private _skeleton;
  79939. private _localMatrix;
  79940. private _restPose;
  79941. private _baseMatrix;
  79942. private _absoluteTransform;
  79943. private _invertedAbsoluteTransform;
  79944. private _parent;
  79945. private _scalingDeterminant;
  79946. private _worldTransform;
  79947. private _localScaling;
  79948. private _localRotation;
  79949. private _localPosition;
  79950. private _needToDecompose;
  79951. private _needToCompose;
  79952. /** @hidden */
  79953. _linkedTransformNode: Nullable<TransformNode>;
  79954. /** @hidden */
  79955. /** @hidden */
  79956. _matrix: Matrix;
  79957. /**
  79958. * Create a new bone
  79959. * @param name defines the bone name
  79960. * @param skeleton defines the parent skeleton
  79961. * @param parentBone defines the parent (can be null if the bone is the root)
  79962. * @param localMatrix defines the local matrix
  79963. * @param restPose defines the rest pose matrix
  79964. * @param baseMatrix defines the base matrix
  79965. * @param index defines index of the bone in the hiearchy
  79966. */
  79967. constructor(
  79968. /**
  79969. * defines the bone name
  79970. */
  79971. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79972. /**
  79973. * Gets the parent skeleton
  79974. * @returns a skeleton
  79975. */
  79976. getSkeleton(): Skeleton;
  79977. /**
  79978. * Gets parent bone
  79979. * @returns a bone or null if the bone is the root of the bone hierarchy
  79980. */
  79981. getParent(): Nullable<Bone>;
  79982. /**
  79983. * Sets the parent bone
  79984. * @param parent defines the parent (can be null if the bone is the root)
  79985. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79986. */
  79987. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79988. /**
  79989. * Gets the local matrix
  79990. * @returns a matrix
  79991. */
  79992. getLocalMatrix(): Matrix;
  79993. /**
  79994. * Gets the base matrix (initial matrix which remains unchanged)
  79995. * @returns a matrix
  79996. */
  79997. getBaseMatrix(): Matrix;
  79998. /**
  79999. * Gets the rest pose matrix
  80000. * @returns a matrix
  80001. */
  80002. getRestPose(): Matrix;
  80003. /**
  80004. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80005. */
  80006. getWorldMatrix(): Matrix;
  80007. /**
  80008. * Sets the local matrix to rest pose matrix
  80009. */
  80010. returnToRest(): void;
  80011. /**
  80012. * Gets the inverse of the absolute transform matrix.
  80013. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80014. * @returns a matrix
  80015. */
  80016. getInvertedAbsoluteTransform(): Matrix;
  80017. /**
  80018. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80019. * @returns a matrix
  80020. */
  80021. getAbsoluteTransform(): Matrix;
  80022. /**
  80023. * Links with the given transform node.
  80024. * The local matrix of this bone is copied from the transform node every frame.
  80025. * @param transformNode defines the transform node to link to
  80026. */
  80027. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80028. /** Gets or sets current position (in local space) */
  80029. position: Vector3;
  80030. /** Gets or sets current rotation (in local space) */
  80031. rotation: Vector3;
  80032. /** Gets or sets current rotation quaternion (in local space) */
  80033. rotationQuaternion: Quaternion;
  80034. /** Gets or sets current scaling (in local space) */
  80035. scaling: Vector3;
  80036. /**
  80037. * Gets the animation properties override
  80038. */
  80039. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80040. private _decompose;
  80041. private _compose;
  80042. /**
  80043. * Update the base and local matrices
  80044. * @param matrix defines the new base or local matrix
  80045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80046. * @param updateLocalMatrix defines if the local matrix should be updated
  80047. */
  80048. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80049. /** @hidden */
  80050. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80051. /**
  80052. * Flag the bone as dirty (Forcing it to update everything)
  80053. */
  80054. markAsDirty(): void;
  80055. private _markAsDirtyAndCompose;
  80056. private _markAsDirtyAndDecompose;
  80057. /**
  80058. * Translate the bone in local or world space
  80059. * @param vec The amount to translate the bone
  80060. * @param space The space that the translation is in
  80061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80062. */
  80063. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80064. /**
  80065. * Set the postion of the bone in local or world space
  80066. * @param position The position to set the bone
  80067. * @param space The space that the position is in
  80068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80069. */
  80070. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80071. /**
  80072. * Set the absolute position of the bone (world space)
  80073. * @param position The position to set the bone
  80074. * @param mesh The mesh that this bone is attached to
  80075. */
  80076. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80077. /**
  80078. * Scale the bone on the x, y and z axes (in local space)
  80079. * @param x The amount to scale the bone on the x axis
  80080. * @param y The amount to scale the bone on the y axis
  80081. * @param z The amount to scale the bone on the z axis
  80082. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80083. */
  80084. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80085. /**
  80086. * Set the bone scaling in local space
  80087. * @param scale defines the scaling vector
  80088. */
  80089. setScale(scale: Vector3): void;
  80090. /**
  80091. * Gets the current scaling in local space
  80092. * @returns the current scaling vector
  80093. */
  80094. getScale(): Vector3;
  80095. /**
  80096. * Gets the current scaling in local space and stores it in a target vector
  80097. * @param result defines the target vector
  80098. */
  80099. getScaleToRef(result: Vector3): void;
  80100. /**
  80101. * Set the yaw, pitch, and roll of the bone in local or world space
  80102. * @param yaw The rotation of the bone on the y axis
  80103. * @param pitch The rotation of the bone on the x axis
  80104. * @param roll The rotation of the bone on the z axis
  80105. * @param space The space that the axes of rotation are in
  80106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80107. */
  80108. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80109. /**
  80110. * Add a rotation to the bone on an axis in local or world space
  80111. * @param axis The axis to rotate the bone on
  80112. * @param amount The amount to rotate the bone
  80113. * @param space The space that the axis is in
  80114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80115. */
  80116. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80117. /**
  80118. * Set the rotation of the bone to a particular axis angle in local or world space
  80119. * @param axis The axis to rotate the bone on
  80120. * @param angle The angle that the bone should be rotated to
  80121. * @param space The space that the axis is in
  80122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80123. */
  80124. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80125. /**
  80126. * Set the euler rotation of the bone in local of world space
  80127. * @param rotation The euler rotation that the bone should be set to
  80128. * @param space The space that the rotation is in
  80129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80130. */
  80131. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80132. /**
  80133. * Set the quaternion rotation of the bone in local of world space
  80134. * @param quat The quaternion rotation that the bone should be set to
  80135. * @param space The space that the rotation is in
  80136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80137. */
  80138. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80139. /**
  80140. * Set the rotation matrix of the bone in local of world space
  80141. * @param rotMat The rotation matrix that the bone should be set to
  80142. * @param space The space that the rotation is in
  80143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80144. */
  80145. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80146. private _rotateWithMatrix;
  80147. private _getNegativeRotationToRef;
  80148. /**
  80149. * Get the position of the bone in local or world space
  80150. * @param space The space that the returned position is in
  80151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80152. * @returns The position of the bone
  80153. */
  80154. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80155. /**
  80156. * Copy the position of the bone to a vector3 in local or world space
  80157. * @param space The space that the returned position is in
  80158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80159. * @param result The vector3 to copy the position to
  80160. */
  80161. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80162. /**
  80163. * Get the absolute position of the bone (world space)
  80164. * @param mesh The mesh that this bone is attached to
  80165. * @returns The absolute position of the bone
  80166. */
  80167. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80168. /**
  80169. * Copy the absolute position of the bone (world space) to the result param
  80170. * @param mesh The mesh that this bone is attached to
  80171. * @param result The vector3 to copy the absolute position to
  80172. */
  80173. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80174. /**
  80175. * Compute the absolute transforms of this bone and its children
  80176. */
  80177. computeAbsoluteTransforms(): void;
  80178. /**
  80179. * Get the world direction from an axis that is in the local space of the bone
  80180. * @param localAxis The local direction that is used to compute the world direction
  80181. * @param mesh The mesh that this bone is attached to
  80182. * @returns The world direction
  80183. */
  80184. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80185. /**
  80186. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80187. * @param localAxis The local direction that is used to compute the world direction
  80188. * @param mesh The mesh that this bone is attached to
  80189. * @param result The vector3 that the world direction will be copied to
  80190. */
  80191. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80192. /**
  80193. * Get the euler rotation of the bone in local or world space
  80194. * @param space The space that the rotation should be in
  80195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80196. * @returns The euler rotation
  80197. */
  80198. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80199. /**
  80200. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80201. * @param space The space that the rotation should be in
  80202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80203. * @param result The vector3 that the rotation should be copied to
  80204. */
  80205. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80206. /**
  80207. * Get the quaternion rotation of the bone in either local or world space
  80208. * @param space The space that the rotation should be in
  80209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80210. * @returns The quaternion rotation
  80211. */
  80212. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80213. /**
  80214. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80215. * @param space The space that the rotation should be in
  80216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80217. * @param result The quaternion that the rotation should be copied to
  80218. */
  80219. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80220. /**
  80221. * Get the rotation matrix of the bone in local or world space
  80222. * @param space The space that the rotation should be in
  80223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80224. * @returns The rotation matrix
  80225. */
  80226. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80227. /**
  80228. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either 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. * @param result The quaternion that the rotation should be copied to
  80232. */
  80233. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80234. /**
  80235. * Get the world position of a point that is in the local space of the bone
  80236. * @param position The local position
  80237. * @param mesh The mesh that this bone is attached to
  80238. * @returns The world position
  80239. */
  80240. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80241. /**
  80242. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80243. * @param position The local position
  80244. * @param mesh The mesh that this bone is attached to
  80245. * @param result The vector3 that the world position should be copied to
  80246. */
  80247. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80248. /**
  80249. * Get the local position of a point that is in world space
  80250. * @param position The world position
  80251. * @param mesh The mesh that this bone is attached to
  80252. * @returns The local position
  80253. */
  80254. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80255. /**
  80256. * Get the local position of a point that is in world space and copy it to the result param
  80257. * @param position The world position
  80258. * @param mesh The mesh that this bone is attached to
  80259. * @param result The vector3 that the local position should be copied to
  80260. */
  80261. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80262. }
  80263. }
  80264. declare module BABYLON {
  80265. /**
  80266. * Class used to store an actual running animation
  80267. */
  80268. export class Animatable {
  80269. /** defines the target object */
  80270. target: any;
  80271. /** defines the starting frame number (default is 0) */
  80272. fromFrame: number;
  80273. /** defines the ending frame number (default is 100) */
  80274. toFrame: number;
  80275. /** defines if the animation must loop (default is false) */
  80276. loopAnimation: boolean;
  80277. /** defines a callback to call when animation ends if it is not looping */
  80278. onAnimationEnd?: (() => void) | null | undefined;
  80279. /** defines a callback to call when animation loops */
  80280. onAnimationLoop?: (() => void) | null | undefined;
  80281. private _localDelayOffset;
  80282. private _pausedDelay;
  80283. private _runtimeAnimations;
  80284. private _paused;
  80285. private _scene;
  80286. private _speedRatio;
  80287. private _weight;
  80288. private _syncRoot;
  80289. /**
  80290. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80291. * This will only apply for non looping animation (default is true)
  80292. */
  80293. disposeOnEnd: boolean;
  80294. /**
  80295. * Gets a boolean indicating if the animation has started
  80296. */
  80297. animationStarted: boolean;
  80298. /**
  80299. * Observer raised when the animation ends
  80300. */
  80301. onAnimationEndObservable: Observable<Animatable>;
  80302. /**
  80303. * Observer raised when the animation loops
  80304. */
  80305. onAnimationLoopObservable: Observable<Animatable>;
  80306. /**
  80307. * Gets the root Animatable used to synchronize and normalize animations
  80308. */
  80309. readonly syncRoot: Animatable;
  80310. /**
  80311. * Gets the current frame of the first RuntimeAnimation
  80312. * Used to synchronize Animatables
  80313. */
  80314. readonly masterFrame: number;
  80315. /**
  80316. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80317. */
  80318. weight: number;
  80319. /**
  80320. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80321. */
  80322. speedRatio: number;
  80323. /**
  80324. * Creates a new Animatable
  80325. * @param scene defines the hosting scene
  80326. * @param target defines the target object
  80327. * @param fromFrame defines the starting frame number (default is 0)
  80328. * @param toFrame defines the ending frame number (default is 100)
  80329. * @param loopAnimation defines if the animation must loop (default is false)
  80330. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80331. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80332. * @param animations defines a group of animation to add to the new Animatable
  80333. * @param onAnimationLoop defines a callback to call when animation loops
  80334. */
  80335. constructor(scene: Scene,
  80336. /** defines the target object */
  80337. target: any,
  80338. /** defines the starting frame number (default is 0) */
  80339. fromFrame?: number,
  80340. /** defines the ending frame number (default is 100) */
  80341. toFrame?: number,
  80342. /** defines if the animation must loop (default is false) */
  80343. loopAnimation?: boolean, speedRatio?: number,
  80344. /** defines a callback to call when animation ends if it is not looping */
  80345. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80346. /** defines a callback to call when animation loops */
  80347. onAnimationLoop?: (() => void) | null | undefined);
  80348. /**
  80349. * Synchronize and normalize current Animatable with a source Animatable
  80350. * This is useful when using animation weights and when animations are not of the same length
  80351. * @param root defines the root Animatable to synchronize with
  80352. * @returns the current Animatable
  80353. */
  80354. syncWith(root: Animatable): Animatable;
  80355. /**
  80356. * Gets the list of runtime animations
  80357. * @returns an array of RuntimeAnimation
  80358. */
  80359. getAnimations(): RuntimeAnimation[];
  80360. /**
  80361. * Adds more animations to the current animatable
  80362. * @param target defines the target of the animations
  80363. * @param animations defines the new animations to add
  80364. */
  80365. appendAnimations(target: any, animations: Animation[]): void;
  80366. /**
  80367. * Gets the source animation for a specific property
  80368. * @param property defines the propertyu to look for
  80369. * @returns null or the source animation for the given property
  80370. */
  80371. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80372. /**
  80373. * Gets the runtime animation for a specific property
  80374. * @param property defines the propertyu to look for
  80375. * @returns null or the runtime animation for the given property
  80376. */
  80377. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80378. /**
  80379. * Resets the animatable to its original state
  80380. */
  80381. reset(): void;
  80382. /**
  80383. * Allows the animatable to blend with current running animations
  80384. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80385. * @param blendingSpeed defines the blending speed to use
  80386. */
  80387. enableBlending(blendingSpeed: number): void;
  80388. /**
  80389. * Disable animation blending
  80390. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80391. */
  80392. disableBlending(): void;
  80393. /**
  80394. * Jump directly to a given frame
  80395. * @param frame defines the frame to jump to
  80396. */
  80397. goToFrame(frame: number): void;
  80398. /**
  80399. * Pause the animation
  80400. */
  80401. pause(): void;
  80402. /**
  80403. * Restart the animation
  80404. */
  80405. restart(): void;
  80406. private _raiseOnAnimationEnd;
  80407. /**
  80408. * Stop and delete the current animation
  80409. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80410. * @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)
  80411. */
  80412. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80413. /**
  80414. * Wait asynchronously for the animation to end
  80415. * @returns a promise which will be fullfilled when the animation ends
  80416. */
  80417. waitAsync(): Promise<Animatable>;
  80418. /** @hidden */
  80419. _animate(delay: number): boolean;
  80420. }
  80421. interface Scene {
  80422. /** @hidden */
  80423. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80424. /** @hidden */
  80425. _processLateAnimationBindingsForMatrices(holder: {
  80426. totalWeight: number;
  80427. animations: RuntimeAnimation[];
  80428. originalValue: Matrix;
  80429. }): any;
  80430. /** @hidden */
  80431. _processLateAnimationBindingsForQuaternions(holder: {
  80432. totalWeight: number;
  80433. animations: RuntimeAnimation[];
  80434. originalValue: Quaternion;
  80435. }, refQuaternion: Quaternion): Quaternion;
  80436. /** @hidden */
  80437. _processLateAnimationBindings(): void;
  80438. /**
  80439. * Will start the animation sequence of a given target
  80440. * @param target defines the target
  80441. * @param from defines from which frame should animation start
  80442. * @param to defines until which frame should animation run.
  80443. * @param weight defines the weight to apply to the animation (1.0 by default)
  80444. * @param loop defines if the animation loops
  80445. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80446. * @param onAnimationEnd defines the function to be executed when the animation ends
  80447. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80448. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80449. * @param onAnimationLoop defines the callback to call when an animation loops
  80450. * @returns the animatable object created for this animation
  80451. */
  80452. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80453. /**
  80454. * Will start the animation sequence of a given target
  80455. * @param target defines the target
  80456. * @param from defines from which frame should animation start
  80457. * @param to defines until which frame should animation run.
  80458. * @param loop defines if the animation loops
  80459. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80460. * @param onAnimationEnd defines the function to be executed when the animation ends
  80461. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80462. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80463. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80464. * @param onAnimationLoop defines the callback to call when an animation loops
  80465. * @returns the animatable object created for this animation
  80466. */
  80467. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80468. /**
  80469. * Will start the animation sequence of a given target and its hierarchy
  80470. * @param target defines the target
  80471. * @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.
  80472. * @param from defines from which frame should animation start
  80473. * @param to defines until which frame should animation run.
  80474. * @param loop defines if the animation loops
  80475. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80476. * @param onAnimationEnd defines the function to be executed when the animation ends
  80477. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80478. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80479. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80480. * @param onAnimationLoop defines the callback to call when an animation loops
  80481. * @returns the list of created animatables
  80482. */
  80483. 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[];
  80484. /**
  80485. * Begin a new animation on a given node
  80486. * @param target defines the target where the animation will take place
  80487. * @param animations defines the list of animations to start
  80488. * @param from defines the initial value
  80489. * @param to defines the final value
  80490. * @param loop defines if you want animation to loop (off by default)
  80491. * @param speedRatio defines the speed ratio to apply to all animations
  80492. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80493. * @param onAnimationLoop defines the callback to call when an animation loops
  80494. * @returns the list of created animatables
  80495. */
  80496. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80497. /**
  80498. * Begin a new animation on a given node and its hierarchy
  80499. * @param target defines the root node where the animation will take place
  80500. * @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.
  80501. * @param animations defines the list of animations to start
  80502. * @param from defines the initial value
  80503. * @param to defines the final value
  80504. * @param loop defines if you want animation to loop (off by default)
  80505. * @param speedRatio defines the speed ratio to apply to all animations
  80506. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80507. * @param onAnimationLoop defines the callback to call when an animation loops
  80508. * @returns the list of animatables created for all nodes
  80509. */
  80510. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80511. /**
  80512. * Gets the animatable associated with a specific target
  80513. * @param target defines the target of the animatable
  80514. * @returns the required animatable if found
  80515. */
  80516. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80517. /**
  80518. * Gets all animatables associated with a given target
  80519. * @param target defines the target to look animatables for
  80520. * @returns an array of Animatables
  80521. */
  80522. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80523. /**
  80524. * Will stop the animation of the given target
  80525. * @param target - the target
  80526. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  80527. * @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)
  80528. */
  80529. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  80530. /**
  80531. * Stops and removes all animations that have been applied to the scene
  80532. */
  80533. stopAllAnimations(): void;
  80534. }
  80535. interface Bone {
  80536. /**
  80537. * Copy an animation range from another bone
  80538. * @param source defines the source bone
  80539. * @param rangeName defines the range name to copy
  80540. * @param frameOffset defines the frame offset
  80541. * @param rescaleAsRequired defines if rescaling must be applied if required
  80542. * @param skelDimensionsRatio defines the scaling ratio
  80543. * @returns true if operation was successful
  80544. */
  80545. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80546. }
  80547. }
  80548. declare module BABYLON {
  80549. /**
  80550. * Defines how a node can be built from a string name.
  80551. */
  80552. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80553. /**
  80554. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80555. */
  80556. export class Node implements IBehaviorAware<Node> {
  80557. /** @hidden */
  80558. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80559. private static _NodeConstructors;
  80560. /**
  80561. * Add a new node constructor
  80562. * @param type defines the type name of the node to construct
  80563. * @param constructorFunc defines the constructor function
  80564. */
  80565. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80566. /**
  80567. * Returns a node constructor based on type name
  80568. * @param type defines the type name
  80569. * @param name defines the new node name
  80570. * @param scene defines the hosting scene
  80571. * @param options defines optional options to transmit to constructors
  80572. * @returns the new constructor or null
  80573. */
  80574. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80575. /**
  80576. * Gets or sets the name of the node
  80577. */
  80578. name: string;
  80579. /**
  80580. * Gets or sets the id of the node
  80581. */
  80582. id: string;
  80583. /**
  80584. * Gets or sets the unique id of the node
  80585. */
  80586. uniqueId: number;
  80587. /**
  80588. * Gets or sets a string used to store user defined state for the node
  80589. */
  80590. state: string;
  80591. /**
  80592. * Gets or sets an object used to store user defined information for the node
  80593. */
  80594. metadata: any;
  80595. /**
  80596. * For internal use only. Please do not use.
  80597. */
  80598. reservedDataStore: any;
  80599. /**
  80600. * Gets or sets a boolean used to define if the node must be serialized
  80601. */
  80602. doNotSerialize: boolean;
  80603. /** @hidden */
  80604. _isDisposed: boolean;
  80605. /**
  80606. * Gets a list of Animations associated with the node
  80607. */
  80608. animations: Animation[];
  80609. protected _ranges: {
  80610. [name: string]: Nullable<AnimationRange>;
  80611. };
  80612. /**
  80613. * Callback raised when the node is ready to be used
  80614. */
  80615. onReady: (node: Node) => void;
  80616. private _isEnabled;
  80617. private _isParentEnabled;
  80618. private _isReady;
  80619. /** @hidden */
  80620. _currentRenderId: number;
  80621. private _parentRenderId;
  80622. protected _childRenderId: number;
  80623. /** @hidden */
  80624. _waitingParentId: Nullable<string>;
  80625. /** @hidden */
  80626. _scene: Scene;
  80627. /** @hidden */
  80628. _cache: any;
  80629. private _parentNode;
  80630. private _children;
  80631. /** @hidden */
  80632. _worldMatrix: Matrix;
  80633. /** @hidden */
  80634. _worldMatrixDeterminant: number;
  80635. /** @hidden */
  80636. private _sceneRootNodesIndex;
  80637. /**
  80638. * Gets a boolean indicating if the node has been disposed
  80639. * @returns true if the node was disposed
  80640. */
  80641. isDisposed(): boolean;
  80642. /**
  80643. * Gets or sets the parent of the node
  80644. */
  80645. parent: Nullable<Node>;
  80646. private addToSceneRootNodes;
  80647. private removeFromSceneRootNodes;
  80648. private _animationPropertiesOverride;
  80649. /**
  80650. * Gets or sets the animation properties override
  80651. */
  80652. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80653. /**
  80654. * Gets a string idenfifying the name of the class
  80655. * @returns "Node" string
  80656. */
  80657. getClassName(): string;
  80658. /** @hidden */
  80659. readonly _isNode: boolean;
  80660. /**
  80661. * An event triggered when the mesh is disposed
  80662. */
  80663. onDisposeObservable: Observable<Node>;
  80664. private _onDisposeObserver;
  80665. /**
  80666. * Sets a callback that will be raised when the node will be disposed
  80667. */
  80668. onDispose: () => void;
  80669. /**
  80670. * Creates a new Node
  80671. * @param name the name and id to be given to this node
  80672. * @param scene the scene this node will be added to
  80673. * @param addToRootNodes the node will be added to scene.rootNodes
  80674. */
  80675. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  80676. /**
  80677. * Gets the scene of the node
  80678. * @returns a scene
  80679. */
  80680. getScene(): Scene;
  80681. /**
  80682. * Gets the engine of the node
  80683. * @returns a Engine
  80684. */
  80685. getEngine(): Engine;
  80686. private _behaviors;
  80687. /**
  80688. * Attach a behavior to the node
  80689. * @see http://doc.babylonjs.com/features/behaviour
  80690. * @param behavior defines the behavior to attach
  80691. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  80692. * @returns the current Node
  80693. */
  80694. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  80695. /**
  80696. * Remove an attached behavior
  80697. * @see http://doc.babylonjs.com/features/behaviour
  80698. * @param behavior defines the behavior to attach
  80699. * @returns the current Node
  80700. */
  80701. removeBehavior(behavior: Behavior<Node>): Node;
  80702. /**
  80703. * Gets the list of attached behaviors
  80704. * @see http://doc.babylonjs.com/features/behaviour
  80705. */
  80706. readonly behaviors: Behavior<Node>[];
  80707. /**
  80708. * Gets an attached behavior by name
  80709. * @param name defines the name of the behavior to look for
  80710. * @see http://doc.babylonjs.com/features/behaviour
  80711. * @returns null if behavior was not found else the requested behavior
  80712. */
  80713. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  80714. /**
  80715. * Returns the latest update of the World matrix
  80716. * @returns a Matrix
  80717. */
  80718. getWorldMatrix(): Matrix;
  80719. /** @hidden */
  80720. _getWorldMatrixDeterminant(): number;
  80721. /**
  80722. * Returns directly the latest state of the mesh World matrix.
  80723. * A Matrix is returned.
  80724. */
  80725. readonly worldMatrixFromCache: Matrix;
  80726. /** @hidden */
  80727. _initCache(): void;
  80728. /** @hidden */
  80729. updateCache(force?: boolean): void;
  80730. /** @hidden */
  80731. _updateCache(ignoreParentClass?: boolean): void;
  80732. /** @hidden */
  80733. _isSynchronized(): boolean;
  80734. /** @hidden */
  80735. _markSyncedWithParent(): void;
  80736. /** @hidden */
  80737. isSynchronizedWithParent(): boolean;
  80738. /** @hidden */
  80739. isSynchronized(): boolean;
  80740. /**
  80741. * Is this node ready to be used/rendered
  80742. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80743. * @return true if the node is ready
  80744. */
  80745. isReady(completeCheck?: boolean): boolean;
  80746. /**
  80747. * Is this node enabled?
  80748. * 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
  80749. * @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
  80750. * @return whether this node (and its parent) is enabled
  80751. */
  80752. isEnabled(checkAncestors?: boolean): boolean;
  80753. /** @hidden */
  80754. protected _syncParentEnabledState(): void;
  80755. /**
  80756. * Set the enabled state of this node
  80757. * @param value defines the new enabled state
  80758. */
  80759. setEnabled(value: boolean): void;
  80760. /**
  80761. * Is this node a descendant of the given node?
  80762. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  80763. * @param ancestor defines the parent node to inspect
  80764. * @returns a boolean indicating if this node is a descendant of the given node
  80765. */
  80766. isDescendantOf(ancestor: Node): boolean;
  80767. /** @hidden */
  80768. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  80769. /**
  80770. * Will return all nodes that have this node as ascendant
  80771. * @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
  80772. * @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
  80773. * @return all children nodes of all types
  80774. */
  80775. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  80776. /**
  80777. * Get all child-meshes of this node
  80778. * @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
  80779. * @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
  80780. * @returns an array of AbstractMesh
  80781. */
  80782. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  80783. /**
  80784. * Get all direct children of this node
  80785. * @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
  80786. * @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)
  80787. * @returns an array of Node
  80788. */
  80789. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  80790. /** @hidden */
  80791. _setReady(state: boolean): void;
  80792. /**
  80793. * Get an animation by name
  80794. * @param name defines the name of the animation to look for
  80795. * @returns null if not found else the requested animation
  80796. */
  80797. getAnimationByName(name: string): Nullable<Animation>;
  80798. /**
  80799. * Creates an animation range for this node
  80800. * @param name defines the name of the range
  80801. * @param from defines the starting key
  80802. * @param to defines the end key
  80803. */
  80804. createAnimationRange(name: string, from: number, to: number): void;
  80805. /**
  80806. * Delete a specific animation range
  80807. * @param name defines the name of the range to delete
  80808. * @param deleteFrames defines if animation frames from the range must be deleted as well
  80809. */
  80810. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80811. /**
  80812. * Get an animation range by name
  80813. * @param name defines the name of the animation range to look for
  80814. * @returns null if not found else the requested animation range
  80815. */
  80816. getAnimationRange(name: string): Nullable<AnimationRange>;
  80817. /**
  80818. * Will start the animation sequence
  80819. * @param name defines the range frames for animation sequence
  80820. * @param loop defines if the animation should loop (false by default)
  80821. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  80822. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  80823. * @returns the object created for this animation. If range does not exist, it will return null
  80824. */
  80825. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80826. /**
  80827. * Serialize animation ranges into a JSON compatible object
  80828. * @returns serialization object
  80829. */
  80830. serializeAnimationRanges(): any;
  80831. /**
  80832. * Computes the world matrix of the node
  80833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80834. * @returns the world matrix
  80835. */
  80836. computeWorldMatrix(force?: boolean): Matrix;
  80837. /**
  80838. * Releases resources associated with this node.
  80839. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80840. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80841. */
  80842. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80843. /**
  80844. * Parse animation range data from a serialization object and store them into a given node
  80845. * @param node defines where to store the animation ranges
  80846. * @param parsedNode defines the serialization object to read data from
  80847. * @param scene defines the hosting scene
  80848. */
  80849. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  80850. }
  80851. }
  80852. declare module BABYLON {
  80853. /**
  80854. * Class used to store any kind of animation
  80855. */
  80856. export class Animation {
  80857. /**Name of the animation */
  80858. name: string;
  80859. /**Property to animate */
  80860. targetProperty: string;
  80861. /**The frames per second of the animation */
  80862. framePerSecond: number;
  80863. /**The data type of the animation */
  80864. dataType: number;
  80865. /**The loop mode of the animation */
  80866. loopMode?: number | undefined;
  80867. /**Specifies if blending should be enabled */
  80868. enableBlending?: boolean | undefined;
  80869. /**
  80870. * Use matrix interpolation instead of using direct key value when animating matrices
  80871. */
  80872. static AllowMatricesInterpolation: boolean;
  80873. /**
  80874. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  80875. */
  80876. static AllowMatrixDecomposeForInterpolation: boolean;
  80877. /**
  80878. * Stores the key frames of the animation
  80879. */
  80880. private _keys;
  80881. /**
  80882. * Stores the easing function of the animation
  80883. */
  80884. private _easingFunction;
  80885. /**
  80886. * @hidden Internal use only
  80887. */
  80888. _runtimeAnimations: RuntimeAnimation[];
  80889. /**
  80890. * The set of event that will be linked to this animation
  80891. */
  80892. private _events;
  80893. /**
  80894. * Stores an array of target property paths
  80895. */
  80896. targetPropertyPath: string[];
  80897. /**
  80898. * Stores the blending speed of the animation
  80899. */
  80900. blendingSpeed: number;
  80901. /**
  80902. * Stores the animation ranges for the animation
  80903. */
  80904. private _ranges;
  80905. /**
  80906. * @hidden Internal use
  80907. */
  80908. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  80909. /**
  80910. * Sets up an animation
  80911. * @param property The property to animate
  80912. * @param animationType The animation type to apply
  80913. * @param framePerSecond The frames per second of the animation
  80914. * @param easingFunction The easing function used in the animation
  80915. * @returns The created animation
  80916. */
  80917. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  80918. /**
  80919. * Create and start an animation on a node
  80920. * @param name defines the name of the global animation that will be run on all nodes
  80921. * @param node defines the root node where the animation will take place
  80922. * @param targetProperty defines property to animate
  80923. * @param framePerSecond defines the number of frame per second yo use
  80924. * @param totalFrame defines the number of frames in total
  80925. * @param from defines the initial value
  80926. * @param to defines the final value
  80927. * @param loopMode defines which loop mode you want to use (off by default)
  80928. * @param easingFunction defines the easing function to use (linear by default)
  80929. * @param onAnimationEnd defines the callback to call when animation end
  80930. * @returns the animatable created for this animation
  80931. */
  80932. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80933. /**
  80934. * Create and start an animation on a node and its descendants
  80935. * @param name defines the name of the global animation that will be run on all nodes
  80936. * @param node defines the root node where the animation will take place
  80937. * @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
  80938. * @param targetProperty defines property to animate
  80939. * @param framePerSecond defines the number of frame per second to use
  80940. * @param totalFrame defines the number of frames in total
  80941. * @param from defines the initial value
  80942. * @param to defines the final value
  80943. * @param loopMode defines which loop mode you want to use (off by default)
  80944. * @param easingFunction defines the easing function to use (linear by default)
  80945. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80946. * @returns the list of animatables created for all nodes
  80947. * @example https://www.babylonjs-playground.com/#MH0VLI
  80948. */
  80949. 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[]>;
  80950. /**
  80951. * Creates a new animation, merges it with the existing animations and starts it
  80952. * @param name Name of the animation
  80953. * @param node Node which contains the scene that begins the animations
  80954. * @param targetProperty Specifies which property to animate
  80955. * @param framePerSecond The frames per second of the animation
  80956. * @param totalFrame The total number of frames
  80957. * @param from The frame at the beginning of the animation
  80958. * @param to The frame at the end of the animation
  80959. * @param loopMode Specifies the loop mode of the animation
  80960. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  80961. * @param onAnimationEnd Callback to run once the animation is complete
  80962. * @returns Nullable animation
  80963. */
  80964. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80965. /**
  80966. * Transition property of an host to the target Value
  80967. * @param property The property to transition
  80968. * @param targetValue The target Value of the property
  80969. * @param host The object where the property to animate belongs
  80970. * @param scene Scene used to run the animation
  80971. * @param frameRate Framerate (in frame/s) to use
  80972. * @param transition The transition type we want to use
  80973. * @param duration The duration of the animation, in milliseconds
  80974. * @param onAnimationEnd Callback trigger at the end of the animation
  80975. * @returns Nullable animation
  80976. */
  80977. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  80978. /**
  80979. * Return the array of runtime animations currently using this animation
  80980. */
  80981. readonly runtimeAnimations: RuntimeAnimation[];
  80982. /**
  80983. * Specifies if any of the runtime animations are currently running
  80984. */
  80985. readonly hasRunningRuntimeAnimations: boolean;
  80986. /**
  80987. * Initializes the animation
  80988. * @param name Name of the animation
  80989. * @param targetProperty Property to animate
  80990. * @param framePerSecond The frames per second of the animation
  80991. * @param dataType The data type of the animation
  80992. * @param loopMode The loop mode of the animation
  80993. * @param enableBlending Specifies if blending should be enabled
  80994. */
  80995. constructor(
  80996. /**Name of the animation */
  80997. name: string,
  80998. /**Property to animate */
  80999. targetProperty: string,
  81000. /**The frames per second of the animation */
  81001. framePerSecond: number,
  81002. /**The data type of the animation */
  81003. dataType: number,
  81004. /**The loop mode of the animation */
  81005. loopMode?: number | undefined,
  81006. /**Specifies if blending should be enabled */
  81007. enableBlending?: boolean | undefined);
  81008. /**
  81009. * Converts the animation to a string
  81010. * @param fullDetails support for multiple levels of logging within scene loading
  81011. * @returns String form of the animation
  81012. */
  81013. toString(fullDetails?: boolean): string;
  81014. /**
  81015. * Add an event to this animation
  81016. * @param event Event to add
  81017. */
  81018. addEvent(event: AnimationEvent): void;
  81019. /**
  81020. * Remove all events found at the given frame
  81021. * @param frame The frame to remove events from
  81022. */
  81023. removeEvents(frame: number): void;
  81024. /**
  81025. * Retrieves all the events from the animation
  81026. * @returns Events from the animation
  81027. */
  81028. getEvents(): AnimationEvent[];
  81029. /**
  81030. * Creates an animation range
  81031. * @param name Name of the animation range
  81032. * @param from Starting frame of the animation range
  81033. * @param to Ending frame of the animation
  81034. */
  81035. createRange(name: string, from: number, to: number): void;
  81036. /**
  81037. * Deletes an animation range by name
  81038. * @param name Name of the animation range to delete
  81039. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81040. */
  81041. deleteRange(name: string, deleteFrames?: boolean): void;
  81042. /**
  81043. * Gets the animation range by name, or null if not defined
  81044. * @param name Name of the animation range
  81045. * @returns Nullable animation range
  81046. */
  81047. getRange(name: string): Nullable<AnimationRange>;
  81048. /**
  81049. * Gets the key frames from the animation
  81050. * @returns The key frames of the animation
  81051. */
  81052. getKeys(): Array<IAnimationKey>;
  81053. /**
  81054. * Gets the highest frame rate of the animation
  81055. * @returns Highest frame rate of the animation
  81056. */
  81057. getHighestFrame(): number;
  81058. /**
  81059. * Gets the easing function of the animation
  81060. * @returns Easing function of the animation
  81061. */
  81062. getEasingFunction(): IEasingFunction;
  81063. /**
  81064. * Sets the easing function of the animation
  81065. * @param easingFunction A custom mathematical formula for animation
  81066. */
  81067. setEasingFunction(easingFunction: EasingFunction): void;
  81068. /**
  81069. * Interpolates a scalar linearly
  81070. * @param startValue Start value of the animation curve
  81071. * @param endValue End value of the animation curve
  81072. * @param gradient Scalar amount to interpolate
  81073. * @returns Interpolated scalar value
  81074. */
  81075. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81076. /**
  81077. * Interpolates a scalar cubically
  81078. * @param startValue Start value of the animation curve
  81079. * @param outTangent End tangent of the animation
  81080. * @param endValue End value of the animation curve
  81081. * @param inTangent Start tangent of the animation curve
  81082. * @param gradient Scalar amount to interpolate
  81083. * @returns Interpolated scalar value
  81084. */
  81085. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81086. /**
  81087. * Interpolates a quaternion using a spherical linear interpolation
  81088. * @param startValue Start value of the animation curve
  81089. * @param endValue End value of the animation curve
  81090. * @param gradient Scalar amount to interpolate
  81091. * @returns Interpolated quaternion value
  81092. */
  81093. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81094. /**
  81095. * Interpolates a quaternion cubically
  81096. * @param startValue Start value of the animation curve
  81097. * @param outTangent End tangent of the animation curve
  81098. * @param endValue End value of the animation curve
  81099. * @param inTangent Start tangent of the animation curve
  81100. * @param gradient Scalar amount to interpolate
  81101. * @returns Interpolated quaternion value
  81102. */
  81103. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81104. /**
  81105. * Interpolates a Vector3 linearl
  81106. * @param startValue Start value of the animation curve
  81107. * @param endValue End value of the animation curve
  81108. * @param gradient Scalar amount to interpolate
  81109. * @returns Interpolated scalar value
  81110. */
  81111. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81112. /**
  81113. * Interpolates a Vector3 cubically
  81114. * @param startValue Start value of the animation curve
  81115. * @param outTangent End tangent of the animation
  81116. * @param endValue End value of the animation curve
  81117. * @param inTangent Start tangent of the animation curve
  81118. * @param gradient Scalar amount to interpolate
  81119. * @returns InterpolatedVector3 value
  81120. */
  81121. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81122. /**
  81123. * Interpolates a Vector2 linearly
  81124. * @param startValue Start value of the animation curve
  81125. * @param endValue End value of the animation curve
  81126. * @param gradient Scalar amount to interpolate
  81127. * @returns Interpolated Vector2 value
  81128. */
  81129. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81130. /**
  81131. * Interpolates a Vector2 cubically
  81132. * @param startValue Start value of the animation curve
  81133. * @param outTangent End tangent of the animation
  81134. * @param endValue End value of the animation curve
  81135. * @param inTangent Start tangent of the animation curve
  81136. * @param gradient Scalar amount to interpolate
  81137. * @returns Interpolated Vector2 value
  81138. */
  81139. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81140. /**
  81141. * Interpolates a size linearly
  81142. * @param startValue Start value of the animation curve
  81143. * @param endValue End value of the animation curve
  81144. * @param gradient Scalar amount to interpolate
  81145. * @returns Interpolated Size value
  81146. */
  81147. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81148. /**
  81149. * Interpolates a Color3 linearly
  81150. * @param startValue Start value of the animation curve
  81151. * @param endValue End value of the animation curve
  81152. * @param gradient Scalar amount to interpolate
  81153. * @returns Interpolated Color3 value
  81154. */
  81155. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81156. /**
  81157. * @hidden Internal use only
  81158. */
  81159. _getKeyValue(value: any): any;
  81160. /**
  81161. * @hidden Internal use only
  81162. */
  81163. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81164. /**
  81165. * Defines the function to use to interpolate matrices
  81166. * @param startValue defines the start matrix
  81167. * @param endValue defines the end matrix
  81168. * @param gradient defines the gradient between both matrices
  81169. * @param result defines an optional target matrix where to store the interpolation
  81170. * @returns the interpolated matrix
  81171. */
  81172. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81173. /**
  81174. * Makes a copy of the animation
  81175. * @returns Cloned animation
  81176. */
  81177. clone(): Animation;
  81178. /**
  81179. * Sets the key frames of the animation
  81180. * @param values The animation key frames to set
  81181. */
  81182. setKeys(values: Array<IAnimationKey>): void;
  81183. /**
  81184. * Serializes the animation to an object
  81185. * @returns Serialized object
  81186. */
  81187. serialize(): any;
  81188. /**
  81189. * Float animation type
  81190. */
  81191. private static _ANIMATIONTYPE_FLOAT;
  81192. /**
  81193. * Vector3 animation type
  81194. */
  81195. private static _ANIMATIONTYPE_VECTOR3;
  81196. /**
  81197. * Quaternion animation type
  81198. */
  81199. private static _ANIMATIONTYPE_QUATERNION;
  81200. /**
  81201. * Matrix animation type
  81202. */
  81203. private static _ANIMATIONTYPE_MATRIX;
  81204. /**
  81205. * Color3 animation type
  81206. */
  81207. private static _ANIMATIONTYPE_COLOR3;
  81208. /**
  81209. * Vector2 animation type
  81210. */
  81211. private static _ANIMATIONTYPE_VECTOR2;
  81212. /**
  81213. * Size animation type
  81214. */
  81215. private static _ANIMATIONTYPE_SIZE;
  81216. /**
  81217. * Relative Loop Mode
  81218. */
  81219. private static _ANIMATIONLOOPMODE_RELATIVE;
  81220. /**
  81221. * Cycle Loop Mode
  81222. */
  81223. private static _ANIMATIONLOOPMODE_CYCLE;
  81224. /**
  81225. * Constant Loop Mode
  81226. */
  81227. private static _ANIMATIONLOOPMODE_CONSTANT;
  81228. /**
  81229. * Get the float animation type
  81230. */
  81231. static readonly ANIMATIONTYPE_FLOAT: number;
  81232. /**
  81233. * Get the Vector3 animation type
  81234. */
  81235. static readonly ANIMATIONTYPE_VECTOR3: number;
  81236. /**
  81237. * Get the Vector2 animation type
  81238. */
  81239. static readonly ANIMATIONTYPE_VECTOR2: number;
  81240. /**
  81241. * Get the Size animation type
  81242. */
  81243. static readonly ANIMATIONTYPE_SIZE: number;
  81244. /**
  81245. * Get the Quaternion animation type
  81246. */
  81247. static readonly ANIMATIONTYPE_QUATERNION: number;
  81248. /**
  81249. * Get the Matrix animation type
  81250. */
  81251. static readonly ANIMATIONTYPE_MATRIX: number;
  81252. /**
  81253. * Get the Color3 animation type
  81254. */
  81255. static readonly ANIMATIONTYPE_COLOR3: number;
  81256. /**
  81257. * Get the Relative Loop Mode
  81258. */
  81259. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81260. /**
  81261. * Get the Cycle Loop Mode
  81262. */
  81263. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81264. /**
  81265. * Get the Constant Loop Mode
  81266. */
  81267. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81268. /** @hidden */
  81269. static _UniversalLerp(left: any, right: any, amount: number): any;
  81270. /**
  81271. * Parses an animation object and creates an animation
  81272. * @param parsedAnimation Parsed animation object
  81273. * @returns Animation object
  81274. */
  81275. static Parse(parsedAnimation: any): Animation;
  81276. /**
  81277. * Appends the serialized animations from the source animations
  81278. * @param source Source containing the animations
  81279. * @param destination Target to store the animations
  81280. */
  81281. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81282. }
  81283. }
  81284. declare module BABYLON {
  81285. /**
  81286. * Base class of all the textures in babylon.
  81287. * It groups all the common properties the materials, post process, lights... might need
  81288. * in order to make a correct use of the texture.
  81289. */
  81290. export class BaseTexture implements IAnimatable {
  81291. /**
  81292. * Default anisotropic filtering level for the application.
  81293. * It is set to 4 as a good tradeoff between perf and quality.
  81294. */
  81295. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81296. /**
  81297. * Gets or sets the unique id of the texture
  81298. */
  81299. uniqueId: number;
  81300. /**
  81301. * Define the name of the texture.
  81302. */
  81303. name: string;
  81304. /**
  81305. * Gets or sets an object used to store user defined information.
  81306. */
  81307. metadata: any;
  81308. /**
  81309. * For internal use only. Please do not use.
  81310. */
  81311. reservedDataStore: any;
  81312. private _hasAlpha;
  81313. /**
  81314. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81315. */
  81316. hasAlpha: boolean;
  81317. /**
  81318. * Defines if the alpha value should be determined via the rgb values.
  81319. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81320. */
  81321. getAlphaFromRGB: boolean;
  81322. /**
  81323. * Intensity or strength of the texture.
  81324. * It is commonly used by materials to fine tune the intensity of the texture
  81325. */
  81326. level: number;
  81327. /**
  81328. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81329. * This is part of the texture as textures usually maps to one uv set.
  81330. */
  81331. coordinatesIndex: number;
  81332. private _coordinatesMode;
  81333. /**
  81334. * How a texture is mapped.
  81335. *
  81336. * | Value | Type | Description |
  81337. * | ----- | ----------------------------------- | ----------- |
  81338. * | 0 | EXPLICIT_MODE | |
  81339. * | 1 | SPHERICAL_MODE | |
  81340. * | 2 | PLANAR_MODE | |
  81341. * | 3 | CUBIC_MODE | |
  81342. * | 4 | PROJECTION_MODE | |
  81343. * | 5 | SKYBOX_MODE | |
  81344. * | 6 | INVCUBIC_MODE | |
  81345. * | 7 | EQUIRECTANGULAR_MODE | |
  81346. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81347. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81348. */
  81349. coordinatesMode: number;
  81350. /**
  81351. * | Value | Type | Description |
  81352. * | ----- | ------------------ | ----------- |
  81353. * | 0 | CLAMP_ADDRESSMODE | |
  81354. * | 1 | WRAP_ADDRESSMODE | |
  81355. * | 2 | MIRROR_ADDRESSMODE | |
  81356. */
  81357. wrapU: number;
  81358. /**
  81359. * | Value | Type | Description |
  81360. * | ----- | ------------------ | ----------- |
  81361. * | 0 | CLAMP_ADDRESSMODE | |
  81362. * | 1 | WRAP_ADDRESSMODE | |
  81363. * | 2 | MIRROR_ADDRESSMODE | |
  81364. */
  81365. wrapV: number;
  81366. /**
  81367. * | Value | Type | Description |
  81368. * | ----- | ------------------ | ----------- |
  81369. * | 0 | CLAMP_ADDRESSMODE | |
  81370. * | 1 | WRAP_ADDRESSMODE | |
  81371. * | 2 | MIRROR_ADDRESSMODE | |
  81372. */
  81373. wrapR: number;
  81374. /**
  81375. * With compliant hardware and browser (supporting anisotropic filtering)
  81376. * this defines the level of anisotropic filtering in the texture.
  81377. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81378. */
  81379. anisotropicFilteringLevel: number;
  81380. /**
  81381. * Define if the texture is a cube texture or if false a 2d texture.
  81382. */
  81383. isCube: boolean;
  81384. /**
  81385. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81386. */
  81387. is3D: boolean;
  81388. /**
  81389. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81390. * HDR texture are usually stored in linear space.
  81391. * This only impacts the PBR and Background materials
  81392. */
  81393. gammaSpace: boolean;
  81394. /**
  81395. * Gets whether or not the texture contains RGBD data.
  81396. */
  81397. readonly isRGBD: boolean;
  81398. /**
  81399. * Is Z inverted in the texture (useful in a cube texture).
  81400. */
  81401. invertZ: boolean;
  81402. /**
  81403. * Are mip maps generated for this texture or not.
  81404. */
  81405. readonly noMipmap: boolean;
  81406. /**
  81407. * @hidden
  81408. */
  81409. lodLevelInAlpha: boolean;
  81410. /**
  81411. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81412. */
  81413. lodGenerationOffset: number;
  81414. /**
  81415. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81416. */
  81417. lodGenerationScale: number;
  81418. /**
  81419. * Define if the texture is a render target.
  81420. */
  81421. isRenderTarget: boolean;
  81422. /**
  81423. * Define the unique id of the texture in the scene.
  81424. */
  81425. readonly uid: string;
  81426. /**
  81427. * Return a string representation of the texture.
  81428. * @returns the texture as a string
  81429. */
  81430. toString(): string;
  81431. /**
  81432. * Get the class name of the texture.
  81433. * @returns "BaseTexture"
  81434. */
  81435. getClassName(): string;
  81436. /**
  81437. * Define the list of animation attached to the texture.
  81438. */
  81439. animations: Animation[];
  81440. /**
  81441. * An event triggered when the texture is disposed.
  81442. */
  81443. onDisposeObservable: Observable<BaseTexture>;
  81444. private _onDisposeObserver;
  81445. /**
  81446. * Callback triggered when the texture has been disposed.
  81447. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81448. */
  81449. onDispose: () => void;
  81450. /**
  81451. * Define the current state of the loading sequence when in delayed load mode.
  81452. */
  81453. delayLoadState: number;
  81454. private _scene;
  81455. /** @hidden */
  81456. _texture: Nullable<InternalTexture>;
  81457. private _uid;
  81458. /**
  81459. * Define if the texture is preventinga material to render or not.
  81460. * If not and the texture is not ready, the engine will use a default black texture instead.
  81461. */
  81462. readonly isBlocking: boolean;
  81463. /**
  81464. * Instantiates a new BaseTexture.
  81465. * Base class of all the textures in babylon.
  81466. * It groups all the common properties the materials, post process, lights... might need
  81467. * in order to make a correct use of the texture.
  81468. * @param scene Define the scene the texture blongs to
  81469. */
  81470. constructor(scene: Nullable<Scene>);
  81471. /**
  81472. * Get the scene the texture belongs to.
  81473. * @returns the scene or null if undefined
  81474. */
  81475. getScene(): Nullable<Scene>;
  81476. /**
  81477. * Get the texture transform matrix used to offset tile the texture for istance.
  81478. * @returns the transformation matrix
  81479. */
  81480. getTextureMatrix(): Matrix;
  81481. /**
  81482. * Get the texture reflection matrix used to rotate/transform the reflection.
  81483. * @returns the reflection matrix
  81484. */
  81485. getReflectionTextureMatrix(): Matrix;
  81486. /**
  81487. * Get the underlying lower level texture from Babylon.
  81488. * @returns the insternal texture
  81489. */
  81490. getInternalTexture(): Nullable<InternalTexture>;
  81491. /**
  81492. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81493. * @returns true if ready or not blocking
  81494. */
  81495. isReadyOrNotBlocking(): boolean;
  81496. /**
  81497. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81498. * @returns true if fully ready
  81499. */
  81500. isReady(): boolean;
  81501. private _cachedSize;
  81502. /**
  81503. * Get the size of the texture.
  81504. * @returns the texture size.
  81505. */
  81506. getSize(): ISize;
  81507. /**
  81508. * Get the base size of the texture.
  81509. * It can be different from the size if the texture has been resized for POT for instance
  81510. * @returns the base size
  81511. */
  81512. getBaseSize(): ISize;
  81513. /**
  81514. * Update the sampling mode of the texture.
  81515. * Default is Trilinear mode.
  81516. *
  81517. * | Value | Type | Description |
  81518. * | ----- | ------------------ | ----------- |
  81519. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81520. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81521. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81522. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81523. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81524. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81525. * | 7 | NEAREST_LINEAR | |
  81526. * | 8 | NEAREST_NEAREST | |
  81527. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81528. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81529. * | 11 | LINEAR_LINEAR | |
  81530. * | 12 | LINEAR_NEAREST | |
  81531. *
  81532. * > _mag_: magnification filter (close to the viewer)
  81533. * > _min_: minification filter (far from the viewer)
  81534. * > _mip_: filter used between mip map levels
  81535. *@param samplingMode Define the new sampling mode of the texture
  81536. */
  81537. updateSamplingMode(samplingMode: number): void;
  81538. /**
  81539. * Scales the texture if is `canRescale()`
  81540. * @param ratio the resize factor we want to use to rescale
  81541. */
  81542. scale(ratio: number): void;
  81543. /**
  81544. * Get if the texture can rescale.
  81545. */
  81546. readonly canRescale: boolean;
  81547. /** @hidden */
  81548. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  81549. /** @hidden */
  81550. _rebuild(): void;
  81551. /**
  81552. * Triggers the load sequence in delayed load mode.
  81553. */
  81554. delayLoad(): void;
  81555. /**
  81556. * Clones the texture.
  81557. * @returns the cloned texture
  81558. */
  81559. clone(): Nullable<BaseTexture>;
  81560. /**
  81561. * Get the texture underlying type (INT, FLOAT...)
  81562. */
  81563. readonly textureType: number;
  81564. /**
  81565. * Get the texture underlying format (RGB, RGBA...)
  81566. */
  81567. readonly textureFormat: number;
  81568. /**
  81569. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  81570. * This will returns an RGBA array buffer containing either in values (0-255) or
  81571. * float values (0-1) depending of the underlying buffer type.
  81572. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  81573. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  81574. * @param buffer defines a user defined buffer to fill with data (can be null)
  81575. * @returns The Array buffer containing the pixels data.
  81576. */
  81577. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  81578. /**
  81579. * Release and destroy the underlying lower level texture aka internalTexture.
  81580. */
  81581. releaseInternalTexture(): void;
  81582. /**
  81583. * Get the polynomial representation of the texture data.
  81584. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  81585. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  81586. */
  81587. sphericalPolynomial: Nullable<SphericalPolynomial>;
  81588. /** @hidden */
  81589. readonly _lodTextureHigh: Nullable<BaseTexture>;
  81590. /** @hidden */
  81591. readonly _lodTextureMid: Nullable<BaseTexture>;
  81592. /** @hidden */
  81593. readonly _lodTextureLow: Nullable<BaseTexture>;
  81594. /**
  81595. * Dispose the texture and release its associated resources.
  81596. */
  81597. dispose(): void;
  81598. /**
  81599. * Serialize the texture into a JSON representation that can be parsed later on.
  81600. * @returns the JSON representation of the texture
  81601. */
  81602. serialize(): any;
  81603. /**
  81604. * Helper function to be called back once a list of texture contains only ready textures.
  81605. * @param textures Define the list of textures to wait for
  81606. * @param callback Define the callback triggered once the entire list will be ready
  81607. */
  81608. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  81609. }
  81610. }
  81611. declare module BABYLON {
  81612. /**
  81613. * Uniform buffer objects.
  81614. *
  81615. * Handles blocks of uniform on the GPU.
  81616. *
  81617. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81618. *
  81619. * For more information, please refer to :
  81620. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81621. */
  81622. export class UniformBuffer {
  81623. private _engine;
  81624. private _buffer;
  81625. private _data;
  81626. private _bufferData;
  81627. private _dynamic?;
  81628. private _uniformLocations;
  81629. private _uniformSizes;
  81630. private _uniformLocationPointer;
  81631. private _needSync;
  81632. private _noUBO;
  81633. private _currentEffect;
  81634. private static _MAX_UNIFORM_SIZE;
  81635. private static _tempBuffer;
  81636. /**
  81637. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81638. * This is dynamic to allow compat with webgl 1 and 2.
  81639. * You will need to pass the name of the uniform as well as the value.
  81640. */
  81641. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81642. /**
  81643. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81644. * This is dynamic to allow compat with webgl 1 and 2.
  81645. * You will need to pass the name of the uniform as well as the value.
  81646. */
  81647. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81648. /**
  81649. * Lambda to Update a single float in a uniform buffer.
  81650. * This is dynamic to allow compat with webgl 1 and 2.
  81651. * You will need to pass the name of the uniform as well as the value.
  81652. */
  81653. updateFloat: (name: string, x: number) => void;
  81654. /**
  81655. * Lambda to Update a vec2 of float in a uniform buffer.
  81656. * This is dynamic to allow compat with webgl 1 and 2.
  81657. * You will need to pass the name of the uniform as well as the value.
  81658. */
  81659. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81660. /**
  81661. * Lambda to Update a vec3 of float in a uniform buffer.
  81662. * This is dynamic to allow compat with webgl 1 and 2.
  81663. * You will need to pass the name of the uniform as well as the value.
  81664. */
  81665. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81666. /**
  81667. * Lambda to Update a vec4 of float in a uniform buffer.
  81668. * This is dynamic to allow compat with webgl 1 and 2.
  81669. * You will need to pass the name of the uniform as well as the value.
  81670. */
  81671. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81672. /**
  81673. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81674. * This is dynamic to allow compat with webgl 1 and 2.
  81675. * You will need to pass the name of the uniform as well as the value.
  81676. */
  81677. updateMatrix: (name: string, mat: Matrix) => void;
  81678. /**
  81679. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81680. * This is dynamic to allow compat with webgl 1 and 2.
  81681. * You will need to pass the name of the uniform as well as the value.
  81682. */
  81683. updateVector3: (name: string, vector: Vector3) => void;
  81684. /**
  81685. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81686. * This is dynamic to allow compat with webgl 1 and 2.
  81687. * You will need to pass the name of the uniform as well as the value.
  81688. */
  81689. updateVector4: (name: string, vector: Vector4) => void;
  81690. /**
  81691. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81692. * This is dynamic to allow compat with webgl 1 and 2.
  81693. * You will need to pass the name of the uniform as well as the value.
  81694. */
  81695. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81696. /**
  81697. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81698. * This is dynamic to allow compat with webgl 1 and 2.
  81699. * You will need to pass the name of the uniform as well as the value.
  81700. */
  81701. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81702. /**
  81703. * Instantiates a new Uniform buffer objects.
  81704. *
  81705. * Handles blocks of uniform on the GPU.
  81706. *
  81707. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81708. *
  81709. * For more information, please refer to :
  81710. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81711. * @param engine Define the engine the buffer is associated with
  81712. * @param data Define the data contained in the buffer
  81713. * @param dynamic Define if the buffer is updatable
  81714. */
  81715. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81716. /**
  81717. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81718. * or just falling back on setUniformXXX calls.
  81719. */
  81720. readonly useUbo: boolean;
  81721. /**
  81722. * Indicates if the WebGL underlying uniform buffer is in sync
  81723. * with the javascript cache data.
  81724. */
  81725. readonly isSync: boolean;
  81726. /**
  81727. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81728. * Also, a dynamic UniformBuffer will disable cache verification and always
  81729. * update the underlying WebGL uniform buffer to the GPU.
  81730. * @returns if Dynamic, otherwise false
  81731. */
  81732. isDynamic(): boolean;
  81733. /**
  81734. * The data cache on JS side.
  81735. * @returns the underlying data as a float array
  81736. */
  81737. getData(): Float32Array;
  81738. /**
  81739. * The underlying WebGL Uniform buffer.
  81740. * @returns the webgl buffer
  81741. */
  81742. getBuffer(): Nullable<WebGLBuffer>;
  81743. /**
  81744. * std140 layout specifies how to align data within an UBO structure.
  81745. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81746. * for specs.
  81747. */
  81748. private _fillAlignment;
  81749. /**
  81750. * Adds an uniform in the buffer.
  81751. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81752. * for the layout to be correct !
  81753. * @param name Name of the uniform, as used in the uniform block in the shader.
  81754. * @param size Data size, or data directly.
  81755. */
  81756. addUniform(name: string, size: number | number[]): void;
  81757. /**
  81758. * Adds a Matrix 4x4 to the uniform buffer.
  81759. * @param name Name of the uniform, as used in the uniform block in the shader.
  81760. * @param mat A 4x4 matrix.
  81761. */
  81762. addMatrix(name: string, mat: Matrix): void;
  81763. /**
  81764. * Adds a vec2 to the uniform buffer.
  81765. * @param name Name of the uniform, as used in the uniform block in the shader.
  81766. * @param x Define the x component value of the vec2
  81767. * @param y Define the y component value of the vec2
  81768. */
  81769. addFloat2(name: string, x: number, y: number): void;
  81770. /**
  81771. * Adds a vec3 to the uniform buffer.
  81772. * @param name Name of the uniform, as used in the uniform block in the shader.
  81773. * @param x Define the x component value of the vec3
  81774. * @param y Define the y component value of the vec3
  81775. * @param z Define the z component value of the vec3
  81776. */
  81777. addFloat3(name: string, x: number, y: number, z: number): void;
  81778. /**
  81779. * Adds a vec3 to the uniform buffer.
  81780. * @param name Name of the uniform, as used in the uniform block in the shader.
  81781. * @param color Define the vec3 from a Color
  81782. */
  81783. addColor3(name: string, color: Color3): void;
  81784. /**
  81785. * Adds a vec4 to the uniform buffer.
  81786. * @param name Name of the uniform, as used in the uniform block in the shader.
  81787. * @param color Define the rgb components from a Color
  81788. * @param alpha Define the a component of the vec4
  81789. */
  81790. addColor4(name: string, color: Color3, alpha: number): void;
  81791. /**
  81792. * Adds a vec3 to the uniform buffer.
  81793. * @param name Name of the uniform, as used in the uniform block in the shader.
  81794. * @param vector Define the vec3 components from a Vector
  81795. */
  81796. addVector3(name: string, vector: Vector3): void;
  81797. /**
  81798. * Adds a Matrix 3x3 to the uniform buffer.
  81799. * @param name Name of the uniform, as used in the uniform block in the shader.
  81800. */
  81801. addMatrix3x3(name: string): void;
  81802. /**
  81803. * Adds a Matrix 2x2 to the uniform buffer.
  81804. * @param name Name of the uniform, as used in the uniform block in the shader.
  81805. */
  81806. addMatrix2x2(name: string): void;
  81807. /**
  81808. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81809. */
  81810. create(): void;
  81811. /** @hidden */
  81812. _rebuild(): void;
  81813. /**
  81814. * Updates the WebGL Uniform Buffer on the GPU.
  81815. * If the `dynamic` flag is set to true, no cache comparison is done.
  81816. * Otherwise, the buffer will be updated only if the cache differs.
  81817. */
  81818. update(): void;
  81819. /**
  81820. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81821. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81822. * @param data Define the flattened data
  81823. * @param size Define the size of the data.
  81824. */
  81825. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81826. private _updateMatrix3x3ForUniform;
  81827. private _updateMatrix3x3ForEffect;
  81828. private _updateMatrix2x2ForEffect;
  81829. private _updateMatrix2x2ForUniform;
  81830. private _updateFloatForEffect;
  81831. private _updateFloatForUniform;
  81832. private _updateFloat2ForEffect;
  81833. private _updateFloat2ForUniform;
  81834. private _updateFloat3ForEffect;
  81835. private _updateFloat3ForUniform;
  81836. private _updateFloat4ForEffect;
  81837. private _updateFloat4ForUniform;
  81838. private _updateMatrixForEffect;
  81839. private _updateMatrixForUniform;
  81840. private _updateVector3ForEffect;
  81841. private _updateVector3ForUniform;
  81842. private _updateVector4ForEffect;
  81843. private _updateVector4ForUniform;
  81844. private _updateColor3ForEffect;
  81845. private _updateColor3ForUniform;
  81846. private _updateColor4ForEffect;
  81847. private _updateColor4ForUniform;
  81848. /**
  81849. * Sets a sampler uniform on the effect.
  81850. * @param name Define the name of the sampler.
  81851. * @param texture Define the texture to set in the sampler
  81852. */
  81853. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81854. /**
  81855. * Directly updates the value of the uniform in the cache AND on 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. */
  81859. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81860. /**
  81861. * Binds this uniform buffer to an effect.
  81862. * @param effect Define the effect to bind the buffer to
  81863. * @param name Name of the uniform block in the shader.
  81864. */
  81865. bindToEffect(effect: Effect, name: string): void;
  81866. /**
  81867. * Disposes the uniform buffer.
  81868. */
  81869. dispose(): void;
  81870. }
  81871. }
  81872. declare module BABYLON {
  81873. /**
  81874. * This represents the required contract to create a new type of texture loader.
  81875. */
  81876. export interface IInternalTextureLoader {
  81877. /**
  81878. * Defines wether the loader supports cascade loading the different faces.
  81879. */
  81880. supportCascades: boolean;
  81881. /**
  81882. * This returns if the loader support the current file information.
  81883. * @param extension defines the file extension of the file being loaded
  81884. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81885. * @param fallback defines the fallback internal texture if any
  81886. * @param isBase64 defines whether the texture is encoded as a base64
  81887. * @param isBuffer defines whether the texture data are stored as a buffer
  81888. * @returns true if the loader can load the specified file
  81889. */
  81890. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  81891. /**
  81892. * Transform the url before loading if required.
  81893. * @param rootUrl the url of the texture
  81894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81895. * @returns the transformed texture
  81896. */
  81897. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  81898. /**
  81899. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  81900. * @param rootUrl the url of the texture
  81901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81902. * @returns the fallback texture
  81903. */
  81904. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  81905. /**
  81906. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  81907. * @param data contains the texture data
  81908. * @param texture defines the BabylonJS internal texture
  81909. * @param createPolynomials will be true if polynomials have been requested
  81910. * @param onLoad defines the callback to trigger once the texture is ready
  81911. * @param onError defines the callback to trigger in case of error
  81912. */
  81913. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81914. /**
  81915. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  81916. * @param data contains the texture data
  81917. * @param texture defines the BabylonJS internal texture
  81918. * @param callback defines the method to call once ready to upload
  81919. */
  81920. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81921. }
  81922. }
  81923. declare module BABYLON {
  81924. /**
  81925. * Creation options of the multi render target texture.
  81926. */
  81927. export interface IMultiRenderTargetOptions {
  81928. /**
  81929. * Define if the texture needs to create mip maps after render.
  81930. */
  81931. generateMipMaps?: boolean;
  81932. /**
  81933. * Define the types of all the draw buffers we want to create
  81934. */
  81935. types?: number[];
  81936. /**
  81937. * Define the sampling modes of all the draw buffers we want to create
  81938. */
  81939. samplingModes?: number[];
  81940. /**
  81941. * Define if a depth buffer is required
  81942. */
  81943. generateDepthBuffer?: boolean;
  81944. /**
  81945. * Define if a stencil buffer is required
  81946. */
  81947. generateStencilBuffer?: boolean;
  81948. /**
  81949. * Define if a depth texture is required instead of a depth buffer
  81950. */
  81951. generateDepthTexture?: boolean;
  81952. /**
  81953. * Define the number of desired draw buffers
  81954. */
  81955. textureCount?: number;
  81956. /**
  81957. * Define if aspect ratio should be adapted to the texture or stay the scene one
  81958. */
  81959. doNotChangeAspectRatio?: boolean;
  81960. /**
  81961. * Define the default type of the buffers we are creating
  81962. */
  81963. defaultType?: number;
  81964. }
  81965. /**
  81966. * A multi render target, like a render target provides the ability to render to a texture.
  81967. * Unlike the render target, it can render to several draw buffers in one draw.
  81968. * This is specially interesting in deferred rendering or for any effects requiring more than
  81969. * just one color from a single pass.
  81970. */
  81971. export class MultiRenderTarget extends RenderTargetTexture {
  81972. private _internalTextures;
  81973. private _textures;
  81974. private _multiRenderTargetOptions;
  81975. /**
  81976. * Get if draw buffers are currently supported by the used hardware and browser.
  81977. */
  81978. readonly isSupported: boolean;
  81979. /**
  81980. * Get the list of textures generated by the multi render target.
  81981. */
  81982. readonly textures: Texture[];
  81983. /**
  81984. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  81985. */
  81986. readonly depthTexture: Texture;
  81987. /**
  81988. * Set the wrapping mode on U of all the textures we are rendering to.
  81989. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81990. */
  81991. wrapU: number;
  81992. /**
  81993. * Set the wrapping mode on V of all the textures we are rendering to.
  81994. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81995. */
  81996. wrapV: number;
  81997. /**
  81998. * Instantiate a new multi render target texture.
  81999. * A multi render target, like a render target provides the ability to render to a texture.
  82000. * Unlike the render target, it can render to several draw buffers in one draw.
  82001. * This is specially interesting in deferred rendering or for any effects requiring more than
  82002. * just one color from a single pass.
  82003. * @param name Define the name of the texture
  82004. * @param size Define the size of the buffers to render to
  82005. * @param count Define the number of target we are rendering into
  82006. * @param scene Define the scene the texture belongs to
  82007. * @param options Define the options used to create the multi render target
  82008. */
  82009. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82010. /** @hidden */
  82011. _rebuild(): void;
  82012. private _createInternalTextures;
  82013. private _createTextures;
  82014. /**
  82015. * Define the number of samples used if MSAA is enabled.
  82016. */
  82017. samples: number;
  82018. /**
  82019. * Resize all the textures in the multi render target.
  82020. * Be carrefull as it will recreate all the data in the new texture.
  82021. * @param size Define the new size
  82022. */
  82023. resize(size: any): void;
  82024. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82025. /**
  82026. * Dispose the render targets and their associated resources
  82027. */
  82028. dispose(): void;
  82029. /**
  82030. * Release all the underlying texture used as draw buffers.
  82031. */
  82032. releaseInternalTextures(): void;
  82033. }
  82034. }
  82035. declare module BABYLON {
  82036. /**
  82037. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82039. */
  82040. export class Analyser {
  82041. /**
  82042. * Gets or sets the smoothing
  82043. * @ignorenaming
  82044. */
  82045. SMOOTHING: number;
  82046. /**
  82047. * Gets or sets the FFT table size
  82048. * @ignorenaming
  82049. */
  82050. FFT_SIZE: number;
  82051. /**
  82052. * Gets or sets the bar graph amplitude
  82053. * @ignorenaming
  82054. */
  82055. BARGRAPHAMPLITUDE: number;
  82056. /**
  82057. * Gets or sets the position of the debug canvas
  82058. * @ignorenaming
  82059. */
  82060. DEBUGCANVASPOS: {
  82061. x: number;
  82062. y: number;
  82063. };
  82064. /**
  82065. * Gets or sets the debug canvas size
  82066. * @ignorenaming
  82067. */
  82068. DEBUGCANVASSIZE: {
  82069. width: number;
  82070. height: number;
  82071. };
  82072. private _byteFreqs;
  82073. private _byteTime;
  82074. private _floatFreqs;
  82075. private _webAudioAnalyser;
  82076. private _debugCanvas;
  82077. private _debugCanvasContext;
  82078. private _scene;
  82079. private _registerFunc;
  82080. private _audioEngine;
  82081. /**
  82082. * Creates a new analyser
  82083. * @param scene defines hosting scene
  82084. */
  82085. constructor(scene: Scene);
  82086. /**
  82087. * Get the number of data values you will have to play with for the visualization
  82088. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82089. * @returns a number
  82090. */
  82091. getFrequencyBinCount(): number;
  82092. /**
  82093. * Gets the current frequency data as a byte array
  82094. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82095. * @returns a Uint8Array
  82096. */
  82097. getByteFrequencyData(): Uint8Array;
  82098. /**
  82099. * Gets the current waveform as a byte array
  82100. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82101. * @returns a Uint8Array
  82102. */
  82103. getByteTimeDomainData(): Uint8Array;
  82104. /**
  82105. * Gets the current frequency data as a float array
  82106. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82107. * @returns a Float32Array
  82108. */
  82109. getFloatFrequencyData(): Float32Array;
  82110. /**
  82111. * Renders the debug canvas
  82112. */
  82113. drawDebugCanvas(): void;
  82114. /**
  82115. * Stops rendering the debug canvas and removes it
  82116. */
  82117. stopDebugCanvas(): void;
  82118. /**
  82119. * Connects two audio nodes
  82120. * @param inputAudioNode defines first node to connect
  82121. * @param outputAudioNode defines second node to connect
  82122. */
  82123. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82124. /**
  82125. * Releases all associated resources
  82126. */
  82127. dispose(): void;
  82128. }
  82129. }
  82130. declare module BABYLON {
  82131. /**
  82132. * This represents an audio engine and it is responsible
  82133. * to play, synchronize and analyse sounds throughout the application.
  82134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82135. */
  82136. export interface IAudioEngine extends IDisposable {
  82137. /**
  82138. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82139. */
  82140. readonly canUseWebAudio: boolean;
  82141. /**
  82142. * Gets the current AudioContext if available.
  82143. */
  82144. readonly audioContext: Nullable<AudioContext>;
  82145. /**
  82146. * The master gain node defines the global audio volume of your audio engine.
  82147. */
  82148. readonly masterGain: GainNode;
  82149. /**
  82150. * Gets whether or not mp3 are supported by your browser.
  82151. */
  82152. readonly isMP3supported: boolean;
  82153. /**
  82154. * Gets whether or not ogg are supported by your browser.
  82155. */
  82156. readonly isOGGsupported: boolean;
  82157. /**
  82158. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82159. * @ignoreNaming
  82160. */
  82161. WarnedWebAudioUnsupported: boolean;
  82162. /**
  82163. * Defines if the audio engine relies on a custom unlocked button.
  82164. * In this case, the embedded button will not be displayed.
  82165. */
  82166. useCustomUnlockedButton: boolean;
  82167. /**
  82168. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82169. */
  82170. readonly unlocked: boolean;
  82171. /**
  82172. * Event raised when audio has been unlocked on the browser.
  82173. */
  82174. onAudioUnlockedObservable: Observable<AudioEngine>;
  82175. /**
  82176. * Event raised when audio has been locked on the browser.
  82177. */
  82178. onAudioLockedObservable: Observable<AudioEngine>;
  82179. /**
  82180. * Flags the audio engine in Locked state.
  82181. * This happens due to new browser policies preventing audio to autoplay.
  82182. */
  82183. lock(): void;
  82184. /**
  82185. * Unlocks the audio engine once a user action has been done on the dom.
  82186. * This is helpful to resume play once browser policies have been satisfied.
  82187. */
  82188. unlock(): void;
  82189. }
  82190. /**
  82191. * This represents the default audio engine used in babylon.
  82192. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82194. */
  82195. export class AudioEngine implements IAudioEngine {
  82196. private _audioContext;
  82197. private _audioContextInitialized;
  82198. private _muteButton;
  82199. private _hostElement;
  82200. /**
  82201. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82202. */
  82203. canUseWebAudio: boolean;
  82204. /**
  82205. * The master gain node defines the global audio volume of your audio engine.
  82206. */
  82207. masterGain: GainNode;
  82208. /**
  82209. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82210. * @ignoreNaming
  82211. */
  82212. WarnedWebAudioUnsupported: boolean;
  82213. /**
  82214. * Gets whether or not mp3 are supported by your browser.
  82215. */
  82216. isMP3supported: boolean;
  82217. /**
  82218. * Gets whether or not ogg are supported by your browser.
  82219. */
  82220. isOGGsupported: boolean;
  82221. /**
  82222. * Gets whether audio has been unlocked on the device.
  82223. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82224. * a user interaction has happened.
  82225. */
  82226. unlocked: boolean;
  82227. /**
  82228. * Defines if the audio engine relies on a custom unlocked button.
  82229. * In this case, the embedded button will not be displayed.
  82230. */
  82231. useCustomUnlockedButton: boolean;
  82232. /**
  82233. * Event raised when audio has been unlocked on the browser.
  82234. */
  82235. onAudioUnlockedObservable: Observable<AudioEngine>;
  82236. /**
  82237. * Event raised when audio has been locked on the browser.
  82238. */
  82239. onAudioLockedObservable: Observable<AudioEngine>;
  82240. /**
  82241. * Gets the current AudioContext if available.
  82242. */
  82243. readonly audioContext: Nullable<AudioContext>;
  82244. private _connectedAnalyser;
  82245. /**
  82246. * Instantiates a new audio engine.
  82247. *
  82248. * There should be only one per page as some browsers restrict the number
  82249. * of audio contexts you can create.
  82250. * @param hostElement defines the host element where to display the mute icon if necessary
  82251. */
  82252. constructor(hostElement?: Nullable<HTMLElement>);
  82253. /**
  82254. * Flags the audio engine in Locked state.
  82255. * This happens due to new browser policies preventing audio to autoplay.
  82256. */
  82257. lock(): void;
  82258. /**
  82259. * Unlocks the audio engine once a user action has been done on the dom.
  82260. * This is helpful to resume play once browser policies have been satisfied.
  82261. */
  82262. unlock(): void;
  82263. private _resumeAudioContext;
  82264. private _initializeAudioContext;
  82265. private _tryToRun;
  82266. private _triggerRunningState;
  82267. private _triggerSuspendedState;
  82268. private _displayMuteButton;
  82269. private _moveButtonToTopLeft;
  82270. private _onResize;
  82271. private _hideMuteButton;
  82272. /**
  82273. * Destroy and release the resources associated with the audio ccontext.
  82274. */
  82275. dispose(): void;
  82276. /**
  82277. * Gets the global volume sets on the master gain.
  82278. * @returns the global volume if set or -1 otherwise
  82279. */
  82280. getGlobalVolume(): number;
  82281. /**
  82282. * Sets the global volume of your experience (sets on the master gain).
  82283. * @param newVolume Defines the new global volume of the application
  82284. */
  82285. setGlobalVolume(newVolume: number): void;
  82286. /**
  82287. * Connect the audio engine to an audio analyser allowing some amazing
  82288. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82290. * @param analyser The analyser to connect to the engine
  82291. */
  82292. connectToAnalyser(analyser: Analyser): void;
  82293. }
  82294. }
  82295. declare module BABYLON {
  82296. /**
  82297. * Interface used to present a loading screen while loading a scene
  82298. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82299. */
  82300. export interface ILoadingScreen {
  82301. /**
  82302. * Function called to display the loading screen
  82303. */
  82304. displayLoadingUI: () => void;
  82305. /**
  82306. * Function called to hide the loading screen
  82307. */
  82308. hideLoadingUI: () => void;
  82309. /**
  82310. * Gets or sets the color to use for the background
  82311. */
  82312. loadingUIBackgroundColor: string;
  82313. /**
  82314. * Gets or sets the text to display while loading
  82315. */
  82316. loadingUIText: string;
  82317. }
  82318. /**
  82319. * Class used for the default loading screen
  82320. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82321. */
  82322. export class DefaultLoadingScreen implements ILoadingScreen {
  82323. private _renderingCanvas;
  82324. private _loadingText;
  82325. private _loadingDivBackgroundColor;
  82326. private _loadingDiv;
  82327. private _loadingTextDiv;
  82328. /**
  82329. * Creates a new default loading screen
  82330. * @param _renderingCanvas defines the canvas used to render the scene
  82331. * @param _loadingText defines the default text to display
  82332. * @param _loadingDivBackgroundColor defines the default background color
  82333. */
  82334. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82335. /**
  82336. * Function called to display the loading screen
  82337. */
  82338. displayLoadingUI(): void;
  82339. /**
  82340. * Function called to hide the loading screen
  82341. */
  82342. hideLoadingUI(): void;
  82343. /**
  82344. * Gets or sets the text to display while loading
  82345. */
  82346. loadingUIText: string;
  82347. /**
  82348. * Gets or sets the color to use for the background
  82349. */
  82350. loadingUIBackgroundColor: string;
  82351. private _resizeLoadingUI;
  82352. }
  82353. }
  82354. declare module BABYLON {
  82355. /**
  82356. * Settings for finer control over video usage
  82357. */
  82358. export interface VideoTextureSettings {
  82359. /**
  82360. * Applies `autoplay` to video, if specified
  82361. */
  82362. autoPlay?: boolean;
  82363. /**
  82364. * Applies `loop` to video, if specified
  82365. */
  82366. loop?: boolean;
  82367. /**
  82368. * Automatically updates internal texture from video at every frame in the render loop
  82369. */
  82370. autoUpdateTexture: boolean;
  82371. /**
  82372. * Image src displayed during the video loading or until the user interacts with the video.
  82373. */
  82374. poster?: string;
  82375. }
  82376. /**
  82377. * If you want to display a video in your scene, this is the special texture for that.
  82378. * This special texture works similar to other textures, with the exception of a few parameters.
  82379. * @see https://doc.babylonjs.com/how_to/video_texture
  82380. */
  82381. export class VideoTexture extends Texture {
  82382. /**
  82383. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82384. */
  82385. readonly autoUpdateTexture: boolean;
  82386. /**
  82387. * The video instance used by the texture internally
  82388. */
  82389. readonly video: HTMLVideoElement;
  82390. private _onUserActionRequestedObservable;
  82391. /**
  82392. * Event triggerd when a dom action is required by the user to play the video.
  82393. * This happens due to recent changes in browser policies preventing video to auto start.
  82394. */
  82395. readonly onUserActionRequestedObservable: Observable<Texture>;
  82396. private _generateMipMaps;
  82397. private _engine;
  82398. private _stillImageCaptured;
  82399. private _displayingPosterTexture;
  82400. private _settings;
  82401. private _createInternalTextureOnEvent;
  82402. /**
  82403. * Creates a video texture.
  82404. * If you want to display a video in your scene, this is the special texture for that.
  82405. * This special texture works similar to other textures, with the exception of a few parameters.
  82406. * @see https://doc.babylonjs.com/how_to/video_texture
  82407. * @param name optional name, will detect from video source, if not defined
  82408. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82409. * @param scene is obviously the current scene.
  82410. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82411. * @param invertY is false by default but can be used to invert video on Y axis
  82412. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82413. * @param settings allows finer control over video usage
  82414. */
  82415. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82416. private _getName;
  82417. private _getVideo;
  82418. private _createInternalTexture;
  82419. private reset;
  82420. /**
  82421. * @hidden Internal method to initiate `update`.
  82422. */
  82423. _rebuild(): void;
  82424. /**
  82425. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82426. */
  82427. update(): void;
  82428. /**
  82429. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82430. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82431. */
  82432. updateTexture(isVisible: boolean): void;
  82433. protected _updateInternalTexture: () => void;
  82434. /**
  82435. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82436. * @param url New url.
  82437. */
  82438. updateURL(url: string): void;
  82439. /**
  82440. * Dispose the texture and release its associated resources.
  82441. */
  82442. dispose(): void;
  82443. /**
  82444. * Creates a video texture straight from your WebCam video feed.
  82445. * @param scene Define the scene the texture should be created in
  82446. * @param onReady Define a callback to triggered once the texture will be ready
  82447. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82448. */
  82449. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82450. minWidth: number;
  82451. maxWidth: number;
  82452. minHeight: number;
  82453. maxHeight: number;
  82454. deviceId: string;
  82455. }): void;
  82456. }
  82457. }
  82458. declare module BABYLON {
  82459. /**
  82460. * Interface for attribute information associated with buffer instanciation
  82461. */
  82462. export class InstancingAttributeInfo {
  82463. /**
  82464. * Index/offset of the attribute in the vertex shader
  82465. */
  82466. index: number;
  82467. /**
  82468. * size of the attribute, 1, 2, 3 or 4
  82469. */
  82470. attributeSize: number;
  82471. /**
  82472. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82473. * default is FLOAT
  82474. */
  82475. attribyteType: number;
  82476. /**
  82477. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82478. */
  82479. normalized: boolean;
  82480. /**
  82481. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82482. */
  82483. offset: number;
  82484. /**
  82485. * Name of the GLSL attribute, for debugging purpose only
  82486. */
  82487. attributeName: string;
  82488. }
  82489. /**
  82490. * Define options used to create a depth texture
  82491. */
  82492. export class DepthTextureCreationOptions {
  82493. /** Specifies whether or not a stencil should be allocated in the texture */
  82494. generateStencil?: boolean;
  82495. /** Specifies whether or not bilinear filtering is enable on the texture */
  82496. bilinearFiltering?: boolean;
  82497. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82498. comparisonFunction?: number;
  82499. /** Specifies if the created texture is a cube texture */
  82500. isCube?: boolean;
  82501. }
  82502. /**
  82503. * Class used to describe the capabilities of the engine relatively to the current browser
  82504. */
  82505. export class EngineCapabilities {
  82506. /** Maximum textures units per fragment shader */
  82507. maxTexturesImageUnits: number;
  82508. /** Maximum texture units per vertex shader */
  82509. maxVertexTextureImageUnits: number;
  82510. /** Maximum textures units in the entire pipeline */
  82511. maxCombinedTexturesImageUnits: number;
  82512. /** Maximum texture size */
  82513. maxTextureSize: number;
  82514. /** Maximum cube texture size */
  82515. maxCubemapTextureSize: number;
  82516. /** Maximum render texture size */
  82517. maxRenderTextureSize: number;
  82518. /** Maximum number of vertex attributes */
  82519. maxVertexAttribs: number;
  82520. /** Maximum number of varyings */
  82521. maxVaryingVectors: number;
  82522. /** Maximum number of uniforms per vertex shader */
  82523. maxVertexUniformVectors: number;
  82524. /** Maximum number of uniforms per fragment shader */
  82525. maxFragmentUniformVectors: number;
  82526. /** Defines if standard derivates (dx/dy) are supported */
  82527. standardDerivatives: boolean;
  82528. /** Defines if s3tc texture compression is supported */
  82529. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82530. /** Defines if pvrtc texture compression is supported */
  82531. pvrtc: any;
  82532. /** Defines if etc1 texture compression is supported */
  82533. etc1: any;
  82534. /** Defines if etc2 texture compression is supported */
  82535. etc2: any;
  82536. /** Defines if astc texture compression is supported */
  82537. astc: any;
  82538. /** Defines if float textures are supported */
  82539. textureFloat: boolean;
  82540. /** Defines if vertex array objects are supported */
  82541. vertexArrayObject: boolean;
  82542. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  82543. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  82544. /** Gets the maximum level of anisotropy supported */
  82545. maxAnisotropy: number;
  82546. /** Defines if instancing is supported */
  82547. instancedArrays: boolean;
  82548. /** Defines if 32 bits indices are supported */
  82549. uintIndices: boolean;
  82550. /** Defines if high precision shaders are supported */
  82551. highPrecisionShaderSupported: boolean;
  82552. /** Defines if depth reading in the fragment shader is supported */
  82553. fragmentDepthSupported: boolean;
  82554. /** Defines if float texture linear filtering is supported*/
  82555. textureFloatLinearFiltering: boolean;
  82556. /** Defines if rendering to float textures is supported */
  82557. textureFloatRender: boolean;
  82558. /** Defines if half float textures are supported*/
  82559. textureHalfFloat: boolean;
  82560. /** Defines if half float texture linear filtering is supported*/
  82561. textureHalfFloatLinearFiltering: boolean;
  82562. /** Defines if rendering to half float textures is supported */
  82563. textureHalfFloatRender: boolean;
  82564. /** Defines if textureLOD shader command is supported */
  82565. textureLOD: boolean;
  82566. /** Defines if draw buffers extension is supported */
  82567. drawBuffersExtension: boolean;
  82568. /** Defines if depth textures are supported */
  82569. depthTextureExtension: boolean;
  82570. /** Defines if float color buffer are supported */
  82571. colorBufferFloat: boolean;
  82572. /** Gets disjoint timer query extension (null if not supported) */
  82573. timerQuery: EXT_disjoint_timer_query;
  82574. /** Defines if timestamp can be used with timer query */
  82575. canUseTimestampForTimerQuery: boolean;
  82576. /** Function used to let the system compiles shaders in background */
  82577. parallelShaderCompile: {
  82578. MAX_SHADER_COMPILER_THREADS_KHR: number;
  82579. maxShaderCompilerThreadsKHR: (thread: number) => void;
  82580. COMPLETION_STATUS_KHR: number;
  82581. };
  82582. }
  82583. /** Interface defining initialization parameters for Engine class */
  82584. export interface EngineOptions extends WebGLContextAttributes {
  82585. /**
  82586. * Defines if the engine should no exceed a specified device ratio
  82587. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  82588. */
  82589. limitDeviceRatio?: number;
  82590. /**
  82591. * Defines if webvr should be enabled automatically
  82592. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82593. */
  82594. autoEnableWebVR?: boolean;
  82595. /**
  82596. * Defines if webgl2 should be turned off even if supported
  82597. * @see http://doc.babylonjs.com/features/webgl2
  82598. */
  82599. disableWebGL2Support?: boolean;
  82600. /**
  82601. * Defines if webaudio should be initialized as well
  82602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82603. */
  82604. audioEngine?: boolean;
  82605. /**
  82606. * Defines if animations should run using a deterministic lock step
  82607. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  82608. */
  82609. deterministicLockstep?: boolean;
  82610. /** Defines the maximum steps to use with deterministic lock step mode */
  82611. lockstepMaxSteps?: number;
  82612. /**
  82613. * Defines that engine should ignore context lost events
  82614. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  82615. */
  82616. doNotHandleContextLost?: boolean;
  82617. /**
  82618. * Defines that engine should ignore modifying touch action attribute and style
  82619. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  82620. */
  82621. doNotHandleTouchAction?: boolean;
  82622. }
  82623. /**
  82624. * Defines the interface used by display changed events
  82625. */
  82626. export interface IDisplayChangedEventArgs {
  82627. /** Gets the vrDisplay object (if any) */
  82628. vrDisplay: Nullable<any>;
  82629. /** Gets a boolean indicating if webVR is supported */
  82630. vrSupported: boolean;
  82631. }
  82632. /**
  82633. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  82634. */
  82635. export class Engine {
  82636. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  82637. static ExceptionList: ({
  82638. key: string;
  82639. capture: string;
  82640. captureConstraint: number;
  82641. targets: string[];
  82642. } | {
  82643. key: string;
  82644. capture: null;
  82645. captureConstraint: null;
  82646. targets: string[];
  82647. })[];
  82648. /** Gets the list of created engines */
  82649. static readonly Instances: Engine[];
  82650. /**
  82651. * Gets the latest created engine
  82652. */
  82653. static readonly LastCreatedEngine: Nullable<Engine>;
  82654. /**
  82655. * Gets the latest created scene
  82656. */
  82657. static readonly LastCreatedScene: Nullable<Scene>;
  82658. /**
  82659. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  82660. * @param flag defines which part of the materials must be marked as dirty
  82661. * @param predicate defines a predicate used to filter which materials should be affected
  82662. */
  82663. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  82664. /**
  82665. * Hidden
  82666. */
  82667. static _TextureLoaders: IInternalTextureLoader[];
  82668. /** Defines that alpha blending is disabled */
  82669. static readonly ALPHA_DISABLE: number;
  82670. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  82671. static readonly ALPHA_ADD: number;
  82672. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82673. static readonly ALPHA_COMBINE: number;
  82674. /** Defines that alpha blending to DEST - SRC * DEST */
  82675. static readonly ALPHA_SUBTRACT: number;
  82676. /** Defines that alpha blending to SRC * DEST */
  82677. static readonly ALPHA_MULTIPLY: number;
  82678. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  82679. static readonly ALPHA_MAXIMIZED: number;
  82680. /** Defines that alpha blending to SRC + DEST */
  82681. static readonly ALPHA_ONEONE: number;
  82682. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  82683. static readonly ALPHA_PREMULTIPLIED: number;
  82684. /**
  82685. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  82686. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82687. */
  82688. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82689. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  82690. static readonly ALPHA_INTERPOLATE: number;
  82691. /**
  82692. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  82693. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82694. */
  82695. static readonly ALPHA_SCREENMODE: number;
  82696. /** Defines that the ressource is not delayed*/
  82697. static readonly DELAYLOADSTATE_NONE: number;
  82698. /** Defines that the ressource was successfully delay loaded */
  82699. static readonly DELAYLOADSTATE_LOADED: number;
  82700. /** Defines that the ressource is currently delay loading */
  82701. static readonly DELAYLOADSTATE_LOADING: number;
  82702. /** Defines that the ressource is delayed and has not started loading */
  82703. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82704. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82705. static readonly NEVER: number;
  82706. /** 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 */
  82707. static readonly ALWAYS: number;
  82708. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82709. static readonly LESS: number;
  82710. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82711. static readonly EQUAL: number;
  82712. /** 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 */
  82713. static readonly LEQUAL: number;
  82714. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82715. static readonly GREATER: number;
  82716. /** 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 */
  82717. static readonly GEQUAL: number;
  82718. /** 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 */
  82719. static readonly NOTEQUAL: number;
  82720. /** Passed to stencilOperation to specify that stencil value must be kept */
  82721. static readonly KEEP: number;
  82722. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82723. static readonly REPLACE: number;
  82724. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82725. static readonly INCR: number;
  82726. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82727. static readonly DECR: number;
  82728. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82729. static readonly INVERT: number;
  82730. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82731. static readonly INCR_WRAP: number;
  82732. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82733. static readonly DECR_WRAP: number;
  82734. /** Texture is not repeating outside of 0..1 UVs */
  82735. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82736. /** Texture is repeating outside of 0..1 UVs */
  82737. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82738. /** Texture is repeating and mirrored */
  82739. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82740. /** ALPHA */
  82741. static readonly TEXTUREFORMAT_ALPHA: number;
  82742. /** LUMINANCE */
  82743. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82744. /** LUMINANCE_ALPHA */
  82745. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82746. /** RGB */
  82747. static readonly TEXTUREFORMAT_RGB: number;
  82748. /** RGBA */
  82749. static readonly TEXTUREFORMAT_RGBA: number;
  82750. /** RED */
  82751. static readonly TEXTUREFORMAT_RED: number;
  82752. /** RED (2nd reference) */
  82753. static readonly TEXTUREFORMAT_R: number;
  82754. /** RG */
  82755. static readonly TEXTUREFORMAT_RG: number;
  82756. /** RED_INTEGER */
  82757. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82758. /** RED_INTEGER (2nd reference) */
  82759. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82760. /** RG_INTEGER */
  82761. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82762. /** RGB_INTEGER */
  82763. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82764. /** RGBA_INTEGER */
  82765. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82766. /** UNSIGNED_BYTE */
  82767. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82768. /** UNSIGNED_BYTE (2nd reference) */
  82769. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82770. /** FLOAT */
  82771. static readonly TEXTURETYPE_FLOAT: number;
  82772. /** HALF_FLOAT */
  82773. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82774. /** BYTE */
  82775. static readonly TEXTURETYPE_BYTE: number;
  82776. /** SHORT */
  82777. static readonly TEXTURETYPE_SHORT: number;
  82778. /** UNSIGNED_SHORT */
  82779. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82780. /** INT */
  82781. static readonly TEXTURETYPE_INT: number;
  82782. /** UNSIGNED_INT */
  82783. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82784. /** UNSIGNED_SHORT_4_4_4_4 */
  82785. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82786. /** UNSIGNED_SHORT_5_5_5_1 */
  82787. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82788. /** UNSIGNED_SHORT_5_6_5 */
  82789. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82790. /** UNSIGNED_INT_2_10_10_10_REV */
  82791. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82792. /** UNSIGNED_INT_24_8 */
  82793. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82794. /** UNSIGNED_INT_10F_11F_11F_REV */
  82795. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82796. /** UNSIGNED_INT_5_9_9_9_REV */
  82797. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82798. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82799. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82800. /** nearest is mag = nearest and min = nearest and mip = linear */
  82801. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82803. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82804. /** Trilinear is mag = linear and min = linear and mip = linear */
  82805. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82806. /** nearest is mag = nearest and min = nearest and mip = linear */
  82807. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82810. /** Trilinear is mag = linear and min = linear and mip = linear */
  82811. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82812. /** mag = nearest and min = nearest and mip = nearest */
  82813. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82814. /** mag = nearest and min = linear and mip = nearest */
  82815. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82816. /** mag = nearest and min = linear and mip = linear */
  82817. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82818. /** mag = nearest and min = linear and mip = none */
  82819. static readonly TEXTURE_NEAREST_LINEAR: number;
  82820. /** mag = nearest and min = nearest and mip = none */
  82821. static readonly TEXTURE_NEAREST_NEAREST: number;
  82822. /** mag = linear and min = nearest and mip = nearest */
  82823. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82824. /** mag = linear and min = nearest and mip = linear */
  82825. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82826. /** mag = linear and min = linear and mip = none */
  82827. static readonly TEXTURE_LINEAR_LINEAR: number;
  82828. /** mag = linear and min = nearest and mip = none */
  82829. static readonly TEXTURE_LINEAR_NEAREST: number;
  82830. /** Explicit coordinates mode */
  82831. static readonly TEXTURE_EXPLICIT_MODE: number;
  82832. /** Spherical coordinates mode */
  82833. static readonly TEXTURE_SPHERICAL_MODE: number;
  82834. /** Planar coordinates mode */
  82835. static readonly TEXTURE_PLANAR_MODE: number;
  82836. /** Cubic coordinates mode */
  82837. static readonly TEXTURE_CUBIC_MODE: number;
  82838. /** Projection coordinates mode */
  82839. static readonly TEXTURE_PROJECTION_MODE: number;
  82840. /** Skybox coordinates mode */
  82841. static readonly TEXTURE_SKYBOX_MODE: number;
  82842. /** Inverse Cubic coordinates mode */
  82843. static readonly TEXTURE_INVCUBIC_MODE: number;
  82844. /** Equirectangular coordinates mode */
  82845. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82846. /** Equirectangular Fixed coordinates mode */
  82847. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82848. /** Equirectangular Fixed Mirrored coordinates mode */
  82849. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82850. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82851. static readonly SCALEMODE_FLOOR: number;
  82852. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82853. static readonly SCALEMODE_NEAREST: number;
  82854. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82855. static readonly SCALEMODE_CEILING: number;
  82856. /**
  82857. * Returns the current version of the framework
  82858. */
  82859. static readonly Version: string;
  82860. /**
  82861. * Returns a string describing the current engine
  82862. */
  82863. readonly description: string;
  82864. /**
  82865. * Gets or sets the epsilon value used by collision engine
  82866. */
  82867. static CollisionsEpsilon: number;
  82868. /**
  82869. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  82870. */
  82871. static ShadersRepository: string;
  82872. /**
  82873. * Method called to create the default loading screen.
  82874. * This can be overriden in your own app.
  82875. * @param canvas The rendering canvas element
  82876. * @returns The loading screen
  82877. */
  82878. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  82879. /**
  82880. * Method called to create the default rescale post process on each engine.
  82881. */
  82882. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  82883. /**
  82884. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  82885. */
  82886. forcePOTTextures: boolean;
  82887. /**
  82888. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  82889. */
  82890. isFullscreen: boolean;
  82891. /**
  82892. * Gets a boolean indicating if the pointer is currently locked
  82893. */
  82894. isPointerLock: boolean;
  82895. /**
  82896. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  82897. */
  82898. cullBackFaces: boolean;
  82899. /**
  82900. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  82901. */
  82902. renderEvenInBackground: boolean;
  82903. /**
  82904. * Gets or sets a boolean indicating that cache can be kept between frames
  82905. */
  82906. preventCacheWipeBetweenFrames: boolean;
  82907. /**
  82908. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  82909. **/
  82910. enableOfflineSupport: boolean;
  82911. /**
  82912. * 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)
  82913. **/
  82914. disableManifestCheck: boolean;
  82915. /**
  82916. * Gets the list of created scenes
  82917. */
  82918. scenes: Scene[];
  82919. /**
  82920. * Event raised when a new scene is created
  82921. */
  82922. onNewSceneAddedObservable: Observable<Scene>;
  82923. /**
  82924. * Gets the list of created postprocesses
  82925. */
  82926. postProcesses: PostProcess[];
  82927. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  82928. validateShaderPrograms: boolean;
  82929. /**
  82930. * Observable event triggered each time the rendering canvas is resized
  82931. */
  82932. onResizeObservable: Observable<Engine>;
  82933. /**
  82934. * Observable event triggered each time the canvas loses focus
  82935. */
  82936. onCanvasBlurObservable: Observable<Engine>;
  82937. /**
  82938. * Observable event triggered each time the canvas gains focus
  82939. */
  82940. onCanvasFocusObservable: Observable<Engine>;
  82941. /**
  82942. * Observable event triggered each time the canvas receives pointerout event
  82943. */
  82944. onCanvasPointerOutObservable: Observable<PointerEvent>;
  82945. /**
  82946. * Observable event triggered before each texture is initialized
  82947. */
  82948. onBeforeTextureInitObservable: Observable<Texture>;
  82949. private _vrDisplay;
  82950. private _vrSupported;
  82951. private _oldSize;
  82952. private _oldHardwareScaleFactor;
  82953. private _vrExclusivePointerMode;
  82954. private _webVRInitPromise;
  82955. /**
  82956. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82957. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82958. */
  82959. readonly isInVRExclusivePointerMode: boolean;
  82960. /**
  82961. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  82962. */
  82963. disableUniformBuffers: boolean;
  82964. /** @hidden */
  82965. _uniformBuffers: UniformBuffer[];
  82966. /**
  82967. * Gets a boolean indicating that the engine supports uniform buffers
  82968. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82969. */
  82970. readonly supportsUniformBuffers: boolean;
  82971. /**
  82972. * Observable raised when the engine begins a new frame
  82973. */
  82974. onBeginFrameObservable: Observable<Engine>;
  82975. /**
  82976. * If set, will be used to request the next animation frame for the render loop
  82977. */
  82978. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  82979. /**
  82980. * Observable raised when the engine ends the current frame
  82981. */
  82982. onEndFrameObservable: Observable<Engine>;
  82983. /**
  82984. * Observable raised when the engine is about to compile a shader
  82985. */
  82986. onBeforeShaderCompilationObservable: Observable<Engine>;
  82987. /**
  82988. * Observable raised when the engine has jsut compiled a shader
  82989. */
  82990. onAfterShaderCompilationObservable: Observable<Engine>;
  82991. /** @hidden */
  82992. _gl: WebGLRenderingContext;
  82993. private _renderingCanvas;
  82994. private _windowIsBackground;
  82995. private _webGLVersion;
  82996. /**
  82997. * Gets a boolean indicating that only power of 2 textures are supported
  82998. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  82999. */
  83000. readonly needPOTTextures: boolean;
  83001. /** @hidden */
  83002. _badOS: boolean;
  83003. /** @hidden */
  83004. _badDesktopOS: boolean;
  83005. /**
  83006. * Gets or sets a value indicating if we want to disable texture binding optimization.
  83007. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  83008. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  83009. */
  83010. disableTextureBindingOptimization: boolean;
  83011. /**
  83012. * Gets the audio engine
  83013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83014. * @ignorenaming
  83015. */
  83016. static audioEngine: IAudioEngine;
  83017. /**
  83018. * Default AudioEngine factory responsible of creating the Audio Engine.
  83019. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  83020. */
  83021. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  83022. /**
  83023. * Default offline support factory responsible of creating a tool used to store data locally.
  83024. * By default, this will create a Database object if the workload has been embedded.
  83025. */
  83026. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  83027. private _onFocus;
  83028. private _onBlur;
  83029. private _onCanvasPointerOut;
  83030. private _onCanvasBlur;
  83031. private _onCanvasFocus;
  83032. private _onFullscreenChange;
  83033. private _onPointerLockChange;
  83034. private _onVRDisplayPointerRestricted;
  83035. private _onVRDisplayPointerUnrestricted;
  83036. private _onVrDisplayConnect;
  83037. private _onVrDisplayDisconnect;
  83038. private _onVrDisplayPresentChange;
  83039. /**
  83040. * Observable signaled when VR display mode changes
  83041. */
  83042. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83043. /**
  83044. * Observable signaled when VR request present is complete
  83045. */
  83046. onVRRequestPresentComplete: Observable<boolean>;
  83047. /**
  83048. * Observable signaled when VR request present starts
  83049. */
  83050. onVRRequestPresentStart: Observable<Engine>;
  83051. private _hardwareScalingLevel;
  83052. /** @hidden */
  83053. protected _caps: EngineCapabilities;
  83054. private _pointerLockRequested;
  83055. private _isStencilEnable;
  83056. private _colorWrite;
  83057. private _loadingScreen;
  83058. /** @hidden */
  83059. _drawCalls: PerfCounter;
  83060. /** @hidden */
  83061. _textureCollisions: PerfCounter;
  83062. private _glVersion;
  83063. private _glRenderer;
  83064. private _glVendor;
  83065. private _videoTextureSupported;
  83066. private _renderingQueueLaunched;
  83067. private _activeRenderLoops;
  83068. private _deterministicLockstep;
  83069. private _lockstepMaxSteps;
  83070. /**
  83071. * Observable signaled when a context lost event is raised
  83072. */
  83073. onContextLostObservable: Observable<Engine>;
  83074. /**
  83075. * Observable signaled when a context restored event is raised
  83076. */
  83077. onContextRestoredObservable: Observable<Engine>;
  83078. private _onContextLost;
  83079. private _onContextRestored;
  83080. private _contextWasLost;
  83081. private _doNotHandleContextLost;
  83082. /**
  83083. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83085. */
  83086. doNotHandleContextLost: boolean;
  83087. private _performanceMonitor;
  83088. private _fps;
  83089. private _deltaTime;
  83090. /**
  83091. * Turn this value on if you want to pause FPS computation when in background
  83092. */
  83093. disablePerformanceMonitorInBackground: boolean;
  83094. /**
  83095. * Gets the performance monitor attached to this engine
  83096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83097. */
  83098. readonly performanceMonitor: PerformanceMonitor;
  83099. /** @hidden */
  83100. protected _depthCullingState: _DepthCullingState;
  83101. /** @hidden */
  83102. protected _stencilState: _StencilState;
  83103. /** @hidden */
  83104. protected _alphaState: _AlphaState;
  83105. /** @hidden */
  83106. protected _alphaMode: number;
  83107. protected _internalTexturesCache: InternalTexture[];
  83108. /** @hidden */
  83109. protected _activeChannel: number;
  83110. private _currentTextureChannel;
  83111. /** @hidden */
  83112. protected _boundTexturesCache: {
  83113. [key: string]: Nullable<InternalTexture>;
  83114. };
  83115. /** @hidden */
  83116. protected _currentEffect: Nullable<Effect>;
  83117. /** @hidden */
  83118. protected _currentProgram: Nullable<WebGLProgram>;
  83119. private _compiledEffects;
  83120. private _vertexAttribArraysEnabled;
  83121. /** @hidden */
  83122. protected _cachedViewport: Nullable<Viewport>;
  83123. private _cachedVertexArrayObject;
  83124. /** @hidden */
  83125. protected _cachedVertexBuffers: any;
  83126. /** @hidden */
  83127. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83128. /** @hidden */
  83129. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83130. /** @hidden */
  83131. protected _currentRenderTarget: Nullable<InternalTexture>;
  83132. private _uintIndicesCurrentlySet;
  83133. private _currentBoundBuffer;
  83134. /** @hidden */
  83135. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83136. private _currentBufferPointers;
  83137. private _currentInstanceLocations;
  83138. private _currentInstanceBuffers;
  83139. private _textureUnits;
  83140. private _firstBoundInternalTextureTracker;
  83141. private _lastBoundInternalTextureTracker;
  83142. private _workingCanvas;
  83143. private _workingContext;
  83144. private _rescalePostProcess;
  83145. private _dummyFramebuffer;
  83146. private _externalData;
  83147. private _bindedRenderFunction;
  83148. private _vaoRecordInProgress;
  83149. private _mustWipeVertexAttributes;
  83150. private _emptyTexture;
  83151. private _emptyCubeTexture;
  83152. private _emptyTexture3D;
  83153. /** @hidden */
  83154. _frameHandler: number;
  83155. private _nextFreeTextureSlots;
  83156. private _maxSimultaneousTextures;
  83157. private _activeRequests;
  83158. private _texturesSupported;
  83159. private _textureFormatInUse;
  83160. /**
  83161. * Gets the list of texture formats supported
  83162. */
  83163. readonly texturesSupported: Array<string>;
  83164. /**
  83165. * Gets the list of texture formats in use
  83166. */
  83167. readonly textureFormatInUse: Nullable<string>;
  83168. /**
  83169. * Gets the current viewport
  83170. */
  83171. readonly currentViewport: Nullable<Viewport>;
  83172. /**
  83173. * Gets the default empty texture
  83174. */
  83175. readonly emptyTexture: InternalTexture;
  83176. /**
  83177. * Gets the default empty 3D texture
  83178. */
  83179. readonly emptyTexture3D: InternalTexture;
  83180. /**
  83181. * Gets the default empty cube texture
  83182. */
  83183. readonly emptyCubeTexture: InternalTexture;
  83184. /**
  83185. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83186. */
  83187. readonly premultipliedAlpha: boolean;
  83188. /**
  83189. * Creates a new engine
  83190. * @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
  83191. * @param antialias defines enable antialiasing (default: false)
  83192. * @param options defines further options to be sent to the getContext() function
  83193. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83194. */
  83195. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83196. private _disableTouchAction;
  83197. private _rebuildInternalTextures;
  83198. private _rebuildEffects;
  83199. /**
  83200. * Gets a boolean indicating if all created effects are ready
  83201. * @returns true if all effects are ready
  83202. */
  83203. areAllEffectsReady(): boolean;
  83204. private _rebuildBuffers;
  83205. private _initGLContext;
  83206. /**
  83207. * Gets version of the current webGL context
  83208. */
  83209. readonly webGLVersion: number;
  83210. /**
  83211. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83212. */
  83213. readonly isStencilEnable: boolean;
  83214. private _prepareWorkingCanvas;
  83215. /**
  83216. * Reset the texture cache to empty state
  83217. */
  83218. resetTextureCache(): void;
  83219. /**
  83220. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83221. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83222. * @returns true if engine is in deterministic lock step mode
  83223. */
  83224. isDeterministicLockStep(): boolean;
  83225. /**
  83226. * Gets the max steps when engine is running in deterministic lock step
  83227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83228. * @returns the max steps
  83229. */
  83230. getLockstepMaxSteps(): number;
  83231. /**
  83232. * Gets an object containing information about the current webGL context
  83233. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83234. */
  83235. getGlInfo(): {
  83236. vendor: string;
  83237. renderer: string;
  83238. version: string;
  83239. };
  83240. /**
  83241. * Gets current aspect ratio
  83242. * @param camera defines the camera to use to get the aspect ratio
  83243. * @param useScreen defines if screen size must be used (or the current render target if any)
  83244. * @returns a number defining the aspect ratio
  83245. */
  83246. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83247. /**
  83248. * Gets current screen aspect ratio
  83249. * @returns a number defining the aspect ratio
  83250. */
  83251. getScreenAspectRatio(): number;
  83252. /**
  83253. * Gets the current render width
  83254. * @param useScreen defines if screen size must be used (or the current render target if any)
  83255. * @returns a number defining the current render width
  83256. */
  83257. getRenderWidth(useScreen?: boolean): number;
  83258. /**
  83259. * Gets the current render height
  83260. * @param useScreen defines if screen size must be used (or the current render target if any)
  83261. * @returns a number defining the current render height
  83262. */
  83263. getRenderHeight(useScreen?: boolean): number;
  83264. /**
  83265. * Gets the HTML canvas attached with the current webGL context
  83266. * @returns a HTML canvas
  83267. */
  83268. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83269. /**
  83270. * Gets the client rect of the HTML canvas attached with the current webGL context
  83271. * @returns a client rectanglee
  83272. */
  83273. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83274. /**
  83275. * Defines the hardware scaling level.
  83276. * By default the hardware scaling level is computed from the window device ratio.
  83277. * 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.
  83278. * @param level defines the level to use
  83279. */
  83280. setHardwareScalingLevel(level: number): void;
  83281. /**
  83282. * Gets the current hardware scaling level.
  83283. * By default the hardware scaling level is computed from the window device ratio.
  83284. * 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.
  83285. * @returns a number indicating the current hardware scaling level
  83286. */
  83287. getHardwareScalingLevel(): number;
  83288. /**
  83289. * Gets the list of loaded textures
  83290. * @returns an array containing all loaded textures
  83291. */
  83292. getLoadedTexturesCache(): InternalTexture[];
  83293. /**
  83294. * Gets the object containing all engine capabilities
  83295. * @returns the EngineCapabilities object
  83296. */
  83297. getCaps(): EngineCapabilities;
  83298. /**
  83299. * Gets the current depth function
  83300. * @returns a number defining the depth function
  83301. */
  83302. getDepthFunction(): Nullable<number>;
  83303. /**
  83304. * Sets the current depth function
  83305. * @param depthFunc defines the function to use
  83306. */
  83307. setDepthFunction(depthFunc: number): void;
  83308. /**
  83309. * Sets the current depth function to GREATER
  83310. */
  83311. setDepthFunctionToGreater(): void;
  83312. /**
  83313. * Sets the current depth function to GEQUAL
  83314. */
  83315. setDepthFunctionToGreaterOrEqual(): void;
  83316. /**
  83317. * Sets the current depth function to LESS
  83318. */
  83319. setDepthFunctionToLess(): void;
  83320. /**
  83321. * Sets the current depth function to LEQUAL
  83322. */
  83323. setDepthFunctionToLessOrEqual(): void;
  83324. /**
  83325. * Gets a boolean indicating if stencil buffer is enabled
  83326. * @returns the current stencil buffer state
  83327. */
  83328. getStencilBuffer(): boolean;
  83329. /**
  83330. * Enable or disable the stencil buffer
  83331. * @param enable defines if the stencil buffer must be enabled or disabled
  83332. */
  83333. setStencilBuffer(enable: boolean): void;
  83334. /**
  83335. * Gets the current stencil mask
  83336. * @returns a number defining the new stencil mask to use
  83337. */
  83338. getStencilMask(): number;
  83339. /**
  83340. * Sets the current stencil mask
  83341. * @param mask defines the new stencil mask to use
  83342. */
  83343. setStencilMask(mask: number): void;
  83344. /**
  83345. * Gets the current stencil function
  83346. * @returns a number defining the stencil function to use
  83347. */
  83348. getStencilFunction(): number;
  83349. /**
  83350. * Gets the current stencil reference value
  83351. * @returns a number defining the stencil reference value to use
  83352. */
  83353. getStencilFunctionReference(): number;
  83354. /**
  83355. * Gets the current stencil mask
  83356. * @returns a number defining the stencil mask to use
  83357. */
  83358. getStencilFunctionMask(): number;
  83359. /**
  83360. * Sets the current stencil function
  83361. * @param stencilFunc defines the new stencil function to use
  83362. */
  83363. setStencilFunction(stencilFunc: number): void;
  83364. /**
  83365. * Sets the current stencil reference
  83366. * @param reference defines the new stencil reference to use
  83367. */
  83368. setStencilFunctionReference(reference: number): void;
  83369. /**
  83370. * Sets the current stencil mask
  83371. * @param mask defines the new stencil mask to use
  83372. */
  83373. setStencilFunctionMask(mask: number): void;
  83374. /**
  83375. * Gets the current stencil operation when stencil fails
  83376. * @returns a number defining stencil operation to use when stencil fails
  83377. */
  83378. getStencilOperationFail(): number;
  83379. /**
  83380. * Gets the current stencil operation when depth fails
  83381. * @returns a number defining stencil operation to use when depth fails
  83382. */
  83383. getStencilOperationDepthFail(): number;
  83384. /**
  83385. * Gets the current stencil operation when stencil passes
  83386. * @returns a number defining stencil operation to use when stencil passes
  83387. */
  83388. getStencilOperationPass(): number;
  83389. /**
  83390. * Sets the stencil operation to use when stencil fails
  83391. * @param operation defines the stencil operation to use when stencil fails
  83392. */
  83393. setStencilOperationFail(operation: number): void;
  83394. /**
  83395. * Sets the stencil operation to use when depth fails
  83396. * @param operation defines the stencil operation to use when depth fails
  83397. */
  83398. setStencilOperationDepthFail(operation: number): void;
  83399. /**
  83400. * Sets the stencil operation to use when stencil passes
  83401. * @param operation defines the stencil operation to use when stencil passes
  83402. */
  83403. setStencilOperationPass(operation: number): void;
  83404. /**
  83405. * Sets a boolean indicating if the dithering state is enabled or disabled
  83406. * @param value defines the dithering state
  83407. */
  83408. setDitheringState(value: boolean): void;
  83409. /**
  83410. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83411. * @param value defines the rasterizer state
  83412. */
  83413. setRasterizerState(value: boolean): void;
  83414. /**
  83415. * stop executing a render loop function and remove it from the execution array
  83416. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83417. */
  83418. stopRenderLoop(renderFunction?: () => void): void;
  83419. /** @hidden */
  83420. _renderLoop(): void;
  83421. /**
  83422. * Register and execute a render loop. The engine can have more than one render function
  83423. * @param renderFunction defines the function to continuously execute
  83424. */
  83425. runRenderLoop(renderFunction: () => void): void;
  83426. /**
  83427. * Toggle full screen mode
  83428. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83429. */
  83430. switchFullscreen(requestPointerLock: boolean): void;
  83431. /**
  83432. * Enters full screen mode
  83433. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83434. */
  83435. enterFullscreen(requestPointerLock: boolean): void;
  83436. /**
  83437. * Exits full screen mode
  83438. */
  83439. exitFullscreen(): void;
  83440. /**
  83441. * Clear the current render buffer or the current render target (if any is set up)
  83442. * @param color defines the color to use
  83443. * @param backBuffer defines if the back buffer must be cleared
  83444. * @param depth defines if the depth buffer must be cleared
  83445. * @param stencil defines if the stencil buffer must be cleared
  83446. */
  83447. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83448. /**
  83449. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83450. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83451. * @param y defines the y-coordinate of the corner of the clear rectangle
  83452. * @param width defines the width of the clear rectangle
  83453. * @param height defines the height of the clear rectangle
  83454. * @param clearColor defines the clear color
  83455. */
  83456. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83457. /**
  83458. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83459. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83460. * @param y defines the y-coordinate of the corner of the clear rectangle
  83461. * @param width defines the width of the clear rectangle
  83462. * @param height defines the height of the clear rectangle
  83463. */
  83464. enableScissor(x: number, y: number, width: number, height: number): void;
  83465. /**
  83466. * Disable previously set scissor test rectangle
  83467. */
  83468. disableScissor(): void;
  83469. private _viewportCached;
  83470. /** @hidden */
  83471. _viewport(x: number, y: number, width: number, height: number): void;
  83472. /**
  83473. * Set the WebGL's viewport
  83474. * @param viewport defines the viewport element to be used
  83475. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83476. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83477. */
  83478. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83479. /**
  83480. * Directly set the WebGL Viewport
  83481. * @param x defines the x coordinate of the viewport (in screen space)
  83482. * @param y defines the y coordinate of the viewport (in screen space)
  83483. * @param width defines the width of the viewport (in screen space)
  83484. * @param height defines the height of the viewport (in screen space)
  83485. * @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
  83486. */
  83487. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83488. /**
  83489. * Begin a new frame
  83490. */
  83491. beginFrame(): void;
  83492. /**
  83493. * Enf the current frame
  83494. */
  83495. endFrame(): void;
  83496. /**
  83497. * Resize the view according to the canvas' size
  83498. */
  83499. resize(): void;
  83500. /**
  83501. * Force a specific size of the canvas
  83502. * @param width defines the new canvas' width
  83503. * @param height defines the new canvas' height
  83504. */
  83505. setSize(width: number, height: number): void;
  83506. /**
  83507. * Gets a boolean indicating if a webVR device was detected
  83508. * @returns true if a webVR device was detected
  83509. */
  83510. isVRDevicePresent(): boolean;
  83511. /**
  83512. * Gets the current webVR device
  83513. * @returns the current webVR device (or null)
  83514. */
  83515. getVRDevice(): any;
  83516. /**
  83517. * Initializes a webVR display and starts listening to display change events
  83518. * The onVRDisplayChangedObservable will be notified upon these changes
  83519. * @returns The onVRDisplayChangedObservable
  83520. */
  83521. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83522. /**
  83523. * Initializes a webVR display and starts listening to display change events
  83524. * The onVRDisplayChangedObservable will be notified upon these changes
  83525. * @returns A promise containing a VRDisplay and if vr is supported
  83526. */
  83527. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83528. /**
  83529. * Call this function to switch to webVR mode
  83530. * Will do nothing if webVR is not supported or if there is no webVR device
  83531. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83532. */
  83533. enableVR(): void;
  83534. /**
  83535. * Call this function to leave webVR mode
  83536. * Will do nothing if webVR is not supported or if there is no webVR device
  83537. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83538. */
  83539. disableVR(): void;
  83540. private _onVRFullScreenTriggered;
  83541. private _getVRDisplaysAsync;
  83542. /**
  83543. * Binds the frame buffer to the specified texture.
  83544. * @param texture The texture to render to or null for the default canvas
  83545. * @param faceIndex The face of the texture to render to in case of cube texture
  83546. * @param requiredWidth The width of the target to render to
  83547. * @param requiredHeight The height of the target to render to
  83548. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  83549. * @param depthStencilTexture The depth stencil texture to use to render
  83550. * @param lodLevel defines le lod level to bind to the frame buffer
  83551. */
  83552. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  83553. private bindUnboundFramebuffer;
  83554. /**
  83555. * Unbind the current render target texture from the webGL context
  83556. * @param texture defines the render target texture to unbind
  83557. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83558. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83559. */
  83560. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83561. /**
  83562. * Unbind a list of render target textures from the webGL context
  83563. * This is used only when drawBuffer extension or webGL2 are active
  83564. * @param textures defines the render target textures to unbind
  83565. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83566. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83567. */
  83568. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83569. /**
  83570. * Force the mipmap generation for the given render target texture
  83571. * @param texture defines the render target texture to use
  83572. */
  83573. generateMipMapsForCubemap(texture: InternalTexture): void;
  83574. /**
  83575. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  83576. */
  83577. flushFramebuffer(): void;
  83578. /**
  83579. * Unbind the current render target and bind the default framebuffer
  83580. */
  83581. restoreDefaultFramebuffer(): void;
  83582. /**
  83583. * Create an uniform buffer
  83584. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83585. * @param elements defines the content of the uniform buffer
  83586. * @returns the webGL uniform buffer
  83587. */
  83588. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  83589. /**
  83590. * Create a dynamic uniform buffer
  83591. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83592. * @param elements defines the content of the uniform buffer
  83593. * @returns the webGL uniform buffer
  83594. */
  83595. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  83596. /**
  83597. * Update an existing uniform buffer
  83598. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83599. * @param uniformBuffer defines the target uniform buffer
  83600. * @param elements defines the content to update
  83601. * @param offset defines the offset in the uniform buffer where update should start
  83602. * @param count defines the size of the data to update
  83603. */
  83604. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83605. private _resetVertexBufferBinding;
  83606. /**
  83607. * Creates a vertex buffer
  83608. * @param data the data for the vertex buffer
  83609. * @returns the new WebGL static buffer
  83610. */
  83611. createVertexBuffer(data: DataArray): WebGLBuffer;
  83612. /**
  83613. * Creates a dynamic vertex buffer
  83614. * @param data the data for the dynamic vertex buffer
  83615. * @returns the new WebGL dynamic buffer
  83616. */
  83617. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  83618. /**
  83619. * Update a dynamic index buffer
  83620. * @param indexBuffer defines the target index buffer
  83621. * @param indices defines the data to update
  83622. * @param offset defines the offset in the target index buffer where update should start
  83623. */
  83624. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  83625. /**
  83626. * Updates a dynamic vertex buffer.
  83627. * @param vertexBuffer the vertex buffer to update
  83628. * @param data the data used to update the vertex buffer
  83629. * @param byteOffset the byte offset of the data
  83630. * @param byteLength the byte length of the data
  83631. */
  83632. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  83633. private _resetIndexBufferBinding;
  83634. /**
  83635. * Creates a new index buffer
  83636. * @param indices defines the content of the index buffer
  83637. * @param updatable defines if the index buffer must be updatable
  83638. * @returns a new webGL buffer
  83639. */
  83640. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  83641. /**
  83642. * Bind a webGL buffer to the webGL context
  83643. * @param buffer defines the buffer to bind
  83644. */
  83645. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  83646. /**
  83647. * Bind an uniform buffer to the current webGL context
  83648. * @param buffer defines the buffer to bind
  83649. */
  83650. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  83651. /**
  83652. * Bind a buffer to the current webGL context at a given location
  83653. * @param buffer defines the buffer to bind
  83654. * @param location defines the index where to bind the buffer
  83655. */
  83656. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  83657. /**
  83658. * Bind a specific block at a given index in a specific shader program
  83659. * @param shaderProgram defines the shader program
  83660. * @param blockName defines the block name
  83661. * @param index defines the index where to bind the block
  83662. */
  83663. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  83664. private bindIndexBuffer;
  83665. private bindBuffer;
  83666. /**
  83667. * update the bound buffer with the given data
  83668. * @param data defines the data to update
  83669. */
  83670. updateArrayBuffer(data: Float32Array): void;
  83671. private _vertexAttribPointer;
  83672. private _bindIndexBufferWithCache;
  83673. private _bindVertexBuffersAttributes;
  83674. /**
  83675. * Records a vertex array object
  83676. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83677. * @param vertexBuffers defines the list of vertex buffers to store
  83678. * @param indexBuffer defines the index buffer to store
  83679. * @param effect defines the effect to store
  83680. * @returns the new vertex array object
  83681. */
  83682. recordVertexArrayObject(vertexBuffers: {
  83683. [key: string]: VertexBuffer;
  83684. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  83685. /**
  83686. * Bind a specific vertex array object
  83687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83688. * @param vertexArrayObject defines the vertex array object to bind
  83689. * @param indexBuffer defines the index buffer to bind
  83690. */
  83691. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  83692. /**
  83693. * Bind webGl buffers directly to the webGL context
  83694. * @param vertexBuffer defines the vertex buffer to bind
  83695. * @param indexBuffer defines the index buffer to bind
  83696. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  83697. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  83698. * @param effect defines the effect associated with the vertex buffer
  83699. */
  83700. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  83701. private _unbindVertexArrayObject;
  83702. /**
  83703. * Bind a list of vertex buffers to the webGL context
  83704. * @param vertexBuffers defines the list of vertex buffers to bind
  83705. * @param indexBuffer defines the index buffer to bind
  83706. * @param effect defines the effect associated with the vertex buffers
  83707. */
  83708. bindBuffers(vertexBuffers: {
  83709. [key: string]: Nullable<VertexBuffer>;
  83710. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  83711. /**
  83712. * Unbind all instance attributes
  83713. */
  83714. unbindInstanceAttributes(): void;
  83715. /**
  83716. * Release and free the memory of a vertex array object
  83717. * @param vao defines the vertex array object to delete
  83718. */
  83719. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  83720. /** @hidden */
  83721. _releaseBuffer(buffer: WebGLBuffer): boolean;
  83722. /**
  83723. * Creates a webGL buffer to use with instanciation
  83724. * @param capacity defines the size of the buffer
  83725. * @returns the webGL buffer
  83726. */
  83727. createInstancesBuffer(capacity: number): WebGLBuffer;
  83728. /**
  83729. * Delete a webGL buffer used with instanciation
  83730. * @param buffer defines the webGL buffer to delete
  83731. */
  83732. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  83733. /**
  83734. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  83735. * @param instancesBuffer defines the webGL buffer to update and bind
  83736. * @param data defines the data to store in the buffer
  83737. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  83738. */
  83739. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  83740. /**
  83741. * Apply all cached states (depth, culling, stencil and alpha)
  83742. */
  83743. applyStates(): void;
  83744. /**
  83745. * Send a draw order
  83746. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83747. * @param indexStart defines the starting index
  83748. * @param indexCount defines the number of index to draw
  83749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83750. */
  83751. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  83752. /**
  83753. * Draw a list of points
  83754. * @param verticesStart defines the index of first vertex to draw
  83755. * @param verticesCount defines the count of vertices to draw
  83756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83757. */
  83758. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83759. /**
  83760. * Draw a list of unindexed primitives
  83761. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83762. * @param verticesStart defines the index of first vertex to draw
  83763. * @param verticesCount defines the count of vertices to draw
  83764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83765. */
  83766. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83767. /**
  83768. * Draw a list of indexed primitives
  83769. * @param fillMode defines the primitive to use
  83770. * @param indexStart defines the starting index
  83771. * @param indexCount defines the number of index to draw
  83772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83773. */
  83774. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  83775. /**
  83776. * Draw a list of unindexed primitives
  83777. * @param fillMode defines the primitive to use
  83778. * @param verticesStart defines the index of first vertex to draw
  83779. * @param verticesCount defines the count of vertices to draw
  83780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83781. */
  83782. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83783. private _drawMode;
  83784. /** @hidden */
  83785. _releaseEffect(effect: Effect): void;
  83786. /** @hidden */
  83787. _deleteProgram(program: WebGLProgram): void;
  83788. /**
  83789. * Create a new effect (used to store vertex/fragment shaders)
  83790. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  83791. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  83792. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  83793. * @param samplers defines an array of string used to represent textures
  83794. * @param defines defines the string containing the defines to use to compile the shaders
  83795. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  83796. * @param onCompiled defines a function to call when the effect creation is successful
  83797. * @param onError defines a function to call when the effect creation has failed
  83798. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  83799. * @returns the new Effect
  83800. */
  83801. 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;
  83802. private _compileShader;
  83803. private _compileRawShader;
  83804. /**
  83805. * Directly creates a webGL program
  83806. * @param vertexCode defines the vertex shader code to use
  83807. * @param fragmentCode defines the fragment shader code to use
  83808. * @param context defines the webGL context to use (if not set, the current one will be used)
  83809. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83810. * @returns the new webGL program
  83811. */
  83812. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83813. /**
  83814. * Creates a webGL program
  83815. * @param vertexCode defines the vertex shader code to use
  83816. * @param fragmentCode defines the fragment shader code to use
  83817. * @param defines defines the string containing the defines to use to compile the shaders
  83818. * @param context defines the webGL context to use (if not set, the current one will be used)
  83819. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83820. * @returns the new webGL program
  83821. */
  83822. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83823. private _createShaderProgram;
  83824. private _finalizeProgram;
  83825. /** @hidden */
  83826. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  83827. /** @hidden */
  83828. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  83829. /**
  83830. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  83831. * @param shaderProgram defines the webGL program to use
  83832. * @param uniformsNames defines the list of uniform names
  83833. * @returns an array of webGL uniform locations
  83834. */
  83835. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  83836. /**
  83837. * Gets the lsit of active attributes for a given webGL program
  83838. * @param shaderProgram defines the webGL program to use
  83839. * @param attributesNames defines the list of attribute names to get
  83840. * @returns an array of indices indicating the offset of each attribute
  83841. */
  83842. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  83843. /**
  83844. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  83845. * @param effect defines the effect to activate
  83846. */
  83847. enableEffect(effect: Nullable<Effect>): void;
  83848. /**
  83849. * Set the value of an uniform to an array of int32
  83850. * @param uniform defines the webGL uniform location where to store the value
  83851. * @param array defines the array of int32 to store
  83852. */
  83853. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83854. /**
  83855. * Set the value of an uniform to an array of int32 (stored as vec2)
  83856. * @param uniform defines the webGL uniform location where to store the value
  83857. * @param array defines the array of int32 to store
  83858. */
  83859. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83860. /**
  83861. * Set the value of an uniform to an array of int32 (stored as vec3)
  83862. * @param uniform defines the webGL uniform location where to store the value
  83863. * @param array defines the array of int32 to store
  83864. */
  83865. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83866. /**
  83867. * Set the value of an uniform to an array of int32 (stored as vec4)
  83868. * @param uniform defines the webGL uniform location where to store the value
  83869. * @param array defines the array of int32 to store
  83870. */
  83871. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83872. /**
  83873. * Set the value of an uniform to an array of float32
  83874. * @param uniform defines the webGL uniform location where to store the value
  83875. * @param array defines the array of float32 to store
  83876. */
  83877. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83878. /**
  83879. * Set the value of an uniform to an array of float32 (stored as vec2)
  83880. * @param uniform defines the webGL uniform location where to store the value
  83881. * @param array defines the array of float32 to store
  83882. */
  83883. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83884. /**
  83885. * Set the value of an uniform to an array of float32 (stored as vec3)
  83886. * @param uniform defines the webGL uniform location where to store the value
  83887. * @param array defines the array of float32 to store
  83888. */
  83889. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83890. /**
  83891. * Set the value of an uniform to an array of float32 (stored as vec4)
  83892. * @param uniform defines the webGL uniform location where to store the value
  83893. * @param array defines the array of float32 to store
  83894. */
  83895. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83896. /**
  83897. * Set the value of an uniform to an array of number
  83898. * @param uniform defines the webGL uniform location where to store the value
  83899. * @param array defines the array of number to store
  83900. */
  83901. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83902. /**
  83903. * Set the value of an uniform to an array of number (stored as vec2)
  83904. * @param uniform defines the webGL uniform location where to store the value
  83905. * @param array defines the array of number to store
  83906. */
  83907. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83908. /**
  83909. * Set the value of an uniform to an array of number (stored as vec3)
  83910. * @param uniform defines the webGL uniform location where to store the value
  83911. * @param array defines the array of number to store
  83912. */
  83913. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83914. /**
  83915. * Set the value of an uniform to an array of number (stored as vec4)
  83916. * @param uniform defines the webGL uniform location where to store the value
  83917. * @param array defines the array of number to store
  83918. */
  83919. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83920. /**
  83921. * Set the value of an uniform to an array of float32 (stored as matrices)
  83922. * @param uniform defines the webGL uniform location where to store the value
  83923. * @param matrices defines the array of float32 to store
  83924. */
  83925. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  83926. /**
  83927. * Set the value of an uniform to a matrix
  83928. * @param uniform defines the webGL uniform location where to store the value
  83929. * @param matrix defines the matrix to store
  83930. */
  83931. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  83932. /**
  83933. * Set the value of an uniform to a matrix (3x3)
  83934. * @param uniform defines the webGL uniform location where to store the value
  83935. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  83936. */
  83937. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83938. /**
  83939. * Set the value of an uniform to a matrix (2x2)
  83940. * @param uniform defines the webGL uniform location where to store the value
  83941. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  83942. */
  83943. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83944. /**
  83945. * Set the value of an uniform to a number (int)
  83946. * @param uniform defines the webGL uniform location where to store the value
  83947. * @param value defines the int number to store
  83948. */
  83949. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83950. /**
  83951. * Set the value of an uniform to a number (float)
  83952. * @param uniform defines the webGL uniform location where to store the value
  83953. * @param value defines the float number to store
  83954. */
  83955. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83956. /**
  83957. * Set the value of an uniform to a vec2
  83958. * @param uniform defines the webGL uniform location where to store the value
  83959. * @param x defines the 1st component of the value
  83960. * @param y defines the 2nd component of the value
  83961. */
  83962. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  83963. /**
  83964. * Set the value of an uniform to a vec3
  83965. * @param uniform defines the webGL uniform location where to store the value
  83966. * @param x defines the 1st component of the value
  83967. * @param y defines the 2nd component of the value
  83968. * @param z defines the 3rd component of the value
  83969. */
  83970. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  83971. /**
  83972. * Set the value of an uniform to a boolean
  83973. * @param uniform defines the webGL uniform location where to store the value
  83974. * @param bool defines the boolean to store
  83975. */
  83976. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  83977. /**
  83978. * Set the value of an uniform to a vec4
  83979. * @param uniform defines the webGL uniform location where to store the value
  83980. * @param x defines the 1st component of the value
  83981. * @param y defines the 2nd component of the value
  83982. * @param z defines the 3rd component of the value
  83983. * @param w defines the 4th component of the value
  83984. */
  83985. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  83986. /**
  83987. * Set the value of an uniform to a Color3
  83988. * @param uniform defines the webGL uniform location where to store the value
  83989. * @param color3 defines the color to store
  83990. */
  83991. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  83992. /**
  83993. * Set the value of an uniform to a Color3 and an alpha value
  83994. * @param uniform defines the webGL uniform location where to store the value
  83995. * @param color3 defines the color to store
  83996. * @param alpha defines the alpha component to store
  83997. */
  83998. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  83999. /**
  84000. * Sets a Color4 on a uniform variable
  84001. * @param uniform defines the uniform location
  84002. * @param color4 defines the value to be set
  84003. */
  84004. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  84005. /**
  84006. * Set various states to the webGL context
  84007. * @param culling defines backface culling state
  84008. * @param zOffset defines the value to apply to zOffset (0 by default)
  84009. * @param force defines if states must be applied even if cache is up to date
  84010. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  84011. */
  84012. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  84013. /**
  84014. * Set the z offset to apply to current rendering
  84015. * @param value defines the offset to apply
  84016. */
  84017. setZOffset(value: number): void;
  84018. /**
  84019. * Gets the current value of the zOffset
  84020. * @returns the current zOffset state
  84021. */
  84022. getZOffset(): number;
  84023. /**
  84024. * Enable or disable depth buffering
  84025. * @param enable defines the state to set
  84026. */
  84027. setDepthBuffer(enable: boolean): void;
  84028. /**
  84029. * Gets a boolean indicating if depth writing is enabled
  84030. * @returns the current depth writing state
  84031. */
  84032. getDepthWrite(): boolean;
  84033. /**
  84034. * Enable or disable depth writing
  84035. * @param enable defines the state to set
  84036. */
  84037. setDepthWrite(enable: boolean): void;
  84038. /**
  84039. * Enable or disable color writing
  84040. * @param enable defines the state to set
  84041. */
  84042. setColorWrite(enable: boolean): void;
  84043. /**
  84044. * Gets a boolean indicating if color writing is enabled
  84045. * @returns the current color writing state
  84046. */
  84047. getColorWrite(): boolean;
  84048. /**
  84049. * Sets alpha constants used by some alpha blending modes
  84050. * @param r defines the red component
  84051. * @param g defines the green component
  84052. * @param b defines the blue component
  84053. * @param a defines the alpha component
  84054. */
  84055. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84056. /**
  84057. * Sets the current alpha mode
  84058. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84059. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84060. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84061. */
  84062. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84063. /**
  84064. * Gets the current alpha mode
  84065. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84066. * @returns the current alpha mode
  84067. */
  84068. getAlphaMode(): number;
  84069. /**
  84070. * Clears the list of texture accessible through engine.
  84071. * This can help preventing texture load conflict due to name collision.
  84072. */
  84073. clearInternalTexturesCache(): void;
  84074. /**
  84075. * Force the entire cache to be cleared
  84076. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84077. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84078. */
  84079. wipeCaches(bruteForce?: boolean): void;
  84080. /**
  84081. * Set the compressed texture format to use, based on the formats you have, and the formats
  84082. * supported by the hardware / browser.
  84083. *
  84084. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84085. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84086. * to API arguments needed to compressed textures. This puts the burden on the container
  84087. * generator to house the arcane code for determining these for current & future formats.
  84088. *
  84089. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84090. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84091. *
  84092. * Note: The result of this call is not taken into account when a texture is base64.
  84093. *
  84094. * @param formatsAvailable defines the list of those format families you have created
  84095. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84096. *
  84097. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84098. * @returns The extension selected.
  84099. */
  84100. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84101. private _getSamplingParameters;
  84102. private _partialLoadImg;
  84103. private _cascadeLoadImgs;
  84104. /** @hidden */
  84105. _createTexture(): WebGLTexture;
  84106. /**
  84107. * Usually called from Texture.ts.
  84108. * Passed information to create a WebGLTexture
  84109. * @param urlArg defines a value which contains one of the following:
  84110. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84111. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84112. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84113. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84114. * @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)
  84115. * @param scene needed for loading to the correct scene
  84116. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84117. * @param onLoad optional callback to be called upon successful completion
  84118. * @param onError optional callback to be called upon failure
  84119. * @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
  84120. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84121. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84122. * @param forcedExtension defines the extension to use to pick the right loader
  84123. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84124. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84125. */
  84126. 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;
  84127. private _rescaleTexture;
  84128. /**
  84129. * Update a raw texture
  84130. * @param texture defines the texture to update
  84131. * @param data defines the data to store in the texture
  84132. * @param format defines the format of the data
  84133. * @param invertY defines if data must be stored with Y axis inverted
  84134. * @param compression defines the compression used (null by default)
  84135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84136. */
  84137. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84138. /**
  84139. * Creates a raw texture
  84140. * @param data defines the data to store in the texture
  84141. * @param width defines the width of the texture
  84142. * @param height defines the height of the texture
  84143. * @param format defines the format of the data
  84144. * @param generateMipMaps defines if the engine should generate the mip levels
  84145. * @param invertY defines if data must be stored with Y axis inverted
  84146. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84147. * @param compression defines the compression used (null by default)
  84148. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84149. * @returns the raw texture inside an InternalTexture
  84150. */
  84151. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84152. private _unpackFlipYCached;
  84153. /**
  84154. * In case you are sharing the context with other applications, it might
  84155. * be interested to not cache the unpack flip y state to ensure a consistent
  84156. * value would be set.
  84157. */
  84158. enableUnpackFlipYCached: boolean;
  84159. /** @hidden */
  84160. _unpackFlipY(value: boolean): void;
  84161. /** @hidden */
  84162. _getUnpackAlignement(): number;
  84163. /**
  84164. * Creates a dynamic texture
  84165. * @param width defines the width of the texture
  84166. * @param height defines the height of the texture
  84167. * @param generateMipMaps defines if the engine should generate the mip levels
  84168. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84169. * @returns the dynamic texture inside an InternalTexture
  84170. */
  84171. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84172. /**
  84173. * Update the sampling mode of a given texture
  84174. * @param samplingMode defines the required sampling mode
  84175. * @param texture defines the texture to update
  84176. */
  84177. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84178. /**
  84179. * Update the content of a dynamic texture
  84180. * @param texture defines the texture to update
  84181. * @param canvas defines the canvas containing the source
  84182. * @param invertY defines if data must be stored with Y axis inverted
  84183. * @param premulAlpha defines if alpha is stored as premultiplied
  84184. * @param format defines the format of the data
  84185. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84186. */
  84187. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84188. /**
  84189. * Update a video texture
  84190. * @param texture defines the texture to update
  84191. * @param video defines the video element to use
  84192. * @param invertY defines if data must be stored with Y axis inverted
  84193. */
  84194. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84195. /**
  84196. * Updates a depth texture Comparison Mode and Function.
  84197. * If the comparison Function is equal to 0, the mode will be set to none.
  84198. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84199. * @param texture The texture to set the comparison function for
  84200. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84201. */
  84202. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84203. private _setupDepthStencilTexture;
  84204. /**
  84205. * Creates a depth stencil texture.
  84206. * This is only available in WebGL 2 or with the depth texture extension available.
  84207. * @param size The size of face edge in the texture.
  84208. * @param options The options defining the texture.
  84209. * @returns The texture
  84210. */
  84211. createDepthStencilTexture(size: number | {
  84212. width: number;
  84213. height: number;
  84214. }, options: DepthTextureCreationOptions): InternalTexture;
  84215. /**
  84216. * Creates a depth stencil texture.
  84217. * This is only available in WebGL 2 or with the depth texture extension available.
  84218. * @param size The size of face edge in the texture.
  84219. * @param options The options defining the texture.
  84220. * @returns The texture
  84221. */
  84222. private _createDepthStencilTexture;
  84223. /**
  84224. * Creates a depth stencil cube texture.
  84225. * This is only available in WebGL 2.
  84226. * @param size The size of face edge in the cube texture.
  84227. * @param options The options defining the cube texture.
  84228. * @returns The cube texture
  84229. */
  84230. private _createDepthStencilCubeTexture;
  84231. /**
  84232. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84233. * @param renderTarget The render target to set the frame buffer for
  84234. */
  84235. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84236. /**
  84237. * Creates a new render target texture
  84238. * @param size defines the size of the texture
  84239. * @param options defines the options used to create the texture
  84240. * @returns a new render target texture stored in an InternalTexture
  84241. */
  84242. createRenderTargetTexture(size: number | {
  84243. width: number;
  84244. height: number;
  84245. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84246. /**
  84247. * Create a multi render target texture
  84248. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84249. * @param size defines the size of the texture
  84250. * @param options defines the creation options
  84251. * @returns the cube texture as an InternalTexture
  84252. */
  84253. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84254. private _setupFramebufferDepthAttachments;
  84255. /**
  84256. * Updates the sample count of a render target texture
  84257. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84258. * @param texture defines the texture to update
  84259. * @param samples defines the sample count to set
  84260. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84261. */
  84262. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84263. /**
  84264. * Update the sample count for a given multiple render target texture
  84265. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84266. * @param textures defines the textures to update
  84267. * @param samples defines the sample count to set
  84268. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84269. */
  84270. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84271. /** @hidden */
  84272. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84273. /** @hidden */
  84274. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84275. /** @hidden */
  84276. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84277. /** @hidden */
  84278. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84279. /**
  84280. * Creates a new render target cube texture
  84281. * @param size defines the size of the texture
  84282. * @param options defines the options used to create the texture
  84283. * @returns a new render target cube texture stored in an InternalTexture
  84284. */
  84285. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84286. /**
  84287. * Creates a cube texture
  84288. * @param rootUrl defines the url where the files to load is located
  84289. * @param scene defines the current scene
  84290. * @param files defines the list of files to load (1 per face)
  84291. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84292. * @param onLoad defines an optional callback raised when the texture is loaded
  84293. * @param onError defines an optional callback raised if there is an issue to load the texture
  84294. * @param format defines the format of the data
  84295. * @param forcedExtension defines the extension to use to pick the right loader
  84296. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84297. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84298. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84299. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84300. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84301. * @returns the cube texture as an InternalTexture
  84302. */
  84303. 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;
  84304. /**
  84305. * @hidden
  84306. */
  84307. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84308. /**
  84309. * Update a raw cube texture
  84310. * @param texture defines the texture to udpdate
  84311. * @param data defines the data to store
  84312. * @param format defines the data format
  84313. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84314. * @param invertY defines if data must be stored with Y axis inverted
  84315. * @param compression defines the compression used (null by default)
  84316. * @param level defines which level of the texture to update
  84317. */
  84318. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84319. /**
  84320. * Creates a new raw cube texture
  84321. * @param data defines the array of data to use to create each face
  84322. * @param size defines the size of the textures
  84323. * @param format defines the format of the data
  84324. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84325. * @param generateMipMaps defines if the engine should generate the mip levels
  84326. * @param invertY defines if data must be stored with Y axis inverted
  84327. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84328. * @param compression defines the compression used (null by default)
  84329. * @returns the cube texture as an InternalTexture
  84330. */
  84331. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84332. /**
  84333. * Creates a new raw cube texture from a specified url
  84334. * @param url defines the url where the data is located
  84335. * @param scene defines the current scene
  84336. * @param size defines the size of the textures
  84337. * @param format defines the format of the data
  84338. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84339. * @param noMipmap defines if the engine should avoid generating the mip levels
  84340. * @param callback defines a callback used to extract texture data from loaded data
  84341. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84342. * @param onLoad defines a callback called when texture is loaded
  84343. * @param onError defines a callback called if there is an error
  84344. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84345. * @param invertY defines if data must be stored with Y axis inverted
  84346. * @returns the cube texture as an InternalTexture
  84347. */
  84348. 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;
  84349. /**
  84350. * Update a raw 3D texture
  84351. * @param texture defines the texture to update
  84352. * @param data defines the data to store
  84353. * @param format defines the data format
  84354. * @param invertY defines if data must be stored with Y axis inverted
  84355. * @param compression defines the used compression (can be null)
  84356. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84357. */
  84358. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84359. /**
  84360. * Creates a new raw 3D texture
  84361. * @param data defines the data used to create the texture
  84362. * @param width defines the width of the texture
  84363. * @param height defines the height of the texture
  84364. * @param depth defines the depth of the texture
  84365. * @param format defines the format of the texture
  84366. * @param generateMipMaps defines if the engine must generate mip levels
  84367. * @param invertY defines if data must be stored with Y axis inverted
  84368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84369. * @param compression defines the compressed used (can be null)
  84370. * @param textureType defines the compressed used (can be null)
  84371. * @returns a new raw 3D texture (stored in an InternalTexture)
  84372. */
  84373. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84374. private _prepareWebGLTextureContinuation;
  84375. private _prepareWebGLTexture;
  84376. private _convertRGBtoRGBATextureData;
  84377. /** @hidden */
  84378. _releaseFramebufferObjects(texture: InternalTexture): void;
  84379. /** @hidden */
  84380. _releaseTexture(texture: InternalTexture): void;
  84381. private setProgram;
  84382. private _boundUniforms;
  84383. /**
  84384. * Binds an effect to the webGL context
  84385. * @param effect defines the effect to bind
  84386. */
  84387. bindSamplers(effect: Effect): void;
  84388. private _moveBoundTextureOnTop;
  84389. private _getCorrectTextureChannel;
  84390. private _linkTrackers;
  84391. private _removeDesignatedSlot;
  84392. private _activateCurrentTexture;
  84393. /** @hidden */
  84394. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84395. /** @hidden */
  84396. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84397. /**
  84398. * Sets a texture to the webGL context from a postprocess
  84399. * @param channel defines the channel to use
  84400. * @param postProcess defines the source postprocess
  84401. */
  84402. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84403. /**
  84404. * Binds the output of the passed in post process to the texture channel specified
  84405. * @param channel The channel the texture should be bound to
  84406. * @param postProcess The post process which's output should be bound
  84407. */
  84408. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84409. /**
  84410. * Unbind all textures from the webGL context
  84411. */
  84412. unbindAllTextures(): void;
  84413. /**
  84414. * Sets a texture to the according uniform.
  84415. * @param channel The texture channel
  84416. * @param uniform The uniform to set
  84417. * @param texture The texture to apply
  84418. */
  84419. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84420. /**
  84421. * Sets a depth stencil texture from a render target to the according uniform.
  84422. * @param channel The texture channel
  84423. * @param uniform The uniform to set
  84424. * @param texture The render target texture containing the depth stencil texture to apply
  84425. */
  84426. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84427. private _bindSamplerUniformToChannel;
  84428. private _getTextureWrapMode;
  84429. private _setTexture;
  84430. /**
  84431. * Sets an array of texture to the webGL context
  84432. * @param channel defines the channel where the texture array must be set
  84433. * @param uniform defines the associated uniform location
  84434. * @param textures defines the array of textures to bind
  84435. */
  84436. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84437. /** @hidden */
  84438. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84439. private _setTextureParameterFloat;
  84440. private _setTextureParameterInteger;
  84441. /**
  84442. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84443. * @param x defines the x coordinate of the rectangle where pixels must be read
  84444. * @param y defines the y coordinate of the rectangle where pixels must be read
  84445. * @param width defines the width of the rectangle where pixels must be read
  84446. * @param height defines the height of the rectangle where pixels must be read
  84447. * @returns a Uint8Array containing RGBA colors
  84448. */
  84449. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84450. /**
  84451. * Add an externaly attached data from its key.
  84452. * This method call will fail and return false, if such key already exists.
  84453. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84454. * @param key the unique key that identifies the data
  84455. * @param data the data object to associate to the key for this Engine instance
  84456. * @return true if no such key were already present and the data was added successfully, false otherwise
  84457. */
  84458. addExternalData<T>(key: string, data: T): boolean;
  84459. /**
  84460. * Get an externaly attached data from its key
  84461. * @param key the unique key that identifies the data
  84462. * @return the associated data, if present (can be null), or undefined if not present
  84463. */
  84464. getExternalData<T>(key: string): T;
  84465. /**
  84466. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84467. * @param key the unique key that identifies the data
  84468. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84469. * @return the associated data, can be null if the factory returned null.
  84470. */
  84471. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84472. /**
  84473. * Remove an externaly attached data from the Engine instance
  84474. * @param key the unique key that identifies the data
  84475. * @return true if the data was successfully removed, false if it doesn't exist
  84476. */
  84477. removeExternalData(key: string): boolean;
  84478. /**
  84479. * Unbind all vertex attributes from the webGL context
  84480. */
  84481. unbindAllAttributes(): void;
  84482. /**
  84483. * 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
  84484. */
  84485. releaseEffects(): void;
  84486. /**
  84487. * Dispose and release all associated resources
  84488. */
  84489. dispose(): void;
  84490. /**
  84491. * Display the loading screen
  84492. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84493. */
  84494. displayLoadingUI(): void;
  84495. /**
  84496. * Hide the loading screen
  84497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84498. */
  84499. hideLoadingUI(): void;
  84500. /**
  84501. * Gets the current loading screen object
  84502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84503. */
  84504. /**
  84505. * Sets the current loading screen object
  84506. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84507. */
  84508. loadingScreen: ILoadingScreen;
  84509. /**
  84510. * Sets the current loading screen text
  84511. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84512. */
  84513. loadingUIText: string;
  84514. /**
  84515. * Sets the current loading screen background color
  84516. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84517. */
  84518. loadingUIBackgroundColor: string;
  84519. /**
  84520. * Attach a new callback raised when context lost event is fired
  84521. * @param callback defines the callback to call
  84522. */
  84523. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84524. /**
  84525. * Attach a new callback raised when context restored event is fired
  84526. * @param callback defines the callback to call
  84527. */
  84528. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84529. /**
  84530. * Gets the source code of the vertex shader associated with a specific webGL program
  84531. * @param program defines the program to use
  84532. * @returns a string containing the source code of the vertex shader associated with the program
  84533. */
  84534. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84535. /**
  84536. * Gets the source code of the fragment shader associated with a specific webGL program
  84537. * @param program defines the program to use
  84538. * @returns a string containing the source code of the fragment shader associated with the program
  84539. */
  84540. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  84541. /**
  84542. * Get the current error code of the webGL context
  84543. * @returns the error code
  84544. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  84545. */
  84546. getError(): number;
  84547. /**
  84548. * Gets the current framerate
  84549. * @returns a number representing the framerate
  84550. */
  84551. getFps(): number;
  84552. /**
  84553. * Gets the time spent between current and previous frame
  84554. * @returns a number representing the delta time in ms
  84555. */
  84556. getDeltaTime(): number;
  84557. private _measureFps;
  84558. /** @hidden */
  84559. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  84560. private _canRenderToFloatFramebuffer;
  84561. private _canRenderToHalfFloatFramebuffer;
  84562. private _canRenderToFramebuffer;
  84563. /** @hidden */
  84564. _getWebGLTextureType(type: number): number;
  84565. private _getInternalFormat;
  84566. /** @hidden */
  84567. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  84568. /** @hidden */
  84569. _getRGBAMultiSampleBufferFormat(type: number): number;
  84570. /** @hidden */
  84571. _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;
  84572. /** @hidden */
  84573. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  84574. private _partialLoadFile;
  84575. private _cascadeLoadFiles;
  84576. /**
  84577. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  84578. * @returns true if the engine can be created
  84579. * @ignorenaming
  84580. */
  84581. static isSupported(): boolean;
  84582. }
  84583. }
  84584. declare module BABYLON {
  84585. /**
  84586. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84587. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84588. */
  84589. export class EffectFallbacks {
  84590. private _defines;
  84591. private _currentRank;
  84592. private _maxRank;
  84593. private _mesh;
  84594. /**
  84595. * Removes the fallback from the bound mesh.
  84596. */
  84597. unBindMesh(): void;
  84598. /**
  84599. * Adds a fallback on the specified property.
  84600. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84601. * @param define The name of the define in the shader
  84602. */
  84603. addFallback(rank: number, define: string): void;
  84604. /**
  84605. * Sets the mesh to use CPU skinning when needing to fallback.
  84606. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84607. * @param mesh The mesh to use the fallbacks.
  84608. */
  84609. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84610. /**
  84611. * Checks to see if more fallbacks are still availible.
  84612. */
  84613. readonly isMoreFallbacks: boolean;
  84614. /**
  84615. * Removes the defines that shoould be removed when falling back.
  84616. * @param currentDefines defines the current define statements for the shader.
  84617. * @param effect defines the current effect we try to compile
  84618. * @returns The resulting defines with defines of the current rank removed.
  84619. */
  84620. reduce(currentDefines: string, effect: Effect): string;
  84621. }
  84622. /**
  84623. * Options to be used when creating an effect.
  84624. */
  84625. export class EffectCreationOptions {
  84626. /**
  84627. * Atrributes that will be used in the shader.
  84628. */
  84629. attributes: string[];
  84630. /**
  84631. * Uniform varible names that will be set in the shader.
  84632. */
  84633. uniformsNames: string[];
  84634. /**
  84635. * Uniform buffer varible names that will be set in the shader.
  84636. */
  84637. uniformBuffersNames: string[];
  84638. /**
  84639. * Sampler texture variable names that will be set in the shader.
  84640. */
  84641. samplers: string[];
  84642. /**
  84643. * Define statements that will be set in the shader.
  84644. */
  84645. defines: any;
  84646. /**
  84647. * Possible fallbacks for this effect to improve performance when needed.
  84648. */
  84649. fallbacks: Nullable<EffectFallbacks>;
  84650. /**
  84651. * Callback that will be called when the shader is compiled.
  84652. */
  84653. onCompiled: Nullable<(effect: Effect) => void>;
  84654. /**
  84655. * Callback that will be called if an error occurs during shader compilation.
  84656. */
  84657. onError: Nullable<(effect: Effect, errors: string) => void>;
  84658. /**
  84659. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84660. */
  84661. indexParameters: any;
  84662. /**
  84663. * Max number of lights that can be used in the shader.
  84664. */
  84665. maxSimultaneousLights: number;
  84666. /**
  84667. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  84668. */
  84669. transformFeedbackVaryings: Nullable<string[]>;
  84670. }
  84671. /**
  84672. * Effect containing vertex and fragment shader that can be executed on an object.
  84673. */
  84674. export class Effect {
  84675. /**
  84676. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84677. */
  84678. static ShadersRepository: string;
  84679. /**
  84680. * Name of the effect.
  84681. */
  84682. name: any;
  84683. /**
  84684. * String container all the define statements that should be set on the shader.
  84685. */
  84686. defines: string;
  84687. /**
  84688. * Callback that will be called when the shader is compiled.
  84689. */
  84690. onCompiled: Nullable<(effect: Effect) => void>;
  84691. /**
  84692. * Callback that will be called if an error occurs during shader compilation.
  84693. */
  84694. onError: Nullable<(effect: Effect, errors: string) => void>;
  84695. /**
  84696. * Callback that will be called when effect is bound.
  84697. */
  84698. onBind: Nullable<(effect: Effect) => void>;
  84699. /**
  84700. * Unique ID of the effect.
  84701. */
  84702. uniqueId: number;
  84703. /**
  84704. * Observable that will be called when the shader is compiled.
  84705. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  84706. */
  84707. onCompileObservable: Observable<Effect>;
  84708. /**
  84709. * Observable that will be called if an error occurs during shader compilation.
  84710. */
  84711. onErrorObservable: Observable<Effect>;
  84712. /** @hidden */
  84713. _onBindObservable: Nullable<Observable<Effect>>;
  84714. /**
  84715. * Observable that will be called when effect is bound.
  84716. */
  84717. readonly onBindObservable: Observable<Effect>;
  84718. /** @hidden */
  84719. _bonesComputationForcedToCPU: boolean;
  84720. private static _uniqueIdSeed;
  84721. private _engine;
  84722. private _uniformBuffersNames;
  84723. private _uniformsNames;
  84724. private _samplers;
  84725. private _isReady;
  84726. private _compilationError;
  84727. private _attributesNames;
  84728. private _attributes;
  84729. private _uniforms;
  84730. /**
  84731. * Key for the effect.
  84732. * @hidden
  84733. */
  84734. _key: string;
  84735. private _indexParameters;
  84736. private _fallbacks;
  84737. private _vertexSourceCode;
  84738. private _fragmentSourceCode;
  84739. private _vertexSourceCodeOverride;
  84740. private _fragmentSourceCodeOverride;
  84741. private _transformFeedbackVaryings;
  84742. /**
  84743. * Compiled shader to webGL program.
  84744. * @hidden
  84745. */
  84746. _program: WebGLProgram;
  84747. private _valueCache;
  84748. private static _baseCache;
  84749. /**
  84750. * Instantiates an effect.
  84751. * An effect can be used to create/manage/execute vertex and fragment shaders.
  84752. * @param baseName Name of the effect.
  84753. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  84754. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  84755. * @param samplers List of sampler variables that will be passed to the shader.
  84756. * @param engine Engine to be used to render the effect
  84757. * @param defines Define statements to be added to the shader.
  84758. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  84759. * @param onCompiled Callback that will be called when the shader is compiled.
  84760. * @param onError Callback that will be called if an error occurs during shader compilation.
  84761. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84762. */
  84763. 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);
  84764. /**
  84765. * Unique key for this effect
  84766. */
  84767. readonly key: string;
  84768. /**
  84769. * If the effect has been compiled and prepared.
  84770. * @returns if the effect is compiled and prepared.
  84771. */
  84772. isReady(): boolean;
  84773. /**
  84774. * The engine the effect was initialized with.
  84775. * @returns the engine.
  84776. */
  84777. getEngine(): Engine;
  84778. /**
  84779. * The compiled webGL program for the effect
  84780. * @returns the webGL program.
  84781. */
  84782. getProgram(): WebGLProgram;
  84783. /**
  84784. * The set of names of attribute variables for the shader.
  84785. * @returns An array of attribute names.
  84786. */
  84787. getAttributesNames(): string[];
  84788. /**
  84789. * Returns the attribute at the given index.
  84790. * @param index The index of the attribute.
  84791. * @returns The location of the attribute.
  84792. */
  84793. getAttributeLocation(index: number): number;
  84794. /**
  84795. * Returns the attribute based on the name of the variable.
  84796. * @param name of the attribute to look up.
  84797. * @returns the attribute location.
  84798. */
  84799. getAttributeLocationByName(name: string): number;
  84800. /**
  84801. * The number of attributes.
  84802. * @returns the numnber of attributes.
  84803. */
  84804. getAttributesCount(): number;
  84805. /**
  84806. * Gets the index of a uniform variable.
  84807. * @param uniformName of the uniform to look up.
  84808. * @returns the index.
  84809. */
  84810. getUniformIndex(uniformName: string): number;
  84811. /**
  84812. * Returns the attribute based on the name of the variable.
  84813. * @param uniformName of the uniform to look up.
  84814. * @returns the location of the uniform.
  84815. */
  84816. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  84817. /**
  84818. * Returns an array of sampler variable names
  84819. * @returns The array of sampler variable neames.
  84820. */
  84821. getSamplers(): string[];
  84822. /**
  84823. * The error from the last compilation.
  84824. * @returns the error string.
  84825. */
  84826. getCompilationError(): string;
  84827. /**
  84828. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  84829. * @param func The callback to be used.
  84830. */
  84831. executeWhenCompiled(func: (effect: Effect) => void): void;
  84832. private _checkIsReady;
  84833. /** @hidden */
  84834. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  84835. /** @hidden */
  84836. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  84837. /** @hidden */
  84838. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  84839. private _processShaderConversion;
  84840. private _processIncludes;
  84841. private _processPrecision;
  84842. /**
  84843. * Recompiles the webGL program
  84844. * @param vertexSourceCode The source code for the vertex shader.
  84845. * @param fragmentSourceCode The source code for the fragment shader.
  84846. * @param onCompiled Callback called when completed.
  84847. * @param onError Callback called on error.
  84848. * @hidden
  84849. */
  84850. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  84851. /**
  84852. * Gets the uniform locations of the the specified variable names
  84853. * @param names THe names of the variables to lookup.
  84854. * @returns Array of locations in the same order as variable names.
  84855. */
  84856. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  84857. /**
  84858. * Prepares the effect
  84859. * @hidden
  84860. */
  84861. _prepareEffect(): void;
  84862. /**
  84863. * Checks if the effect is supported. (Must be called after compilation)
  84864. */
  84865. readonly isSupported: boolean;
  84866. /**
  84867. * Binds a texture to the engine to be used as output of the shader.
  84868. * @param channel Name of the output variable.
  84869. * @param texture Texture to bind.
  84870. * @hidden
  84871. */
  84872. _bindTexture(channel: string, texture: InternalTexture): void;
  84873. /**
  84874. * Sets a texture on the engine to be used in the shader.
  84875. * @param channel Name of the sampler variable.
  84876. * @param texture Texture to set.
  84877. */
  84878. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  84879. /**
  84880. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  84881. * @param channel Name of the sampler variable.
  84882. * @param texture Texture to set.
  84883. */
  84884. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  84885. /**
  84886. * Sets an array of textures on the engine to be used in the shader.
  84887. * @param channel Name of the variable.
  84888. * @param textures Textures to set.
  84889. */
  84890. setTextureArray(channel: string, textures: BaseTexture[]): void;
  84891. /**
  84892. * 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)
  84893. * @param channel Name of the sampler variable.
  84894. * @param postProcess Post process to get the input texture from.
  84895. */
  84896. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  84897. /**
  84898. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  84899. * 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)
  84900. * @param channel Name of the sampler variable.
  84901. * @param postProcess Post process to get the output texture from.
  84902. */
  84903. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  84904. /** @hidden */
  84905. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  84906. /** @hidden */
  84907. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  84908. /** @hidden */
  84909. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  84910. /** @hidden */
  84911. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  84912. /**
  84913. * Binds a buffer to a uniform.
  84914. * @param buffer Buffer to bind.
  84915. * @param name Name of the uniform variable to bind to.
  84916. */
  84917. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  84918. /**
  84919. * Binds block to a uniform.
  84920. * @param blockName Name of the block to bind.
  84921. * @param index Index to bind.
  84922. */
  84923. bindUniformBlock(blockName: string, index: number): void;
  84924. /**
  84925. * Sets an interger value on a uniform variable.
  84926. * @param uniformName Name of the variable.
  84927. * @param value Value to be set.
  84928. * @returns this effect.
  84929. */
  84930. setInt(uniformName: string, value: number): Effect;
  84931. /**
  84932. * Sets an int array on a uniform variable.
  84933. * @param uniformName Name of the variable.
  84934. * @param array array to be set.
  84935. * @returns this effect.
  84936. */
  84937. setIntArray(uniformName: string, array: Int32Array): Effect;
  84938. /**
  84939. * 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)
  84940. * @param uniformName Name of the variable.
  84941. * @param array array to be set.
  84942. * @returns this effect.
  84943. */
  84944. setIntArray2(uniformName: string, array: Int32Array): Effect;
  84945. /**
  84946. * 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)
  84947. * @param uniformName Name of the variable.
  84948. * @param array array to be set.
  84949. * @returns this effect.
  84950. */
  84951. setIntArray3(uniformName: string, array: Int32Array): Effect;
  84952. /**
  84953. * 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)
  84954. * @param uniformName Name of the variable.
  84955. * @param array array to be set.
  84956. * @returns this effect.
  84957. */
  84958. setIntArray4(uniformName: string, array: Int32Array): Effect;
  84959. /**
  84960. * Sets an float array on a uniform variable.
  84961. * @param uniformName Name of the variable.
  84962. * @param array array to be set.
  84963. * @returns this effect.
  84964. */
  84965. setFloatArray(uniformName: string, array: Float32Array): Effect;
  84966. /**
  84967. * 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)
  84968. * @param uniformName Name of the variable.
  84969. * @param array array to be set.
  84970. * @returns this effect.
  84971. */
  84972. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  84973. /**
  84974. * 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)
  84975. * @param uniformName Name of the variable.
  84976. * @param array array to be set.
  84977. * @returns this effect.
  84978. */
  84979. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  84980. /**
  84981. * 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)
  84982. * @param uniformName Name of the variable.
  84983. * @param array array to be set.
  84984. * @returns this effect.
  84985. */
  84986. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  84987. /**
  84988. * Sets an array on a uniform variable.
  84989. * @param uniformName Name of the variable.
  84990. * @param array array to be set.
  84991. * @returns this effect.
  84992. */
  84993. setArray(uniformName: string, array: number[]): Effect;
  84994. /**
  84995. * 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)
  84996. * @param uniformName Name of the variable.
  84997. * @param array array to be set.
  84998. * @returns this effect.
  84999. */
  85000. setArray2(uniformName: string, array: number[]): Effect;
  85001. /**
  85002. * 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)
  85003. * @param uniformName Name of the variable.
  85004. * @param array array to be set.
  85005. * @returns this effect.
  85006. */
  85007. setArray3(uniformName: string, array: number[]): Effect;
  85008. /**
  85009. * 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)
  85010. * @param uniformName Name of the variable.
  85011. * @param array array to be set.
  85012. * @returns this effect.
  85013. */
  85014. setArray4(uniformName: string, array: number[]): Effect;
  85015. /**
  85016. * Sets matrices on a uniform variable.
  85017. * @param uniformName Name of the variable.
  85018. * @param matrices matrices to be set.
  85019. * @returns this effect.
  85020. */
  85021. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  85022. /**
  85023. * Sets matrix on a uniform variable.
  85024. * @param uniformName Name of the variable.
  85025. * @param matrix matrix to be set.
  85026. * @returns this effect.
  85027. */
  85028. setMatrix(uniformName: string, matrix: Matrix): Effect;
  85029. /**
  85030. * 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)
  85031. * @param uniformName Name of the variable.
  85032. * @param matrix matrix to be set.
  85033. * @returns this effect.
  85034. */
  85035. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85036. /**
  85037. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85038. * @param uniformName Name of the variable.
  85039. * @param matrix matrix to be set.
  85040. * @returns this effect.
  85041. */
  85042. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85043. /**
  85044. * Sets a float on a uniform variable.
  85045. * @param uniformName Name of the variable.
  85046. * @param value value to be set.
  85047. * @returns this effect.
  85048. */
  85049. setFloat(uniformName: string, value: number): Effect;
  85050. /**
  85051. * Sets a boolean on a uniform variable.
  85052. * @param uniformName Name of the variable.
  85053. * @param bool value to be set.
  85054. * @returns this effect.
  85055. */
  85056. setBool(uniformName: string, bool: boolean): Effect;
  85057. /**
  85058. * Sets a Vector2 on a uniform variable.
  85059. * @param uniformName Name of the variable.
  85060. * @param vector2 vector2 to be set.
  85061. * @returns this effect.
  85062. */
  85063. setVector2(uniformName: string, vector2: Vector2): Effect;
  85064. /**
  85065. * Sets a float2 on a uniform variable.
  85066. * @param uniformName Name of the variable.
  85067. * @param x First float in float2.
  85068. * @param y Second float in float2.
  85069. * @returns this effect.
  85070. */
  85071. setFloat2(uniformName: string, x: number, y: number): Effect;
  85072. /**
  85073. * Sets a Vector3 on a uniform variable.
  85074. * @param uniformName Name of the variable.
  85075. * @param vector3 Value to be set.
  85076. * @returns this effect.
  85077. */
  85078. setVector3(uniformName: string, vector3: Vector3): Effect;
  85079. /**
  85080. * Sets a float3 on a uniform variable.
  85081. * @param uniformName Name of the variable.
  85082. * @param x First float in float3.
  85083. * @param y Second float in float3.
  85084. * @param z Third float in float3.
  85085. * @returns this effect.
  85086. */
  85087. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85088. /**
  85089. * Sets a Vector4 on a uniform variable.
  85090. * @param uniformName Name of the variable.
  85091. * @param vector4 Value to be set.
  85092. * @returns this effect.
  85093. */
  85094. setVector4(uniformName: string, vector4: Vector4): Effect;
  85095. /**
  85096. * Sets a float4 on a uniform variable.
  85097. * @param uniformName Name of the variable.
  85098. * @param x First float in float4.
  85099. * @param y Second float in float4.
  85100. * @param z Third float in float4.
  85101. * @param w Fourth float in float4.
  85102. * @returns this effect.
  85103. */
  85104. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85105. /**
  85106. * Sets a Color3 on a uniform variable.
  85107. * @param uniformName Name of the variable.
  85108. * @param color3 Value to be set.
  85109. * @returns this effect.
  85110. */
  85111. setColor3(uniformName: string, color3: Color3): Effect;
  85112. /**
  85113. * Sets a Color4 on a uniform variable.
  85114. * @param uniformName Name of the variable.
  85115. * @param color3 Value to be set.
  85116. * @param alpha Alpha value to be set.
  85117. * @returns this effect.
  85118. */
  85119. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85120. /**
  85121. * Sets a Color4 on a uniform variable
  85122. * @param uniformName defines the name of the variable
  85123. * @param color4 defines the value to be set
  85124. * @returns this effect.
  85125. */
  85126. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85127. /**
  85128. * This function will add a new shader to the shader store
  85129. * @param name the name of the shader
  85130. * @param pixelShader optional pixel shader content
  85131. * @param vertexShader optional vertex shader content
  85132. */
  85133. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85134. /**
  85135. * Store of each shader (The can be looked up using effect.key)
  85136. */
  85137. static ShadersStore: {
  85138. [key: string]: string;
  85139. };
  85140. /**
  85141. * Store of each included file for a shader (The can be looked up using effect.key)
  85142. */
  85143. static IncludesShadersStore: {
  85144. [key: string]: string;
  85145. };
  85146. /**
  85147. * Resets the cache of effects.
  85148. */
  85149. static ResetCache(): void;
  85150. }
  85151. }
  85152. declare module BABYLON {
  85153. /**
  85154. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85155. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85156. * 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;
  85157. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85158. */
  85159. export class ColorCurves {
  85160. private _dirty;
  85161. private _tempColor;
  85162. private _globalCurve;
  85163. private _highlightsCurve;
  85164. private _midtonesCurve;
  85165. private _shadowsCurve;
  85166. private _positiveCurve;
  85167. private _negativeCurve;
  85168. private _globalHue;
  85169. private _globalDensity;
  85170. private _globalSaturation;
  85171. private _globalExposure;
  85172. /**
  85173. * Gets the global Hue value.
  85174. * 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).
  85175. */
  85176. /**
  85177. * Sets the global Hue value.
  85178. * 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).
  85179. */
  85180. globalHue: number;
  85181. /**
  85182. * Gets the global Density value.
  85183. * 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.
  85184. * Values less than zero provide a filter of opposite hue.
  85185. */
  85186. /**
  85187. * Sets the global Density value.
  85188. * 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.
  85189. * Values less than zero provide a filter of opposite hue.
  85190. */
  85191. globalDensity: number;
  85192. /**
  85193. * Gets the global Saturation value.
  85194. * 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.
  85195. */
  85196. /**
  85197. * Sets the global Saturation value.
  85198. * 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.
  85199. */
  85200. globalSaturation: number;
  85201. /**
  85202. * Gets the global Exposure value.
  85203. * 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.
  85204. */
  85205. /**
  85206. * Sets the global Exposure value.
  85207. * 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.
  85208. */
  85209. globalExposure: number;
  85210. private _highlightsHue;
  85211. private _highlightsDensity;
  85212. private _highlightsSaturation;
  85213. private _highlightsExposure;
  85214. /**
  85215. * Gets the highlights Hue value.
  85216. * 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).
  85217. */
  85218. /**
  85219. * Sets the highlights Hue value.
  85220. * 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).
  85221. */
  85222. highlightsHue: number;
  85223. /**
  85224. * Gets the highlights Density value.
  85225. * 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.
  85226. * Values less than zero provide a filter of opposite hue.
  85227. */
  85228. /**
  85229. * Sets the highlights Density value.
  85230. * 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.
  85231. * Values less than zero provide a filter of opposite hue.
  85232. */
  85233. highlightsDensity: number;
  85234. /**
  85235. * Gets the highlights Saturation value.
  85236. * 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.
  85237. */
  85238. /**
  85239. * Sets the highlights Saturation value.
  85240. * 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.
  85241. */
  85242. highlightsSaturation: number;
  85243. /**
  85244. * Gets the highlights Exposure value.
  85245. * 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.
  85246. */
  85247. /**
  85248. * Sets the highlights Exposure value.
  85249. * 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.
  85250. */
  85251. highlightsExposure: number;
  85252. private _midtonesHue;
  85253. private _midtonesDensity;
  85254. private _midtonesSaturation;
  85255. private _midtonesExposure;
  85256. /**
  85257. * Gets the midtones Hue value.
  85258. * 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).
  85259. */
  85260. /**
  85261. * Sets the midtones Hue value.
  85262. * 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).
  85263. */
  85264. midtonesHue: number;
  85265. /**
  85266. * Gets the midtones Density value.
  85267. * 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.
  85268. * Values less than zero provide a filter of opposite hue.
  85269. */
  85270. /**
  85271. * Sets the midtones Density value.
  85272. * 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.
  85273. * Values less than zero provide a filter of opposite hue.
  85274. */
  85275. midtonesDensity: number;
  85276. /**
  85277. * Gets the midtones Saturation value.
  85278. * 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.
  85279. */
  85280. /**
  85281. * Sets the midtones Saturation value.
  85282. * 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.
  85283. */
  85284. midtonesSaturation: number;
  85285. /**
  85286. * Gets the midtones Exposure value.
  85287. * 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.
  85288. */
  85289. /**
  85290. * Sets the midtones Exposure value.
  85291. * 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.
  85292. */
  85293. midtonesExposure: number;
  85294. private _shadowsHue;
  85295. private _shadowsDensity;
  85296. private _shadowsSaturation;
  85297. private _shadowsExposure;
  85298. /**
  85299. * Gets the shadows Hue value.
  85300. * 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).
  85301. */
  85302. /**
  85303. * Sets the shadows Hue value.
  85304. * 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).
  85305. */
  85306. shadowsHue: number;
  85307. /**
  85308. * Gets the shadows Density value.
  85309. * 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.
  85310. * Values less than zero provide a filter of opposite hue.
  85311. */
  85312. /**
  85313. * Sets the shadows Density value.
  85314. * 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.
  85315. * Values less than zero provide a filter of opposite hue.
  85316. */
  85317. shadowsDensity: number;
  85318. /**
  85319. * Gets the shadows Saturation value.
  85320. * 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.
  85321. */
  85322. /**
  85323. * Sets the shadows Saturation value.
  85324. * 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.
  85325. */
  85326. shadowsSaturation: number;
  85327. /**
  85328. * Gets the shadows Exposure value.
  85329. * 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.
  85330. */
  85331. /**
  85332. * Sets the shadows Exposure value.
  85333. * 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.
  85334. */
  85335. shadowsExposure: number;
  85336. /**
  85337. * Returns the class name
  85338. * @returns The class name
  85339. */
  85340. getClassName(): string;
  85341. /**
  85342. * Binds the color curves to the shader.
  85343. * @param colorCurves The color curve to bind
  85344. * @param effect The effect to bind to
  85345. * @param positiveUniform The positive uniform shader parameter
  85346. * @param neutralUniform The neutral uniform shader parameter
  85347. * @param negativeUniform The negative uniform shader parameter
  85348. */
  85349. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85350. /**
  85351. * Prepare the list of uniforms associated with the ColorCurves effects.
  85352. * @param uniformsList The list of uniforms used in the effect
  85353. */
  85354. static PrepareUniforms(uniformsList: string[]): void;
  85355. /**
  85356. * Returns color grading data based on a hue, density, saturation and exposure value.
  85357. * @param filterHue The hue of the color filter.
  85358. * @param filterDensity The density of the color filter.
  85359. * @param saturation The saturation.
  85360. * @param exposure The exposure.
  85361. * @param result The result data container.
  85362. */
  85363. private getColorGradingDataToRef;
  85364. /**
  85365. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85366. * @param value The input slider value in range [-100,100].
  85367. * @returns Adjusted value.
  85368. */
  85369. private static applyColorGradingSliderNonlinear;
  85370. /**
  85371. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85372. * @param hue The hue (H) input.
  85373. * @param saturation The saturation (S) input.
  85374. * @param brightness The brightness (B) input.
  85375. * @result An RGBA color represented as Vector4.
  85376. */
  85377. private static fromHSBToRef;
  85378. /**
  85379. * Returns a value clamped between min and max
  85380. * @param value The value to clamp
  85381. * @param min The minimum of value
  85382. * @param max The maximum of value
  85383. * @returns The clamped value.
  85384. */
  85385. private static clamp;
  85386. /**
  85387. * Clones the current color curve instance.
  85388. * @return The cloned curves
  85389. */
  85390. clone(): ColorCurves;
  85391. /**
  85392. * Serializes the current color curve instance to a json representation.
  85393. * @return a JSON representation
  85394. */
  85395. serialize(): any;
  85396. /**
  85397. * Parses the color curve from a json representation.
  85398. * @param source the JSON source to parse
  85399. * @return The parsed curves
  85400. */
  85401. static Parse(source: any): ColorCurves;
  85402. }
  85403. }
  85404. declare module BABYLON {
  85405. /**
  85406. * Interface to follow in your material defines to integrate easily the
  85407. * Image proccessing functions.
  85408. * @hidden
  85409. */
  85410. export interface IImageProcessingConfigurationDefines {
  85411. IMAGEPROCESSING: boolean;
  85412. VIGNETTE: boolean;
  85413. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85414. VIGNETTEBLENDMODEOPAQUE: boolean;
  85415. TONEMAPPING: boolean;
  85416. TONEMAPPING_ACES: boolean;
  85417. CONTRAST: boolean;
  85418. EXPOSURE: boolean;
  85419. COLORCURVES: boolean;
  85420. COLORGRADING: boolean;
  85421. COLORGRADING3D: boolean;
  85422. SAMPLER3DGREENDEPTH: boolean;
  85423. SAMPLER3DBGRMAP: boolean;
  85424. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85425. }
  85426. /**
  85427. * @hidden
  85428. */
  85429. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85430. IMAGEPROCESSING: boolean;
  85431. VIGNETTE: boolean;
  85432. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85433. VIGNETTEBLENDMODEOPAQUE: boolean;
  85434. TONEMAPPING: boolean;
  85435. TONEMAPPING_ACES: boolean;
  85436. CONTRAST: boolean;
  85437. COLORCURVES: boolean;
  85438. COLORGRADING: boolean;
  85439. COLORGRADING3D: boolean;
  85440. SAMPLER3DGREENDEPTH: boolean;
  85441. SAMPLER3DBGRMAP: boolean;
  85442. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85443. EXPOSURE: boolean;
  85444. constructor();
  85445. }
  85446. /**
  85447. * This groups together the common properties used for image processing either in direct forward pass
  85448. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85449. * or not.
  85450. */
  85451. export class ImageProcessingConfiguration {
  85452. /**
  85453. * Default tone mapping applied in BabylonJS.
  85454. */
  85455. static readonly TONEMAPPING_STANDARD: number;
  85456. /**
  85457. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85458. * to other engines rendering to increase portability.
  85459. */
  85460. static readonly TONEMAPPING_ACES: number;
  85461. /**
  85462. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85463. */
  85464. colorCurves: Nullable<ColorCurves>;
  85465. private _colorCurvesEnabled;
  85466. /**
  85467. * Gets wether the color curves effect is enabled.
  85468. */
  85469. /**
  85470. * Sets wether the color curves effect is enabled.
  85471. */
  85472. colorCurvesEnabled: boolean;
  85473. private _colorGradingTexture;
  85474. /**
  85475. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85476. */
  85477. /**
  85478. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85479. */
  85480. colorGradingTexture: Nullable<BaseTexture>;
  85481. private _colorGradingEnabled;
  85482. /**
  85483. * Gets wether the color grading effect is enabled.
  85484. */
  85485. /**
  85486. * Sets wether the color grading effect is enabled.
  85487. */
  85488. colorGradingEnabled: boolean;
  85489. private _colorGradingWithGreenDepth;
  85490. /**
  85491. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85492. */
  85493. /**
  85494. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85495. */
  85496. colorGradingWithGreenDepth: boolean;
  85497. private _colorGradingBGR;
  85498. /**
  85499. * Gets wether the color grading texture contains BGR values.
  85500. */
  85501. /**
  85502. * Sets wether the color grading texture contains BGR values.
  85503. */
  85504. colorGradingBGR: boolean;
  85505. /** @hidden */
  85506. _exposure: number;
  85507. /**
  85508. * Gets the Exposure used in the effect.
  85509. */
  85510. /**
  85511. * Sets the Exposure used in the effect.
  85512. */
  85513. exposure: number;
  85514. private _toneMappingEnabled;
  85515. /**
  85516. * Gets wether the tone mapping effect is enabled.
  85517. */
  85518. /**
  85519. * Sets wether the tone mapping effect is enabled.
  85520. */
  85521. toneMappingEnabled: boolean;
  85522. private _toneMappingType;
  85523. /**
  85524. * Gets the type of tone mapping effect.
  85525. */
  85526. /**
  85527. * Sets the type of tone mapping effect used in BabylonJS.
  85528. */
  85529. toneMappingType: number;
  85530. protected _contrast: number;
  85531. /**
  85532. * Gets the contrast used in the effect.
  85533. */
  85534. /**
  85535. * Sets the contrast used in the effect.
  85536. */
  85537. contrast: number;
  85538. /**
  85539. * Vignette stretch size.
  85540. */
  85541. vignetteStretch: number;
  85542. /**
  85543. * Vignette centre X Offset.
  85544. */
  85545. vignetteCentreX: number;
  85546. /**
  85547. * Vignette centre Y Offset.
  85548. */
  85549. vignetteCentreY: number;
  85550. /**
  85551. * Vignette weight or intensity of the vignette effect.
  85552. */
  85553. vignetteWeight: number;
  85554. /**
  85555. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85556. * if vignetteEnabled is set to true.
  85557. */
  85558. vignetteColor: Color4;
  85559. /**
  85560. * Camera field of view used by the Vignette effect.
  85561. */
  85562. vignetteCameraFov: number;
  85563. private _vignetteBlendMode;
  85564. /**
  85565. * Gets the vignette blend mode allowing different kind of effect.
  85566. */
  85567. /**
  85568. * Sets the vignette blend mode allowing different kind of effect.
  85569. */
  85570. vignetteBlendMode: number;
  85571. private _vignetteEnabled;
  85572. /**
  85573. * Gets wether the vignette effect is enabled.
  85574. */
  85575. /**
  85576. * Sets wether the vignette effect is enabled.
  85577. */
  85578. vignetteEnabled: boolean;
  85579. private _applyByPostProcess;
  85580. /**
  85581. * Gets wether the image processing is applied through a post process or not.
  85582. */
  85583. /**
  85584. * Sets wether the image processing is applied through a post process or not.
  85585. */
  85586. applyByPostProcess: boolean;
  85587. private _isEnabled;
  85588. /**
  85589. * Gets wether the image processing is enabled or not.
  85590. */
  85591. /**
  85592. * Sets wether the image processing is enabled or not.
  85593. */
  85594. isEnabled: boolean;
  85595. /**
  85596. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85597. */
  85598. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85599. /**
  85600. * Method called each time the image processing information changes requires to recompile the effect.
  85601. */
  85602. protected _updateParameters(): void;
  85603. /**
  85604. * Gets the current class name.
  85605. * @return "ImageProcessingConfiguration"
  85606. */
  85607. getClassName(): string;
  85608. /**
  85609. * Prepare the list of uniforms associated with the Image Processing effects.
  85610. * @param uniforms The list of uniforms used in the effect
  85611. * @param defines the list of defines currently in use
  85612. */
  85613. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85614. /**
  85615. * Prepare the list of samplers associated with the Image Processing effects.
  85616. * @param samplersList The list of uniforms used in the effect
  85617. * @param defines the list of defines currently in use
  85618. */
  85619. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85620. /**
  85621. * Prepare the list of defines associated to the shader.
  85622. * @param defines the list of defines to complete
  85623. * @param forPostProcess Define if we are currently in post process mode or not
  85624. */
  85625. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85626. /**
  85627. * Returns true if all the image processing information are ready.
  85628. * @returns True if ready, otherwise, false
  85629. */
  85630. isReady(): boolean;
  85631. /**
  85632. * Binds the image processing to the shader.
  85633. * @param effect The effect to bind to
  85634. * @param aspectRatio Define the current aspect ratio of the effect
  85635. */
  85636. bind(effect: Effect, aspectRatio?: number): void;
  85637. /**
  85638. * Clones the current image processing instance.
  85639. * @return The cloned image processing
  85640. */
  85641. clone(): ImageProcessingConfiguration;
  85642. /**
  85643. * Serializes the current image processing instance to a json representation.
  85644. * @return a JSON representation
  85645. */
  85646. serialize(): any;
  85647. /**
  85648. * Parses the image processing from a json representation.
  85649. * @param source the JSON source to parse
  85650. * @return The parsed image processing
  85651. */
  85652. static Parse(source: any): ImageProcessingConfiguration;
  85653. private static _VIGNETTEMODE_MULTIPLY;
  85654. private static _VIGNETTEMODE_OPAQUE;
  85655. /**
  85656. * Used to apply the vignette as a mix with the pixel color.
  85657. */
  85658. static readonly VIGNETTEMODE_MULTIPLY: number;
  85659. /**
  85660. * Used to apply the vignette as a replacement of the pixel color.
  85661. */
  85662. static readonly VIGNETTEMODE_OPAQUE: number;
  85663. }
  85664. }
  85665. declare module BABYLON {
  85666. /**
  85667. * This represents all the required information to add a fresnel effect on a material:
  85668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  85669. */
  85670. export class FresnelParameters {
  85671. private _isEnabled;
  85672. /**
  85673. * Define if the fresnel effect is enable or not.
  85674. */
  85675. isEnabled: boolean;
  85676. /**
  85677. * Define the color used on edges (grazing angle)
  85678. */
  85679. leftColor: Color3;
  85680. /**
  85681. * Define the color used on center
  85682. */
  85683. rightColor: Color3;
  85684. /**
  85685. * Define bias applied to computed fresnel term
  85686. */
  85687. bias: number;
  85688. /**
  85689. * Defined the power exponent applied to fresnel term
  85690. */
  85691. power: number;
  85692. /**
  85693. * Clones the current fresnel and its valuues
  85694. * @returns a clone fresnel configuration
  85695. */
  85696. clone(): FresnelParameters;
  85697. /**
  85698. * Serializes the current fresnel parameters to a JSON representation.
  85699. * @return the JSON serialization
  85700. */
  85701. serialize(): any;
  85702. /**
  85703. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  85704. * @param parsedFresnelParameters Define the JSON representation
  85705. * @returns the parsed parameters
  85706. */
  85707. static Parse(parsedFresnelParameters: any): FresnelParameters;
  85708. }
  85709. }
  85710. declare module BABYLON {
  85711. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  85712. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85713. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85714. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85715. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85716. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85717. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85718. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85719. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85720. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85721. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85722. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85723. /**
  85724. * Decorator used to define property that can be serialized as reference to a camera
  85725. * @param sourceName defines the name of the property to decorate
  85726. */
  85727. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85728. /**
  85729. * Class used to help serialization objects
  85730. */
  85731. export class SerializationHelper {
  85732. /** hidden */
  85733. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  85734. /** hidden */
  85735. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  85736. /** hidden */
  85737. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  85738. /** hidden */
  85739. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  85740. /**
  85741. * Appends the serialized animations from the source animations
  85742. * @param source Source containing the animations
  85743. * @param destination Target to store the animations
  85744. */
  85745. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85746. /**
  85747. * Static function used to serialized a specific entity
  85748. * @param entity defines the entity to serialize
  85749. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  85750. * @returns a JSON compatible object representing the serialization of the entity
  85751. */
  85752. static Serialize<T>(entity: T, serializationObject?: any): any;
  85753. /**
  85754. * Creates a new entity from a serialization data object
  85755. * @param creationFunction defines a function used to instanciated the new entity
  85756. * @param source defines the source serialization data
  85757. * @param scene defines the hosting scene
  85758. * @param rootUrl defines the root url for resources
  85759. * @returns a new entity
  85760. */
  85761. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  85762. /**
  85763. * Clones an object
  85764. * @param creationFunction defines the function used to instanciate the new object
  85765. * @param source defines the source object
  85766. * @returns the cloned object
  85767. */
  85768. static Clone<T>(creationFunction: () => T, source: T): T;
  85769. /**
  85770. * Instanciates a new object based on a source one (some data will be shared between both object)
  85771. * @param creationFunction defines the function used to instanciate the new object
  85772. * @param source defines the source object
  85773. * @returns the new object
  85774. */
  85775. static Instanciate<T>(creationFunction: () => T, source: T): T;
  85776. }
  85777. }
  85778. declare module BABYLON {
  85779. /**
  85780. * This is the base class of all the camera used in the application.
  85781. * @see http://doc.babylonjs.com/features/cameras
  85782. */
  85783. export class Camera extends Node {
  85784. /** @hidden */
  85785. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  85786. /**
  85787. * This is the default projection mode used by the cameras.
  85788. * It helps recreating a feeling of perspective and better appreciate depth.
  85789. * This is the best way to simulate real life cameras.
  85790. */
  85791. static readonly PERSPECTIVE_CAMERA: number;
  85792. /**
  85793. * This helps creating camera with an orthographic mode.
  85794. * 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.
  85795. */
  85796. static readonly ORTHOGRAPHIC_CAMERA: number;
  85797. /**
  85798. * This is the default FOV mode for perspective cameras.
  85799. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  85800. */
  85801. static readonly FOVMODE_VERTICAL_FIXED: number;
  85802. /**
  85803. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  85804. */
  85805. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  85806. /**
  85807. * This specifies ther is no need for a camera rig.
  85808. * Basically only one eye is rendered corresponding to the camera.
  85809. */
  85810. static readonly RIG_MODE_NONE: number;
  85811. /**
  85812. * Simulates a camera Rig with one blue eye and one red eye.
  85813. * This can be use with 3d blue and red glasses.
  85814. */
  85815. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  85816. /**
  85817. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  85818. */
  85819. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  85820. /**
  85821. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  85822. */
  85823. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  85824. /**
  85825. * Defines that both eyes of the camera will be rendered over under each other.
  85826. */
  85827. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  85828. /**
  85829. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  85830. */
  85831. static readonly RIG_MODE_VR: number;
  85832. /**
  85833. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  85834. */
  85835. static readonly RIG_MODE_WEBVR: number;
  85836. /**
  85837. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  85838. */
  85839. static readonly RIG_MODE_CUSTOM: number;
  85840. /**
  85841. * Defines if by default attaching controls should prevent the default javascript event to continue.
  85842. */
  85843. static ForceAttachControlToAlwaysPreventDefault: boolean;
  85844. /**
  85845. * @hidden
  85846. * Might be removed once multiview will be a thing
  85847. */
  85848. static UseAlternateWebVRRendering: boolean;
  85849. /**
  85850. * Define the input manager associated with the camera.
  85851. */
  85852. inputs: CameraInputsManager<Camera>;
  85853. /**
  85854. * Define the current local position of the camera in the scene
  85855. */
  85856. position: Vector3;
  85857. /**
  85858. * The vector the camera should consider as up.
  85859. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  85860. */
  85861. upVector: Vector3;
  85862. /**
  85863. * Define the current limit on the left side for an orthographic camera
  85864. * In scene unit
  85865. */
  85866. orthoLeft: Nullable<number>;
  85867. /**
  85868. * Define the current limit on the right side for an orthographic camera
  85869. * In scene unit
  85870. */
  85871. orthoRight: Nullable<number>;
  85872. /**
  85873. * Define the current limit on the bottom side for an orthographic camera
  85874. * In scene unit
  85875. */
  85876. orthoBottom: Nullable<number>;
  85877. /**
  85878. * Define the current limit on the top side for an orthographic camera
  85879. * In scene unit
  85880. */
  85881. orthoTop: Nullable<number>;
  85882. /**
  85883. * Field Of View is set in Radians. (default is 0.8)
  85884. */
  85885. fov: number;
  85886. /**
  85887. * Define the minimum distance the camera can see from.
  85888. * This is important to note that the depth buffer are not infinite and the closer it starts
  85889. * the more your scene might encounter depth fighting issue.
  85890. */
  85891. minZ: number;
  85892. /**
  85893. * Define the maximum distance the camera can see to.
  85894. * This is important to note that the depth buffer are not infinite and the further it end
  85895. * the more your scene might encounter depth fighting issue.
  85896. */
  85897. maxZ: number;
  85898. /**
  85899. * Define the default inertia of the camera.
  85900. * This helps giving a smooth feeling to the camera movement.
  85901. */
  85902. inertia: number;
  85903. /**
  85904. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  85905. */
  85906. mode: number;
  85907. /**
  85908. * Define wether the camera is intermediate.
  85909. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  85910. */
  85911. isIntermediate: boolean;
  85912. /**
  85913. * Define the viewport of the camera.
  85914. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  85915. */
  85916. viewport: Viewport;
  85917. /**
  85918. * Restricts the camera to viewing objects with the same layerMask.
  85919. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  85920. */
  85921. layerMask: number;
  85922. /**
  85923. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  85924. */
  85925. fovMode: number;
  85926. /**
  85927. * Rig mode of the camera.
  85928. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  85929. * This is normally controlled byt the camera themselves as internal use.
  85930. */
  85931. cameraRigMode: number;
  85932. /**
  85933. * Defines the distance between both "eyes" in case of a RIG
  85934. */
  85935. interaxialDistance: number;
  85936. /**
  85937. * Defines if stereoscopic rendering is done side by side or over under.
  85938. */
  85939. isStereoscopicSideBySide: boolean;
  85940. /**
  85941. * 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
  85942. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  85943. * else in the scene.
  85944. */
  85945. customRenderTargets: RenderTargetTexture[];
  85946. /**
  85947. * When set, the camera will render to this render target instead of the default canvas
  85948. */
  85949. outputRenderTarget: Nullable<RenderTargetTexture>;
  85950. /**
  85951. * Observable triggered when the camera view matrix has changed.
  85952. */
  85953. onViewMatrixChangedObservable: Observable<Camera>;
  85954. /**
  85955. * Observable triggered when the camera Projection matrix has changed.
  85956. */
  85957. onProjectionMatrixChangedObservable: Observable<Camera>;
  85958. /**
  85959. * Observable triggered when the inputs have been processed.
  85960. */
  85961. onAfterCheckInputsObservable: Observable<Camera>;
  85962. /**
  85963. * Observable triggered when reset has been called and applied to the camera.
  85964. */
  85965. onRestoreStateObservable: Observable<Camera>;
  85966. /** @hidden */
  85967. _cameraRigParams: any;
  85968. /** @hidden */
  85969. _rigCameras: Camera[];
  85970. /** @hidden */
  85971. _rigPostProcess: Nullable<PostProcess>;
  85972. protected _webvrViewMatrix: Matrix;
  85973. /** @hidden */
  85974. _skipRendering: boolean;
  85975. /** @hidden */
  85976. _alternateCamera: Camera;
  85977. /** @hidden */
  85978. _projectionMatrix: Matrix;
  85979. /** @hidden */
  85980. _postProcesses: Nullable<PostProcess>[];
  85981. /** @hidden */
  85982. _activeMeshes: SmartArray<AbstractMesh>;
  85983. protected _globalPosition: Vector3;
  85984. /** hidden */
  85985. _computedViewMatrix: Matrix;
  85986. private _doNotComputeProjectionMatrix;
  85987. private _transformMatrix;
  85988. private _frustumPlanes;
  85989. private _refreshFrustumPlanes;
  85990. private _storedFov;
  85991. private _stateStored;
  85992. /**
  85993. * Instantiates a new camera object.
  85994. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  85995. * @see http://doc.babylonjs.com/features/cameras
  85996. * @param name Defines the name of the camera in the scene
  85997. * @param position Defines the position of the camera
  85998. * @param scene Defines the scene the camera belongs too
  85999. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  86000. */
  86001. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  86002. /**
  86003. * Store current camera state (fov, position, etc..)
  86004. * @returns the camera
  86005. */
  86006. storeState(): Camera;
  86007. /**
  86008. * Restores the camera state values if it has been stored. You must call storeState() first
  86009. */
  86010. protected _restoreStateValues(): boolean;
  86011. /**
  86012. * Restored camera state. You must call storeState() first.
  86013. * @returns true if restored and false otherwise
  86014. */
  86015. restoreState(): boolean;
  86016. /**
  86017. * Gets the class name of the camera.
  86018. * @returns the class name
  86019. */
  86020. getClassName(): string;
  86021. /** @hidden */
  86022. readonly _isCamera: boolean;
  86023. /**
  86024. * Gets a string representation of the camera useful for debug purpose.
  86025. * @param fullDetails Defines that a more verboe level of logging is required
  86026. * @returns the string representation
  86027. */
  86028. toString(fullDetails?: boolean): string;
  86029. /**
  86030. * Gets the current world space position of the camera.
  86031. */
  86032. readonly globalPosition: Vector3;
  86033. /**
  86034. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  86035. * @returns the active meshe list
  86036. */
  86037. getActiveMeshes(): SmartArray<AbstractMesh>;
  86038. /**
  86039. * Check wether a mesh is part of the current active mesh list of the camera
  86040. * @param mesh Defines the mesh to check
  86041. * @returns true if active, false otherwise
  86042. */
  86043. isActiveMesh(mesh: Mesh): boolean;
  86044. /**
  86045. * Is this camera ready to be used/rendered
  86046. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86047. * @return true if the camera is ready
  86048. */
  86049. isReady(completeCheck?: boolean): boolean;
  86050. /** @hidden */
  86051. _initCache(): void;
  86052. /** @hidden */
  86053. _updateCache(ignoreParentClass?: boolean): void;
  86054. /** @hidden */
  86055. _isSynchronized(): boolean;
  86056. /** @hidden */
  86057. _isSynchronizedViewMatrix(): boolean;
  86058. /** @hidden */
  86059. _isSynchronizedProjectionMatrix(): boolean;
  86060. /**
  86061. * Attach the input controls to a specific dom element to get the input from.
  86062. * @param element Defines the element the controls should be listened from
  86063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86064. */
  86065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86066. /**
  86067. * Detach the current controls from the specified dom element.
  86068. * @param element Defines the element to stop listening the inputs from
  86069. */
  86070. detachControl(element: HTMLElement): void;
  86071. /**
  86072. * Update the camera state according to the different inputs gathered during the frame.
  86073. */
  86074. update(): void;
  86075. /** @hidden */
  86076. _checkInputs(): void;
  86077. /** @hidden */
  86078. readonly rigCameras: Camera[];
  86079. /**
  86080. * Gets the post process used by the rig cameras
  86081. */
  86082. readonly rigPostProcess: Nullable<PostProcess>;
  86083. /**
  86084. * Internal, gets the first post proces.
  86085. * @returns the first post process to be run on this camera.
  86086. */
  86087. _getFirstPostProcess(): Nullable<PostProcess>;
  86088. private _cascadePostProcessesToRigCams;
  86089. /**
  86090. * Attach a post process to the camera.
  86091. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86092. * @param postProcess The post process to attach to the camera
  86093. * @param insertAt The position of the post process in case several of them are in use in the scene
  86094. * @returns the position the post process has been inserted at
  86095. */
  86096. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86097. /**
  86098. * Detach a post process to the camera.
  86099. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86100. * @param postProcess The post process to detach from the camera
  86101. */
  86102. detachPostProcess(postProcess: PostProcess): void;
  86103. /**
  86104. * Gets the current world matrix of the camera
  86105. */
  86106. getWorldMatrix(): Matrix;
  86107. /** @hidden */
  86108. _getViewMatrix(): Matrix;
  86109. /**
  86110. * Gets the current view matrix of the camera.
  86111. * @param force forces the camera to recompute the matrix without looking at the cached state
  86112. * @returns the view matrix
  86113. */
  86114. getViewMatrix(force?: boolean): Matrix;
  86115. /**
  86116. * Freeze the projection matrix.
  86117. * It will prevent the cache check of the camera projection compute and can speed up perf
  86118. * if no parameter of the camera are meant to change
  86119. * @param projection Defines manually a projection if necessary
  86120. */
  86121. freezeProjectionMatrix(projection?: Matrix): void;
  86122. /**
  86123. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86124. */
  86125. unfreezeProjectionMatrix(): void;
  86126. /**
  86127. * Gets the current projection matrix of the camera.
  86128. * @param force forces the camera to recompute the matrix without looking at the cached state
  86129. * @returns the projection matrix
  86130. */
  86131. getProjectionMatrix(force?: boolean): Matrix;
  86132. /**
  86133. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86134. * @returns a Matrix
  86135. */
  86136. getTransformationMatrix(): Matrix;
  86137. private _updateFrustumPlanes;
  86138. /**
  86139. * Checks if a cullable object (mesh...) is in the camera frustum
  86140. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86141. * @param target The object to check
  86142. * @returns true if the object is in frustum otherwise false
  86143. */
  86144. isInFrustum(target: ICullable): boolean;
  86145. /**
  86146. * Checks if a cullable object (mesh...) is in the camera frustum
  86147. * Unlike isInFrustum this cheks the full bounding box
  86148. * @param target The object to check
  86149. * @returns true if the object is in frustum otherwise false
  86150. */
  86151. isCompletelyInFrustum(target: ICullable): boolean;
  86152. /**
  86153. * Gets a ray in the forward direction from the camera.
  86154. * @param length Defines the length of the ray to create
  86155. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86156. * @param origin Defines the start point of the ray which defaults to the camera position
  86157. * @returns the forward ray
  86158. */
  86159. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86160. /**
  86161. * Releases resources associated with this node.
  86162. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86163. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86164. */
  86165. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86166. /**
  86167. * Gets the left camera of a rig setup in case of Rigged Camera
  86168. */
  86169. readonly leftCamera: Nullable<FreeCamera>;
  86170. /**
  86171. * Gets the right camera of a rig setup in case of Rigged Camera
  86172. */
  86173. readonly rightCamera: Nullable<FreeCamera>;
  86174. /**
  86175. * Gets the left camera target of a rig setup in case of Rigged Camera
  86176. * @returns the target position
  86177. */
  86178. getLeftTarget(): Nullable<Vector3>;
  86179. /**
  86180. * Gets the right camera target of a rig setup in case of Rigged Camera
  86181. * @returns the target position
  86182. */
  86183. getRightTarget(): Nullable<Vector3>;
  86184. /**
  86185. * @hidden
  86186. */
  86187. setCameraRigMode(mode: number, rigParams: any): void;
  86188. /** @hidden */
  86189. static _setStereoscopicRigMode(camera: Camera): void;
  86190. /** @hidden */
  86191. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86192. /** @hidden */
  86193. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86194. /** @hidden */
  86195. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86196. /** @hidden */
  86197. _getVRProjectionMatrix(): Matrix;
  86198. protected _updateCameraRotationMatrix(): void;
  86199. protected _updateWebVRCameraRotationMatrix(): void;
  86200. /**
  86201. * This function MUST be overwritten by the different WebVR cameras available.
  86202. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86203. * @hidden
  86204. */
  86205. _getWebVRProjectionMatrix(): Matrix;
  86206. /**
  86207. * This function MUST be overwritten by the different WebVR cameras available.
  86208. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86209. * @hidden
  86210. */
  86211. _getWebVRViewMatrix(): Matrix;
  86212. /** @hidden */
  86213. setCameraRigParameter(name: string, value: any): void;
  86214. /**
  86215. * needs to be overridden by children so sub has required properties to be copied
  86216. * @hidden
  86217. */
  86218. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86219. /**
  86220. * May need to be overridden by children
  86221. * @hidden
  86222. */
  86223. _updateRigCameras(): void;
  86224. /** @hidden */
  86225. _setupInputs(): void;
  86226. /**
  86227. * Serialiaze the camera setup to a json represention
  86228. * @returns the JSON representation
  86229. */
  86230. serialize(): any;
  86231. /**
  86232. * Clones the current camera.
  86233. * @param name The cloned camera name
  86234. * @returns the cloned camera
  86235. */
  86236. clone(name: string): Camera;
  86237. /**
  86238. * Gets the direction of the camera relative to a given local axis.
  86239. * @param localAxis Defines the reference axis to provide a relative direction.
  86240. * @return the direction
  86241. */
  86242. getDirection(localAxis: Vector3): Vector3;
  86243. /**
  86244. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86245. * @param localAxis Defines the reference axis to provide a relative direction.
  86246. * @param result Defines the vector to store the result in
  86247. */
  86248. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86249. /**
  86250. * Gets a camera constructor for a given camera type
  86251. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86252. * @param name The name of the camera the result will be able to instantiate
  86253. * @param scene The scene the result will construct the camera in
  86254. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86255. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86256. * @returns a factory method to construc the camera
  86257. */
  86258. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86259. /**
  86260. * Compute the world matrix of the camera.
  86261. * @returns the camera workd matrix
  86262. */
  86263. computeWorldMatrix(): Matrix;
  86264. /**
  86265. * Parse a JSON and creates the camera from the parsed information
  86266. * @param parsedCamera The JSON to parse
  86267. * @param scene The scene to instantiate the camera in
  86268. * @returns the newly constructed camera
  86269. */
  86270. static Parse(parsedCamera: any, scene: Scene): Camera;
  86271. }
  86272. }
  86273. declare module BABYLON {
  86274. /**
  86275. * Interface for any object that can request an animation frame
  86276. */
  86277. export interface ICustomAnimationFrameRequester {
  86278. /**
  86279. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86280. */
  86281. renderFunction?: Function;
  86282. /**
  86283. * Called to request the next frame to render to
  86284. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86285. */
  86286. requestAnimationFrame: Function;
  86287. /**
  86288. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86289. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86290. */
  86291. requestID?: number;
  86292. }
  86293. /**
  86294. * Interface containing an array of animations
  86295. */
  86296. export interface IAnimatable {
  86297. /**
  86298. * Array of animations
  86299. */
  86300. animations: Array<Animation>;
  86301. }
  86302. /** Interface used by value gradients (color, factor, ...) */
  86303. export interface IValueGradient {
  86304. /**
  86305. * Gets or sets the gradient value (between 0 and 1)
  86306. */
  86307. gradient: number;
  86308. }
  86309. /** Class used to store color4 gradient */
  86310. export class ColorGradient implements IValueGradient {
  86311. /**
  86312. * Gets or sets the gradient value (between 0 and 1)
  86313. */
  86314. gradient: number;
  86315. /**
  86316. * Gets or sets first associated color
  86317. */
  86318. color1: Color4;
  86319. /**
  86320. * Gets or sets second associated color
  86321. */
  86322. color2?: Color4;
  86323. /**
  86324. * Will get a color picked randomly between color1 and color2.
  86325. * If color2 is undefined then color1 will be used
  86326. * @param result defines the target Color4 to store the result in
  86327. */
  86328. getColorToRef(result: Color4): void;
  86329. }
  86330. /** Class used to store color 3 gradient */
  86331. export class Color3Gradient implements IValueGradient {
  86332. /**
  86333. * Gets or sets the gradient value (between 0 and 1)
  86334. */
  86335. gradient: number;
  86336. /**
  86337. * Gets or sets the associated color
  86338. */
  86339. color: Color3;
  86340. }
  86341. /** Class used to store factor gradient */
  86342. export class FactorGradient implements IValueGradient {
  86343. /**
  86344. * Gets or sets the gradient value (between 0 and 1)
  86345. */
  86346. gradient: number;
  86347. /**
  86348. * Gets or sets first associated factor
  86349. */
  86350. factor1: number;
  86351. /**
  86352. * Gets or sets second associated factor
  86353. */
  86354. factor2?: number;
  86355. /**
  86356. * Will get a number picked randomly between factor1 and factor2.
  86357. * If factor2 is undefined then factor1 will be used
  86358. * @returns the picked number
  86359. */
  86360. getFactor(): number;
  86361. }
  86362. /**
  86363. * @ignore
  86364. * Application error to support additional information when loading a file
  86365. */
  86366. export class LoadFileError extends Error {
  86367. /** defines the optional XHR request */
  86368. request?: XMLHttpRequest | undefined;
  86369. private static _setPrototypeOf;
  86370. /**
  86371. * Creates a new LoadFileError
  86372. * @param message defines the message of the error
  86373. * @param request defines the optional XHR request
  86374. */
  86375. constructor(message: string,
  86376. /** defines the optional XHR request */
  86377. request?: XMLHttpRequest | undefined);
  86378. }
  86379. /**
  86380. * Class used to define a retry strategy when error happens while loading assets
  86381. */
  86382. export class RetryStrategy {
  86383. /**
  86384. * Function used to defines an exponential back off strategy
  86385. * @param maxRetries defines the maximum number of retries (3 by default)
  86386. * @param baseInterval defines the interval between retries
  86387. * @returns the strategy function to use
  86388. */
  86389. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86390. }
  86391. /**
  86392. * File request interface
  86393. */
  86394. export interface IFileRequest {
  86395. /**
  86396. * Raised when the request is complete (success or error).
  86397. */
  86398. onCompleteObservable: Observable<IFileRequest>;
  86399. /**
  86400. * Aborts the request for a file.
  86401. */
  86402. abort: () => void;
  86403. }
  86404. /**
  86405. * Class containing a set of static utilities functions
  86406. */
  86407. export class Tools {
  86408. /**
  86409. * Gets or sets the base URL to use to load assets
  86410. */
  86411. static BaseUrl: string;
  86412. /**
  86413. * Enable/Disable Custom HTTP Request Headers globally.
  86414. * default = false
  86415. * @see CustomRequestHeaders
  86416. */
  86417. static UseCustomRequestHeaders: boolean;
  86418. /**
  86419. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86420. * i.e. when loading files, where the server/service expects an Authorization header.
  86421. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86422. */
  86423. static CustomRequestHeaders: {
  86424. [key: string]: string;
  86425. };
  86426. /**
  86427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86428. */
  86429. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86430. /**
  86431. * Default behaviour for cors in the application.
  86432. * It can be a string if the expected behavior is identical in the entire app.
  86433. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86434. */
  86435. static CorsBehavior: string | ((url: string | string[]) => string);
  86436. /**
  86437. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86438. * @ignorenaming
  86439. */
  86440. static UseFallbackTexture: boolean;
  86441. /**
  86442. * Use this object to register external classes like custom textures or material
  86443. * to allow the laoders to instantiate them
  86444. */
  86445. static RegisteredExternalClasses: {
  86446. [key: string]: Object;
  86447. };
  86448. /**
  86449. * Texture content used if a texture cannot loaded
  86450. * @ignorenaming
  86451. */
  86452. static fallbackTexture: string;
  86453. /**
  86454. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86455. * @param u defines the coordinate on X axis
  86456. * @param v defines the coordinate on Y axis
  86457. * @param width defines the width of the source data
  86458. * @param height defines the height of the source data
  86459. * @param pixels defines the source byte array
  86460. * @param color defines the output color
  86461. */
  86462. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86463. /**
  86464. * Interpolates between a and b via alpha
  86465. * @param a The lower value (returned when alpha = 0)
  86466. * @param b The upper value (returned when alpha = 1)
  86467. * @param alpha The interpolation-factor
  86468. * @return The mixed value
  86469. */
  86470. static Mix(a: number, b: number, alpha: number): number;
  86471. /**
  86472. * Tries to instantiate a new object from a given class name
  86473. * @param className defines the class name to instantiate
  86474. * @returns the new object or null if the system was not able to do the instantiation
  86475. */
  86476. static Instantiate(className: string): any;
  86477. /**
  86478. * Provides a slice function that will work even on IE
  86479. * @param data defines the array to slice
  86480. * @param start defines the start of the data (optional)
  86481. * @param end defines the end of the data (optional)
  86482. * @returns the new sliced array
  86483. */
  86484. static Slice<T>(data: T, start?: number, end?: number): T;
  86485. /**
  86486. * Polyfill for setImmediate
  86487. * @param action defines the action to execute after the current execution block
  86488. */
  86489. static SetImmediate(action: () => void): void;
  86490. /**
  86491. * Function indicating if a number is an exponent of 2
  86492. * @param value defines the value to test
  86493. * @returns true if the value is an exponent of 2
  86494. */
  86495. static IsExponentOfTwo(value: number): boolean;
  86496. private static _tmpFloatArray;
  86497. /**
  86498. * Returns the nearest 32-bit single precision float representation of a Number
  86499. * @param value A Number. If the parameter is of a different type, it will get converted
  86500. * to a number or to NaN if it cannot be converted
  86501. * @returns number
  86502. */
  86503. static FloatRound(value: number): number;
  86504. /**
  86505. * Find the next highest power of two.
  86506. * @param x Number to start search from.
  86507. * @return Next highest power of two.
  86508. */
  86509. static CeilingPOT(x: number): number;
  86510. /**
  86511. * Find the next lowest power of two.
  86512. * @param x Number to start search from.
  86513. * @return Next lowest power of two.
  86514. */
  86515. static FloorPOT(x: number): number;
  86516. /**
  86517. * Find the nearest power of two.
  86518. * @param x Number to start search from.
  86519. * @return Next nearest power of two.
  86520. */
  86521. static NearestPOT(x: number): number;
  86522. /**
  86523. * Get the closest exponent of two
  86524. * @param value defines the value to approximate
  86525. * @param max defines the maximum value to return
  86526. * @param mode defines how to define the closest value
  86527. * @returns closest exponent of two of the given value
  86528. */
  86529. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86530. /**
  86531. * Extracts the filename from a path
  86532. * @param path defines the path to use
  86533. * @returns the filename
  86534. */
  86535. static GetFilename(path: string): string;
  86536. /**
  86537. * Extracts the "folder" part of a path (everything before the filename).
  86538. * @param uri The URI to extract the info from
  86539. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  86540. * @returns The "folder" part of the path
  86541. */
  86542. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  86543. /**
  86544. * Extracts text content from a DOM element hierarchy
  86545. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  86546. */
  86547. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  86548. /**
  86549. * Convert an angle in radians to degrees
  86550. * @param angle defines the angle to convert
  86551. * @returns the angle in degrees
  86552. */
  86553. static ToDegrees(angle: number): number;
  86554. /**
  86555. * Convert an angle in degrees to radians
  86556. * @param angle defines the angle to convert
  86557. * @returns the angle in radians
  86558. */
  86559. static ToRadians(angle: number): number;
  86560. /**
  86561. * Encode a buffer to a base64 string
  86562. * @param buffer defines the buffer to encode
  86563. * @returns the encoded string
  86564. */
  86565. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  86566. /**
  86567. * Extracts minimum and maximum values from a list of indexed positions
  86568. * @param positions defines the positions to use
  86569. * @param indices defines the indices to the positions
  86570. * @param indexStart defines the start index
  86571. * @param indexCount defines the end index
  86572. * @param bias defines bias value to add to the result
  86573. * @return minimum and maximum values
  86574. */
  86575. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86576. minimum: Vector3;
  86577. maximum: Vector3;
  86578. };
  86579. /**
  86580. * Extracts minimum and maximum values from a list of positions
  86581. * @param positions defines the positions to use
  86582. * @param start defines the start index in the positions array
  86583. * @param count defines the number of positions to handle
  86584. * @param bias defines bias value to add to the result
  86585. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86586. * @return minimum and maximum values
  86587. */
  86588. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86589. minimum: Vector3;
  86590. maximum: Vector3;
  86591. };
  86592. /**
  86593. * Returns an array if obj is not an array
  86594. * @param obj defines the object to evaluate as an array
  86595. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  86596. * @returns either obj directly if obj is an array or a new array containing obj
  86597. */
  86598. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  86599. /**
  86600. * Gets the pointer prefix to use
  86601. * @returns "pointer" if touch is enabled. Else returns "mouse"
  86602. */
  86603. static GetPointerPrefix(): string;
  86604. /**
  86605. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  86606. * @param func - the function to be called
  86607. * @param requester - the object that will request the next frame. Falls back to window.
  86608. * @returns frame number
  86609. */
  86610. static QueueNewFrame(func: () => void, requester?: any): number;
  86611. /**
  86612. * Ask the browser to promote the current element to fullscreen rendering mode
  86613. * @param element defines the DOM element to promote
  86614. */
  86615. static RequestFullscreen(element: HTMLElement): void;
  86616. /**
  86617. * Asks the browser to exit fullscreen mode
  86618. */
  86619. static ExitFullscreen(): void;
  86620. /**
  86621. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86622. * @param url define the url we are trying
  86623. * @param element define the dom element where to configure the cors policy
  86624. */
  86625. static SetCorsBehavior(url: string | string[], element: {
  86626. crossOrigin: string | null;
  86627. }): void;
  86628. /**
  86629. * Removes unwanted characters from an url
  86630. * @param url defines the url to clean
  86631. * @returns the cleaned url
  86632. */
  86633. static CleanUrl(url: string): string;
  86634. /**
  86635. * Gets or sets a function used to pre-process url before using them to load assets
  86636. */
  86637. static PreprocessUrl: (url: string) => string;
  86638. /**
  86639. * Loads an image as an HTMLImageElement.
  86640. * @param input url string, ArrayBuffer, or Blob to load
  86641. * @param onLoad callback called when the image successfully loads
  86642. * @param onError callback called when the image fails to load
  86643. * @param offlineProvider offline provider for caching
  86644. * @returns the HTMLImageElement of the loaded image
  86645. */
  86646. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  86647. /**
  86648. * Loads a file
  86649. * @param url url string, ArrayBuffer, or Blob to load
  86650. * @param onSuccess callback called when the file successfully loads
  86651. * @param onProgress callback called while file is loading (if the server supports this mode)
  86652. * @param offlineProvider defines the offline provider for caching
  86653. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86654. * @param onError callback called when the file fails to load
  86655. * @returns a file request object
  86656. */
  86657. 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;
  86658. /**
  86659. * Load a script (identified by an url). When the url returns, the
  86660. * content of this file is added into a new script element, attached to the DOM (body element)
  86661. * @param scriptUrl defines the url of the script to laod
  86662. * @param onSuccess defines the callback called when the script is loaded
  86663. * @param onError defines the callback to call if an error occurs
  86664. */
  86665. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  86666. /**
  86667. * Loads a file from a blob
  86668. * @param fileToLoad defines the blob to use
  86669. * @param callback defines the callback to call when data is loaded
  86670. * @param progressCallback defines the callback to call during loading process
  86671. * @returns a file request object
  86672. */
  86673. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  86674. /**
  86675. * Loads a file
  86676. * @param fileToLoad defines the file to load
  86677. * @param callback defines the callback to call when data is loaded
  86678. * @param progressCallBack defines the callback to call during loading process
  86679. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86680. * @returns a file request object
  86681. */
  86682. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  86683. /**
  86684. * Creates a data url from a given string content
  86685. * @param content defines the content to convert
  86686. * @returns the new data url link
  86687. */
  86688. static FileAsURL(content: string): string;
  86689. /**
  86690. * Format the given number to a specific decimal format
  86691. * @param value defines the number to format
  86692. * @param decimals defines the number of decimals to use
  86693. * @returns the formatted string
  86694. */
  86695. static Format(value: number, decimals?: number): string;
  86696. /**
  86697. * Checks if a given vector is inside a specific range
  86698. * @param v defines the vector to test
  86699. * @param min defines the minimum range
  86700. * @param max defines the maximum range
  86701. */
  86702. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  86703. /**
  86704. * Tries to copy an object by duplicating every property
  86705. * @param source defines the source object
  86706. * @param destination defines the target object
  86707. * @param doNotCopyList defines a list of properties to avoid
  86708. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  86709. */
  86710. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  86711. /**
  86712. * Gets a boolean indicating if the given object has no own property
  86713. * @param obj defines the object to test
  86714. * @returns true if object has no own property
  86715. */
  86716. static IsEmpty(obj: any): boolean;
  86717. /**
  86718. * Function used to register events at window level
  86719. * @param events defines the events to register
  86720. */
  86721. static RegisterTopRootEvents(events: {
  86722. name: string;
  86723. handler: Nullable<(e: FocusEvent) => any>;
  86724. }[]): void;
  86725. /**
  86726. * Function used to unregister events from window level
  86727. * @param events defines the events to unregister
  86728. */
  86729. static UnregisterTopRootEvents(events: {
  86730. name: string;
  86731. handler: Nullable<(e: FocusEvent) => any>;
  86732. }[]): void;
  86733. /**
  86734. * Dumps the current bound framebuffer
  86735. * @param width defines the rendering width
  86736. * @param height defines the rendering height
  86737. * @param engine defines the hosting engine
  86738. * @param successCallback defines the callback triggered once the data are available
  86739. * @param mimeType defines the mime type of the result
  86740. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  86741. */
  86742. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86743. /**
  86744. * Converts the canvas data to blob.
  86745. * This acts as a polyfill for browsers not supporting the to blob function.
  86746. * @param canvas Defines the canvas to extract the data from
  86747. * @param successCallback Defines the callback triggered once the data are available
  86748. * @param mimeType Defines the mime type of the result
  86749. */
  86750. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  86751. /**
  86752. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  86753. * @param successCallback defines the callback triggered once the data are available
  86754. * @param mimeType defines the mime type of the result
  86755. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  86756. */
  86757. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86758. /**
  86759. * Downloads a blob in the browser
  86760. * @param blob defines the blob to download
  86761. * @param fileName defines the name of the downloaded file
  86762. */
  86763. static Download(blob: Blob, fileName: string): void;
  86764. /**
  86765. * Captures a screenshot of the current rendering
  86766. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86767. * @param engine defines the rendering engine
  86768. * @param camera defines the source camera
  86769. * @param size This parameter can be set to a single number or to an object with the
  86770. * following (optional) properties: precision, width, height. If a single number is passed,
  86771. * it will be used for both width and height. If an object is passed, the screenshot size
  86772. * will be derived from the parameters. The precision property is a multiplier allowing
  86773. * rendering at a higher or lower resolution
  86774. * @param successCallback defines the callback receives a single parameter which contains the
  86775. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86776. * src parameter of an <img> to display it
  86777. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  86778. * Check your browser for supported MIME types
  86779. */
  86780. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  86781. /**
  86782. * Generates an image screenshot from the specified camera.
  86783. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86784. * @param engine The engine to use for rendering
  86785. * @param camera The camera to use for rendering
  86786. * @param size This parameter can be set to a single number or to an object with the
  86787. * following (optional) properties: precision, width, height. If a single number is passed,
  86788. * it will be used for both width and height. If an object is passed, the screenshot size
  86789. * will be derived from the parameters. The precision property is a multiplier allowing
  86790. * rendering at a higher or lower resolution
  86791. * @param successCallback The callback receives a single parameter which contains the
  86792. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86793. * src parameter of an <img> to display it
  86794. * @param mimeType The MIME type of the screenshot image (default: image/png).
  86795. * Check your browser for supported MIME types
  86796. * @param samples Texture samples (default: 1)
  86797. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  86798. * @param fileName A name for for the downloaded file.
  86799. */
  86800. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  86801. /**
  86802. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86803. * Be aware Math.random() could cause collisions, but:
  86804. * "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"
  86805. * @returns a pseudo random id
  86806. */
  86807. static RandomId(): string;
  86808. /**
  86809. * Test if the given uri is a base64 string
  86810. * @param uri The uri to test
  86811. * @return True if the uri is a base64 string or false otherwise
  86812. */
  86813. static IsBase64(uri: string): boolean;
  86814. /**
  86815. * Decode the given base64 uri.
  86816. * @param uri The uri to decode
  86817. * @return The decoded base64 data.
  86818. */
  86819. static DecodeBase64(uri: string): ArrayBuffer;
  86820. /**
  86821. * No log
  86822. */
  86823. static readonly NoneLogLevel: number;
  86824. /**
  86825. * Only message logs
  86826. */
  86827. static readonly MessageLogLevel: number;
  86828. /**
  86829. * Only warning logs
  86830. */
  86831. static readonly WarningLogLevel: number;
  86832. /**
  86833. * Only error logs
  86834. */
  86835. static readonly ErrorLogLevel: number;
  86836. /**
  86837. * All logs
  86838. */
  86839. static readonly AllLogLevel: number;
  86840. /**
  86841. * Gets a value indicating the number of loading errors
  86842. * @ignorenaming
  86843. */
  86844. static readonly errorsCount: number;
  86845. /**
  86846. * Callback called when a new log is added
  86847. */
  86848. static OnNewCacheEntry: (entry: string) => void;
  86849. /**
  86850. * Log a message to the console
  86851. * @param message defines the message to log
  86852. */
  86853. static Log(message: string): void;
  86854. /**
  86855. * Write a warning message to the console
  86856. * @param message defines the message to log
  86857. */
  86858. static Warn(message: string): void;
  86859. /**
  86860. * Write an error message to the console
  86861. * @param message defines the message to log
  86862. */
  86863. static Error(message: string): void;
  86864. /**
  86865. * Gets current log cache (list of logs)
  86866. */
  86867. static readonly LogCache: string;
  86868. /**
  86869. * Clears the log cache
  86870. */
  86871. static ClearLogCache(): void;
  86872. /**
  86873. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  86874. */
  86875. static LogLevels: number;
  86876. /**
  86877. * Checks if the loaded document was accessed via `file:`-Protocol.
  86878. * @returns boolean
  86879. */
  86880. static IsFileURL(): boolean;
  86881. /**
  86882. * Checks if the window object exists
  86883. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  86884. */
  86885. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  86886. /**
  86887. * No performance log
  86888. */
  86889. static readonly PerformanceNoneLogLevel: number;
  86890. /**
  86891. * Use user marks to log performance
  86892. */
  86893. static readonly PerformanceUserMarkLogLevel: number;
  86894. /**
  86895. * Log performance to the console
  86896. */
  86897. static readonly PerformanceConsoleLogLevel: number;
  86898. private static _performance;
  86899. /**
  86900. * Sets the current performance log level
  86901. */
  86902. static PerformanceLogLevel: number;
  86903. private static _StartPerformanceCounterDisabled;
  86904. private static _EndPerformanceCounterDisabled;
  86905. private static _StartUserMark;
  86906. private static _EndUserMark;
  86907. private static _StartPerformanceConsole;
  86908. private static _EndPerformanceConsole;
  86909. /**
  86910. * Injects the @see CustomRequestHeaders into the given request
  86911. * @param request the request that should be used for injection
  86912. */
  86913. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  86914. /**
  86915. * Starts a performance counter
  86916. */
  86917. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86918. /**
  86919. * Ends a specific performance coutner
  86920. */
  86921. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86922. /**
  86923. * Gets either window.performance.now() if supported or Date.now() else
  86924. */
  86925. static readonly Now: number;
  86926. /**
  86927. * This method will return the name of the class used to create the instance of the given object.
  86928. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  86929. * @param object the object to get the class name from
  86930. * @param isType defines if the object is actually a type
  86931. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  86932. */
  86933. static GetClassName(object: any, isType?: boolean): string;
  86934. /**
  86935. * Gets the first element of an array satisfying a given predicate
  86936. * @param array defines the array to browse
  86937. * @param predicate defines the predicate to use
  86938. * @returns null if not found or the element
  86939. */
  86940. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  86941. /**
  86942. * This method will return the name of the full name of the class, including its owning module (if any).
  86943. * 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).
  86944. * @param object the object to get the class name from
  86945. * @param isType defines if the object is actually a type
  86946. * @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.
  86947. * @ignorenaming
  86948. */
  86949. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  86950. /**
  86951. * Returns a promise that resolves after the given amount of time.
  86952. * @param delay Number of milliseconds to delay
  86953. * @returns Promise that resolves after the given amount of time
  86954. */
  86955. static DelayAsync(delay: number): Promise<void>;
  86956. /**
  86957. * Gets the current gradient from an array of IValueGradient
  86958. * @param ratio defines the current ratio to get
  86959. * @param gradients defines the array of IValueGradient
  86960. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86961. */
  86962. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86963. }
  86964. /**
  86965. * This class is used to track a performance counter which is number based.
  86966. * The user has access to many properties which give statistics of different nature.
  86967. *
  86968. * The implementer can track two kinds of Performance Counter: time and count.
  86969. * 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.
  86970. * 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.
  86971. */
  86972. export class PerfCounter {
  86973. /**
  86974. * Gets or sets a global boolean to turn on and off all the counters
  86975. */
  86976. static Enabled: boolean;
  86977. /**
  86978. * Returns the smallest value ever
  86979. */
  86980. readonly min: number;
  86981. /**
  86982. * Returns the biggest value ever
  86983. */
  86984. readonly max: number;
  86985. /**
  86986. * Returns the average value since the performance counter is running
  86987. */
  86988. readonly average: number;
  86989. /**
  86990. * Returns the average value of the last second the counter was monitored
  86991. */
  86992. readonly lastSecAverage: number;
  86993. /**
  86994. * Returns the current value
  86995. */
  86996. readonly current: number;
  86997. /**
  86998. * Gets the accumulated total
  86999. */
  87000. readonly total: number;
  87001. /**
  87002. * Gets the total value count
  87003. */
  87004. readonly count: number;
  87005. /**
  87006. * Creates a new counter
  87007. */
  87008. constructor();
  87009. /**
  87010. * Call this method to start monitoring a new frame.
  87011. * 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.
  87012. */
  87013. fetchNewFrame(): void;
  87014. /**
  87015. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  87016. * @param newCount the count value to add to the monitored count
  87017. * @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.
  87018. */
  87019. addCount(newCount: number, fetchResult: boolean): void;
  87020. /**
  87021. * Start monitoring this performance counter
  87022. */
  87023. beginMonitoring(): void;
  87024. /**
  87025. * Compute the time lapsed since the previous beginMonitoring() call.
  87026. * @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
  87027. */
  87028. endMonitoring(newFrame?: boolean): void;
  87029. private _fetchResult;
  87030. private _startMonitoringTime;
  87031. private _min;
  87032. private _max;
  87033. private _average;
  87034. private _current;
  87035. private _totalValueCount;
  87036. private _totalAccumulated;
  87037. private _lastSecAverage;
  87038. private _lastSecAccumulated;
  87039. private _lastSecTime;
  87040. private _lastSecValueCount;
  87041. }
  87042. /**
  87043. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  87044. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  87045. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  87046. * @param name The name of the class, case should be preserved
  87047. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  87048. */
  87049. export function className(name: string, module?: string): (target: Object) => void;
  87050. /**
  87051. * An implementation of a loop for asynchronous functions.
  87052. */
  87053. export class AsyncLoop {
  87054. /**
  87055. * Defines the number of iterations for the loop
  87056. */
  87057. iterations: number;
  87058. /**
  87059. * Defines the current index of the loop.
  87060. */
  87061. index: number;
  87062. private _done;
  87063. private _fn;
  87064. private _successCallback;
  87065. /**
  87066. * Constructor.
  87067. * @param iterations the number of iterations.
  87068. * @param func the function to run each iteration
  87069. * @param successCallback the callback that will be called upon succesful execution
  87070. * @param offset starting offset.
  87071. */
  87072. constructor(
  87073. /**
  87074. * Defines the number of iterations for the loop
  87075. */
  87076. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87077. /**
  87078. * Execute the next iteration. Must be called after the last iteration was finished.
  87079. */
  87080. executeNext(): void;
  87081. /**
  87082. * Break the loop and run the success callback.
  87083. */
  87084. breakLoop(): void;
  87085. /**
  87086. * Create and run an async loop.
  87087. * @param iterations the number of iterations.
  87088. * @param fn the function to run each iteration
  87089. * @param successCallback the callback that will be called upon succesful execution
  87090. * @param offset starting offset.
  87091. * @returns the created async loop object
  87092. */
  87093. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87094. /**
  87095. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87096. * @param iterations total number of iterations
  87097. * @param syncedIterations number of synchronous iterations in each async iteration.
  87098. * @param fn the function to call each iteration.
  87099. * @param callback a success call back that will be called when iterating stops.
  87100. * @param breakFunction a break condition (optional)
  87101. * @param timeout timeout settings for the setTimeout function. default - 0.
  87102. * @returns the created async loop object
  87103. */
  87104. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87105. }
  87106. }
  87107. declare module BABYLON {
  87108. /** @hidden */
  87109. export interface ICollisionCoordinator {
  87110. createCollider(): Collider;
  87111. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87112. init(scene: Scene): void;
  87113. }
  87114. /** @hidden */
  87115. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87116. private _scene;
  87117. private _scaledPosition;
  87118. private _scaledVelocity;
  87119. private _finalPosition;
  87120. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87121. createCollider(): Collider;
  87122. init(scene: Scene): void;
  87123. private _collideWithWorld;
  87124. }
  87125. }
  87126. declare module BABYLON {
  87127. /**
  87128. * This class defines the direct association between an animation and a target
  87129. */
  87130. export class TargetedAnimation {
  87131. /**
  87132. * Animation to perform
  87133. */
  87134. animation: Animation;
  87135. /**
  87136. * Target to animate
  87137. */
  87138. target: any;
  87139. }
  87140. /**
  87141. * Use this class to create coordinated animations on multiple targets
  87142. */
  87143. export class AnimationGroup implements IDisposable {
  87144. /** The name of the animation group */
  87145. name: string;
  87146. private _scene;
  87147. private _targetedAnimations;
  87148. private _animatables;
  87149. private _from;
  87150. private _to;
  87151. private _isStarted;
  87152. private _isPaused;
  87153. private _speedRatio;
  87154. /**
  87155. * Gets or sets the unique id of the node
  87156. */
  87157. uniqueId: number;
  87158. /**
  87159. * This observable will notify when one animation have ended
  87160. */
  87161. onAnimationEndObservable: Observable<TargetedAnimation>;
  87162. /**
  87163. * Observer raised when one animation loops
  87164. */
  87165. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87166. /**
  87167. * This observable will notify when all animations have ended.
  87168. */
  87169. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87170. /**
  87171. * This observable will notify when all animations have paused.
  87172. */
  87173. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87174. /**
  87175. * This observable will notify when all animations are playing.
  87176. */
  87177. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87178. /**
  87179. * Gets the first frame
  87180. */
  87181. readonly from: number;
  87182. /**
  87183. * Gets the last frame
  87184. */
  87185. readonly to: number;
  87186. /**
  87187. * Define if the animations are started
  87188. */
  87189. readonly isStarted: boolean;
  87190. /**
  87191. * Gets a value indicating that the current group is playing
  87192. */
  87193. readonly isPlaying: boolean;
  87194. /**
  87195. * Gets or sets the speed ratio to use for all animations
  87196. */
  87197. /**
  87198. * Gets or sets the speed ratio to use for all animations
  87199. */
  87200. speedRatio: number;
  87201. /**
  87202. * Gets the targeted animations for this animation group
  87203. */
  87204. readonly targetedAnimations: Array<TargetedAnimation>;
  87205. /**
  87206. * returning the list of animatables controlled by this animation group.
  87207. */
  87208. readonly animatables: Array<Animatable>;
  87209. /**
  87210. * Instantiates a new Animation Group.
  87211. * This helps managing several animations at once.
  87212. * @see http://doc.babylonjs.com/how_to/group
  87213. * @param name Defines the name of the group
  87214. * @param scene Defines the scene the group belongs to
  87215. */
  87216. constructor(
  87217. /** The name of the animation group */
  87218. name: string, scene?: Nullable<Scene>);
  87219. /**
  87220. * Add an animation (with its target) in the group
  87221. * @param animation defines the animation we want to add
  87222. * @param target defines the target of the animation
  87223. * @returns the TargetedAnimation object
  87224. */
  87225. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87226. /**
  87227. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87228. * It can add constant keys at begin or end
  87229. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87230. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87231. * @returns the animation group
  87232. */
  87233. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87234. /**
  87235. * Start all animations on given targets
  87236. * @param loop defines if animations must loop
  87237. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87238. * @param from defines the from key (optional)
  87239. * @param to defines the to key (optional)
  87240. * @returns the current animation group
  87241. */
  87242. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87243. /**
  87244. * Pause all animations
  87245. * @returns the animation group
  87246. */
  87247. pause(): AnimationGroup;
  87248. /**
  87249. * Play all animations to initial state
  87250. * This function will start() the animations if they were not started or will restart() them if they were paused
  87251. * @param loop defines if animations must loop
  87252. * @returns the animation group
  87253. */
  87254. play(loop?: boolean): AnimationGroup;
  87255. /**
  87256. * Reset all animations to initial state
  87257. * @returns the animation group
  87258. */
  87259. reset(): AnimationGroup;
  87260. /**
  87261. * Restart animations from key 0
  87262. * @returns the animation group
  87263. */
  87264. restart(): AnimationGroup;
  87265. /**
  87266. * Stop all animations
  87267. * @returns the animation group
  87268. */
  87269. stop(): AnimationGroup;
  87270. /**
  87271. * Set animation weight for all animatables
  87272. * @param weight defines the weight to use
  87273. * @return the animationGroup
  87274. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87275. */
  87276. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87277. /**
  87278. * Synchronize and normalize all animatables with a source animatable
  87279. * @param root defines the root animatable to synchronize with
  87280. * @return the animationGroup
  87281. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87282. */
  87283. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87284. /**
  87285. * Goes to a specific frame in this animation group
  87286. * @param frame the frame number to go to
  87287. * @return the animationGroup
  87288. */
  87289. goToFrame(frame: number): AnimationGroup;
  87290. /**
  87291. * Dispose all associated resources
  87292. */
  87293. dispose(): void;
  87294. private _checkAnimationGroupEnded;
  87295. /**
  87296. * Clone the current animation group and returns a copy
  87297. * @param newName defines the name of the new group
  87298. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  87299. * @returns the new aniamtion group
  87300. */
  87301. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  87302. /**
  87303. * Returns a new AnimationGroup object parsed from the source provided.
  87304. * @param parsedAnimationGroup defines the source
  87305. * @param scene defines the scene that will receive the animationGroup
  87306. * @returns a new AnimationGroup
  87307. */
  87308. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87309. /**
  87310. * Returns the string "AnimationGroup"
  87311. * @returns "AnimationGroup"
  87312. */
  87313. getClassName(): string;
  87314. /**
  87315. * Creates a detailled string about the object
  87316. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87317. * @returns a string representing the object
  87318. */
  87319. toString(fullDetails?: boolean): string;
  87320. }
  87321. }
  87322. declare module BABYLON {
  87323. /**
  87324. * Define an interface for all classes that will hold resources
  87325. */
  87326. export interface IDisposable {
  87327. /**
  87328. * Releases all held resources
  87329. */
  87330. dispose(): void;
  87331. }
  87332. /** Interface defining initialization parameters for Scene class */
  87333. export interface SceneOptions {
  87334. /**
  87335. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87336. * It will improve performance when the number of geometries becomes important.
  87337. */
  87338. useGeometryUniqueIdsMap?: boolean;
  87339. /**
  87340. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87341. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87342. */
  87343. useMaterialMeshMap?: boolean;
  87344. /**
  87345. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87346. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87347. */
  87348. useClonedMeshhMap?: boolean;
  87349. }
  87350. /**
  87351. * Represents a scene to be rendered by the engine.
  87352. * @see http://doc.babylonjs.com/features/scene
  87353. */
  87354. export class Scene extends AbstractScene implements IAnimatable {
  87355. private static _uniqueIdCounter;
  87356. /** The fog is deactivated */
  87357. static readonly FOGMODE_NONE: number;
  87358. /** The fog density is following an exponential function */
  87359. static readonly FOGMODE_EXP: number;
  87360. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87361. static readonly FOGMODE_EXP2: number;
  87362. /** The fog density is following a linear function. */
  87363. static readonly FOGMODE_LINEAR: number;
  87364. /**
  87365. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87366. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87367. */
  87368. static MinDeltaTime: number;
  87369. /**
  87370. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87371. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87372. */
  87373. static MaxDeltaTime: number;
  87374. /**
  87375. * Factory used to create the default material.
  87376. * @param name The name of the material to create
  87377. * @param scene The scene to create the material for
  87378. * @returns The default material
  87379. */
  87380. static DefaultMaterialFactory(scene: Scene): Material;
  87381. /**
  87382. * Factory used to create the a collision coordinator.
  87383. * @returns The collision coordinator
  87384. */
  87385. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87386. /** @hidden */
  87387. readonly _isScene: boolean;
  87388. /**
  87389. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87390. */
  87391. autoClear: boolean;
  87392. /**
  87393. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87394. */
  87395. autoClearDepthAndStencil: boolean;
  87396. /**
  87397. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87398. */
  87399. clearColor: Color4;
  87400. /**
  87401. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87402. */
  87403. ambientColor: Color3;
  87404. /** @hidden */
  87405. _environmentBRDFTexture: BaseTexture;
  87406. /** @hidden */
  87407. protected _environmentTexture: Nullable<BaseTexture>;
  87408. /**
  87409. * Texture used in all pbr material as the reflection texture.
  87410. * As in the majority of the scene they are the same (exception for multi room and so on),
  87411. * this is easier to reference from here than from all the materials.
  87412. */
  87413. /**
  87414. * Texture used in all pbr material as the reflection texture.
  87415. * As in the majority of the scene they are the same (exception for multi room and so on),
  87416. * this is easier to set here than in all the materials.
  87417. */
  87418. environmentTexture: Nullable<BaseTexture>;
  87419. /** @hidden */
  87420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87421. /**
  87422. * Default image processing configuration used either in the rendering
  87423. * Forward main pass or through the imageProcessingPostProcess if present.
  87424. * As in the majority of the scene they are the same (exception for multi camera),
  87425. * this is easier to reference from here than from all the materials and post process.
  87426. *
  87427. * No setter as we it is a shared configuration, you can set the values instead.
  87428. */
  87429. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87430. private _forceWireframe;
  87431. /**
  87432. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87433. */
  87434. forceWireframe: boolean;
  87435. private _forcePointsCloud;
  87436. /**
  87437. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87438. */
  87439. forcePointsCloud: boolean;
  87440. /**
  87441. * Gets or sets the active clipplane 1
  87442. */
  87443. clipPlane: Nullable<Plane>;
  87444. /**
  87445. * Gets or sets the active clipplane 2
  87446. */
  87447. clipPlane2: Nullable<Plane>;
  87448. /**
  87449. * Gets or sets the active clipplane 3
  87450. */
  87451. clipPlane3: Nullable<Plane>;
  87452. /**
  87453. * Gets or sets the active clipplane 4
  87454. */
  87455. clipPlane4: Nullable<Plane>;
  87456. /**
  87457. * Gets or sets a boolean indicating if animations are enabled
  87458. */
  87459. animationsEnabled: boolean;
  87460. private _animationPropertiesOverride;
  87461. /**
  87462. * Gets or sets the animation properties override
  87463. */
  87464. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87465. /**
  87466. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87467. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87468. */
  87469. useConstantAnimationDeltaTime: boolean;
  87470. /**
  87471. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87472. * Please note that it requires to run a ray cast through the scene on every frame
  87473. */
  87474. constantlyUpdateMeshUnderPointer: boolean;
  87475. /**
  87476. * Defines the HTML cursor to use when hovering over interactive elements
  87477. */
  87478. hoverCursor: string;
  87479. /**
  87480. * Defines the HTML default cursor to use (empty by default)
  87481. */
  87482. defaultCursor: string;
  87483. /**
  87484. * This is used to call preventDefault() on pointer down
  87485. * in order to block unwanted artifacts like system double clicks
  87486. */
  87487. preventDefaultOnPointerDown: boolean;
  87488. /**
  87489. * This is used to call preventDefault() on pointer up
  87490. * in order to block unwanted artifacts like system double clicks
  87491. */
  87492. preventDefaultOnPointerUp: boolean;
  87493. /**
  87494. * Gets or sets user defined metadata
  87495. */
  87496. metadata: any;
  87497. /**
  87498. * For internal use only. Please do not use.
  87499. */
  87500. reservedDataStore: any;
  87501. /**
  87502. * Gets the name of the plugin used to load this scene (null by default)
  87503. */
  87504. loadingPluginName: string;
  87505. /**
  87506. * Use this array to add regular expressions used to disable offline support for specific urls
  87507. */
  87508. disableOfflineSupportExceptionRules: RegExp[];
  87509. /**
  87510. * An event triggered when the scene is disposed.
  87511. */
  87512. onDisposeObservable: Observable<Scene>;
  87513. private _onDisposeObserver;
  87514. /** Sets a function to be executed when this scene is disposed. */
  87515. onDispose: () => void;
  87516. /**
  87517. * An event triggered before rendering the scene (right after animations and physics)
  87518. */
  87519. onBeforeRenderObservable: Observable<Scene>;
  87520. private _onBeforeRenderObserver;
  87521. /** Sets a function to be executed before rendering this scene */
  87522. beforeRender: Nullable<() => void>;
  87523. /**
  87524. * An event triggered after rendering the scene
  87525. */
  87526. onAfterRenderObservable: Observable<Scene>;
  87527. private _onAfterRenderObserver;
  87528. /** Sets a function to be executed after rendering this scene */
  87529. afterRender: Nullable<() => void>;
  87530. /**
  87531. * An event triggered before animating the scene
  87532. */
  87533. onBeforeAnimationsObservable: Observable<Scene>;
  87534. /**
  87535. * An event triggered after animations processing
  87536. */
  87537. onAfterAnimationsObservable: Observable<Scene>;
  87538. /**
  87539. * An event triggered before draw calls are ready to be sent
  87540. */
  87541. onBeforeDrawPhaseObservable: Observable<Scene>;
  87542. /**
  87543. * An event triggered after draw calls have been sent
  87544. */
  87545. onAfterDrawPhaseObservable: Observable<Scene>;
  87546. /**
  87547. * An event triggered when the scene is ready
  87548. */
  87549. onReadyObservable: Observable<Scene>;
  87550. /**
  87551. * An event triggered before rendering a camera
  87552. */
  87553. onBeforeCameraRenderObservable: Observable<Camera>;
  87554. private _onBeforeCameraRenderObserver;
  87555. /** Sets a function to be executed before rendering a camera*/
  87556. beforeCameraRender: () => void;
  87557. /**
  87558. * An event triggered after rendering a camera
  87559. */
  87560. onAfterCameraRenderObservable: Observable<Camera>;
  87561. private _onAfterCameraRenderObserver;
  87562. /** Sets a function to be executed after rendering a camera*/
  87563. afterCameraRender: () => void;
  87564. /**
  87565. * An event triggered when active meshes evaluation is about to start
  87566. */
  87567. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  87568. /**
  87569. * An event triggered when active meshes evaluation is done
  87570. */
  87571. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  87572. /**
  87573. * An event triggered when particles rendering is about to start
  87574. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87575. */
  87576. onBeforeParticlesRenderingObservable: Observable<Scene>;
  87577. /**
  87578. * An event triggered when particles rendering is done
  87579. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87580. */
  87581. onAfterParticlesRenderingObservable: Observable<Scene>;
  87582. /**
  87583. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  87584. */
  87585. onDataLoadedObservable: Observable<Scene>;
  87586. /**
  87587. * An event triggered when a camera is created
  87588. */
  87589. onNewCameraAddedObservable: Observable<Camera>;
  87590. /**
  87591. * An event triggered when a camera is removed
  87592. */
  87593. onCameraRemovedObservable: Observable<Camera>;
  87594. /**
  87595. * An event triggered when a light is created
  87596. */
  87597. onNewLightAddedObservable: Observable<Light>;
  87598. /**
  87599. * An event triggered when a light is removed
  87600. */
  87601. onLightRemovedObservable: Observable<Light>;
  87602. /**
  87603. * An event triggered when a geometry is created
  87604. */
  87605. onNewGeometryAddedObservable: Observable<Geometry>;
  87606. /**
  87607. * An event triggered when a geometry is removed
  87608. */
  87609. onGeometryRemovedObservable: Observable<Geometry>;
  87610. /**
  87611. * An event triggered when a transform node is created
  87612. */
  87613. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  87614. /**
  87615. * An event triggered when a transform node is removed
  87616. */
  87617. onTransformNodeRemovedObservable: Observable<TransformNode>;
  87618. /**
  87619. * An event triggered when a mesh is created
  87620. */
  87621. onNewMeshAddedObservable: Observable<AbstractMesh>;
  87622. /**
  87623. * An event triggered when a mesh is removed
  87624. */
  87625. onMeshRemovedObservable: Observable<AbstractMesh>;
  87626. /**
  87627. * An event triggered when a material is created
  87628. */
  87629. onNewMaterialAddedObservable: Observable<Material>;
  87630. /**
  87631. * An event triggered when a material is removed
  87632. */
  87633. onMaterialRemovedObservable: Observable<Material>;
  87634. /**
  87635. * An event triggered when a texture is created
  87636. */
  87637. onNewTextureAddedObservable: Observable<BaseTexture>;
  87638. /**
  87639. * An event triggered when a texture is removed
  87640. */
  87641. onTextureRemovedObservable: Observable<BaseTexture>;
  87642. /**
  87643. * An event triggered when render targets are about to be rendered
  87644. * Can happen multiple times per frame.
  87645. */
  87646. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  87647. /**
  87648. * An event triggered when render targets were rendered.
  87649. * Can happen multiple times per frame.
  87650. */
  87651. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  87652. /**
  87653. * An event triggered before calculating deterministic simulation step
  87654. */
  87655. onBeforeStepObservable: Observable<Scene>;
  87656. /**
  87657. * An event triggered after calculating deterministic simulation step
  87658. */
  87659. onAfterStepObservable: Observable<Scene>;
  87660. /**
  87661. * An event triggered when the activeCamera property is updated
  87662. */
  87663. onActiveCameraChanged: Observable<Scene>;
  87664. /**
  87665. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  87666. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87667. * 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)
  87668. */
  87669. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87670. /**
  87671. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  87672. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87673. * 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)
  87674. */
  87675. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87676. /**
  87677. * This Observable will when a mesh has been imported into the scene.
  87678. */
  87679. onMeshImportedObservable: Observable<AbstractMesh>;
  87680. /** @hidden */
  87681. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  87682. /**
  87683. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  87684. */
  87685. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  87686. /**
  87687. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  87688. */
  87689. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  87690. /**
  87691. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  87692. */
  87693. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  87694. private _onPointerMove;
  87695. private _onPointerDown;
  87696. private _onPointerUp;
  87697. /** Callback called when a pointer move is detected */
  87698. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87699. /** Callback called when a pointer down is detected */
  87700. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87701. /** Callback called when a pointer up is detected */
  87702. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  87703. /** Callback called when a pointer pick is detected */
  87704. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  87705. /**
  87706. * 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).
  87707. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  87708. */
  87709. onPrePointerObservable: Observable<PointerInfoPre>;
  87710. /**
  87711. * Observable event triggered each time an input event is received from the rendering canvas
  87712. */
  87713. onPointerObservable: Observable<PointerInfo>;
  87714. /**
  87715. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  87716. */
  87717. readonly unTranslatedPointer: Vector2;
  87718. /** The distance in pixel that you have to move to prevent some events */
  87719. static DragMovementThreshold: number;
  87720. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  87721. static LongPressDelay: number;
  87722. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  87723. static DoubleClickDelay: number;
  87724. /** If you need to check double click without raising a single click at first click, enable this flag */
  87725. static ExclusiveDoubleClickMode: boolean;
  87726. private _initClickEvent;
  87727. private _initActionManager;
  87728. private _delayedSimpleClick;
  87729. private _delayedSimpleClickTimeout;
  87730. private _previousDelayedSimpleClickTimeout;
  87731. private _meshPickProceed;
  87732. private _previousButtonPressed;
  87733. private _currentPickResult;
  87734. private _previousPickResult;
  87735. private _totalPointersPressed;
  87736. private _doubleClickOccured;
  87737. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  87738. cameraToUseForPointers: Nullable<Camera>;
  87739. private _pointerX;
  87740. private _pointerY;
  87741. private _unTranslatedPointerX;
  87742. private _unTranslatedPointerY;
  87743. private _startingPointerPosition;
  87744. private _previousStartingPointerPosition;
  87745. private _startingPointerTime;
  87746. private _previousStartingPointerTime;
  87747. private _pointerCaptures;
  87748. private _timeAccumulator;
  87749. private _currentStepId;
  87750. private _currentInternalStep;
  87751. /** @hidden */
  87752. _mirroredCameraPosition: Nullable<Vector3>;
  87753. /**
  87754. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  87755. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  87756. */
  87757. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  87758. /**
  87759. * Observable event triggered each time an keyboard event is received from the hosting window
  87760. */
  87761. onKeyboardObservable: Observable<KeyboardInfo>;
  87762. private _onKeyDown;
  87763. private _onKeyUp;
  87764. private _onCanvasFocusObserver;
  87765. private _onCanvasBlurObserver;
  87766. private _useRightHandedSystem;
  87767. /**
  87768. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  87769. */
  87770. useRightHandedSystem: boolean;
  87771. /**
  87772. * Sets the step Id used by deterministic lock step
  87773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87774. * @param newStepId defines the step Id
  87775. */
  87776. setStepId(newStepId: number): void;
  87777. /**
  87778. * Gets the step Id used by deterministic lock step
  87779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87780. * @returns the step Id
  87781. */
  87782. getStepId(): number;
  87783. /**
  87784. * Gets the internal step used by deterministic lock step
  87785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87786. * @returns the internal step
  87787. */
  87788. getInternalStep(): number;
  87789. private _fogEnabled;
  87790. /**
  87791. * Gets or sets a boolean indicating if fog is enabled on this scene
  87792. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87793. * (Default is true)
  87794. */
  87795. fogEnabled: boolean;
  87796. private _fogMode;
  87797. /**
  87798. * Gets or sets the fog mode to use
  87799. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87800. * | mode | value |
  87801. * | --- | --- |
  87802. * | FOGMODE_NONE | 0 |
  87803. * | FOGMODE_EXP | 1 |
  87804. * | FOGMODE_EXP2 | 2 |
  87805. * | FOGMODE_LINEAR | 3 |
  87806. */
  87807. fogMode: number;
  87808. /**
  87809. * Gets or sets the fog color to use
  87810. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87811. * (Default is Color3(0.2, 0.2, 0.3))
  87812. */
  87813. fogColor: Color3;
  87814. /**
  87815. * Gets or sets the fog density to use
  87816. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87817. * (Default is 0.1)
  87818. */
  87819. fogDensity: number;
  87820. /**
  87821. * Gets or sets the fog start distance to use
  87822. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87823. * (Default is 0)
  87824. */
  87825. fogStart: number;
  87826. /**
  87827. * Gets or sets the fog end distance to use
  87828. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87829. * (Default is 1000)
  87830. */
  87831. fogEnd: number;
  87832. private _shadowsEnabled;
  87833. /**
  87834. * Gets or sets a boolean indicating if shadows are enabled on this scene
  87835. */
  87836. shadowsEnabled: boolean;
  87837. private _lightsEnabled;
  87838. /**
  87839. * Gets or sets a boolean indicating if lights are enabled on this scene
  87840. */
  87841. lightsEnabled: boolean;
  87842. /** All of the active cameras added to this scene. */
  87843. activeCameras: Camera[];
  87844. private _activeCamera;
  87845. /** Gets or sets the current active camera */
  87846. activeCamera: Nullable<Camera>;
  87847. private _defaultMaterial;
  87848. /** The default material used on meshes when no material is affected */
  87849. /** The default material used on meshes when no material is affected */
  87850. defaultMaterial: Material;
  87851. private _texturesEnabled;
  87852. /**
  87853. * Gets or sets a boolean indicating if textures are enabled on this scene
  87854. */
  87855. texturesEnabled: boolean;
  87856. /**
  87857. * Gets or sets a boolean indicating if particles are enabled on this scene
  87858. */
  87859. particlesEnabled: boolean;
  87860. /**
  87861. * Gets or sets a boolean indicating if sprites are enabled on this scene
  87862. */
  87863. spritesEnabled: boolean;
  87864. private _skeletonsEnabled;
  87865. /**
  87866. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  87867. */
  87868. skeletonsEnabled: boolean;
  87869. /**
  87870. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  87871. */
  87872. lensFlaresEnabled: boolean;
  87873. /**
  87874. * Gets or sets a boolean indicating if collisions are enabled on this scene
  87875. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87876. */
  87877. collisionsEnabled: boolean;
  87878. private _collisionCoordinator;
  87879. /** @hidden */
  87880. readonly collisionCoordinator: ICollisionCoordinator;
  87881. /**
  87882. * Defines the gravity applied to this scene (used only for collisions)
  87883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87884. */
  87885. gravity: Vector3;
  87886. /**
  87887. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  87888. */
  87889. postProcessesEnabled: boolean;
  87890. /**
  87891. * The list of postprocesses added to the scene
  87892. */
  87893. postProcesses: PostProcess[];
  87894. /**
  87895. * Gets the current postprocess manager
  87896. */
  87897. postProcessManager: PostProcessManager;
  87898. /**
  87899. * Gets or sets a boolean indicating if render targets are enabled on this scene
  87900. */
  87901. renderTargetsEnabled: boolean;
  87902. /**
  87903. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  87904. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  87905. */
  87906. dumpNextRenderTargets: boolean;
  87907. /**
  87908. * The list of user defined render targets added to the scene
  87909. */
  87910. customRenderTargets: RenderTargetTexture[];
  87911. /**
  87912. * Defines if texture loading must be delayed
  87913. * If true, textures will only be loaded when they need to be rendered
  87914. */
  87915. useDelayedTextureLoading: boolean;
  87916. /**
  87917. * Gets the list of meshes imported to the scene through SceneLoader
  87918. */
  87919. importedMeshesFiles: String[];
  87920. /**
  87921. * Gets or sets a boolean indicating if probes are enabled on this scene
  87922. */
  87923. probesEnabled: boolean;
  87924. /**
  87925. * Gets or sets the current offline provider to use to store scene data
  87926. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  87927. */
  87928. offlineProvider: IOfflineProvider;
  87929. /**
  87930. * Gets or sets the action manager associated with the scene
  87931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87932. */
  87933. actionManager: AbstractActionManager;
  87934. private _meshesForIntersections;
  87935. /**
  87936. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  87937. */
  87938. proceduralTexturesEnabled: boolean;
  87939. private _engine;
  87940. private _totalVertices;
  87941. /** @hidden */
  87942. _activeIndices: PerfCounter;
  87943. /** @hidden */
  87944. _activeParticles: PerfCounter;
  87945. /** @hidden */
  87946. _activeBones: PerfCounter;
  87947. private _animationRatio;
  87948. /** @hidden */
  87949. _animationTimeLast: number;
  87950. /** @hidden */
  87951. _animationTime: number;
  87952. /**
  87953. * Gets or sets a general scale for animation speed
  87954. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  87955. */
  87956. animationTimeScale: number;
  87957. /** @hidden */
  87958. _cachedMaterial: Nullable<Material>;
  87959. /** @hidden */
  87960. _cachedEffect: Nullable<Effect>;
  87961. /** @hidden */
  87962. _cachedVisibility: Nullable<number>;
  87963. private _renderId;
  87964. private _frameId;
  87965. private _executeWhenReadyTimeoutId;
  87966. private _intermediateRendering;
  87967. private _viewUpdateFlag;
  87968. private _projectionUpdateFlag;
  87969. private _alternateViewUpdateFlag;
  87970. private _alternateProjectionUpdateFlag;
  87971. /** @hidden */
  87972. _toBeDisposed: Nullable<IDisposable>[];
  87973. private _activeRequests;
  87974. /** @hidden */
  87975. _pendingData: any[];
  87976. private _isDisposed;
  87977. /**
  87978. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  87979. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  87980. */
  87981. dispatchAllSubMeshesOfActiveMeshes: boolean;
  87982. private _activeMeshes;
  87983. private _processedMaterials;
  87984. private _renderTargets;
  87985. /** @hidden */
  87986. _activeParticleSystems: SmartArray<IParticleSystem>;
  87987. private _activeSkeletons;
  87988. private _softwareSkinnedMeshes;
  87989. private _renderingManager;
  87990. /** @hidden */
  87991. _activeAnimatables: Animatable[];
  87992. private _transformMatrix;
  87993. private _sceneUbo;
  87994. private _alternateSceneUbo;
  87995. private _viewMatrix;
  87996. private _projectionMatrix;
  87997. private _alternateViewMatrix;
  87998. private _alternateProjectionMatrix;
  87999. private _alternateTransformMatrix;
  88000. private _useAlternateCameraConfiguration;
  88001. private _alternateRendering;
  88002. private _wheelEventName;
  88003. /** @hidden */
  88004. _forcedViewPosition: Nullable<Vector3>;
  88005. /** @hidden */
  88006. readonly _isAlternateRenderingEnabled: boolean;
  88007. private _frustumPlanes;
  88008. /**
  88009. * Gets the list of frustum planes (built from the active camera)
  88010. */
  88011. readonly frustumPlanes: Plane[];
  88012. /**
  88013. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  88014. * This is useful if there are more lights that the maximum simulteanous authorized
  88015. */
  88016. requireLightSorting: boolean;
  88017. /** @hidden */
  88018. readonly useMaterialMeshMap: boolean;
  88019. /** @hidden */
  88020. readonly useClonedMeshhMap: boolean;
  88021. private _pointerOverMesh;
  88022. private _pickedDownMesh;
  88023. private _pickedUpMesh;
  88024. private _externalData;
  88025. private _uid;
  88026. /**
  88027. * @hidden
  88028. * Backing store of defined scene components.
  88029. */
  88030. _components: ISceneComponent[];
  88031. /**
  88032. * @hidden
  88033. * Backing store of defined scene components.
  88034. */
  88035. _serializableComponents: ISceneSerializableComponent[];
  88036. /**
  88037. * List of components to register on the next registration step.
  88038. */
  88039. private _transientComponents;
  88040. /**
  88041. * Registers the transient components if needed.
  88042. */
  88043. private _registerTransientComponents;
  88044. /**
  88045. * @hidden
  88046. * Add a component to the scene.
  88047. * Note that the ccomponent could be registered on th next frame if this is called after
  88048. * the register component stage.
  88049. * @param component Defines the component to add to the scene
  88050. */
  88051. _addComponent(component: ISceneComponent): void;
  88052. /**
  88053. * @hidden
  88054. * Gets a component from the scene.
  88055. * @param name defines the name of the component to retrieve
  88056. * @returns the component or null if not present
  88057. */
  88058. _getComponent(name: string): Nullable<ISceneComponent>;
  88059. /**
  88060. * @hidden
  88061. * Defines the actions happening before camera updates.
  88062. */
  88063. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  88064. /**
  88065. * @hidden
  88066. * Defines the actions happening before clear the canvas.
  88067. */
  88068. _beforeClearStage: Stage<SimpleStageAction>;
  88069. /**
  88070. * @hidden
  88071. * Defines the actions when collecting render targets for the frame.
  88072. */
  88073. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88074. /**
  88075. * @hidden
  88076. * Defines the actions happening for one camera in the frame.
  88077. */
  88078. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88079. /**
  88080. * @hidden
  88081. * Defines the actions happening during the per mesh ready checks.
  88082. */
  88083. _isReadyForMeshStage: Stage<MeshStageAction>;
  88084. /**
  88085. * @hidden
  88086. * Defines the actions happening before evaluate active mesh checks.
  88087. */
  88088. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88089. /**
  88090. * @hidden
  88091. * Defines the actions happening during the evaluate sub mesh checks.
  88092. */
  88093. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88094. /**
  88095. * @hidden
  88096. * Defines the actions happening during the active mesh stage.
  88097. */
  88098. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88099. /**
  88100. * @hidden
  88101. * Defines the actions happening during the per camera render target step.
  88102. */
  88103. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88104. /**
  88105. * @hidden
  88106. * Defines the actions happening just before the active camera is drawing.
  88107. */
  88108. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88109. /**
  88110. * @hidden
  88111. * Defines the actions happening just before a render target is drawing.
  88112. */
  88113. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88114. /**
  88115. * @hidden
  88116. * Defines the actions happening just before a rendering group is drawing.
  88117. */
  88118. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88119. /**
  88120. * @hidden
  88121. * Defines the actions happening just before a mesh is drawing.
  88122. */
  88123. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88124. /**
  88125. * @hidden
  88126. * Defines the actions happening just after a mesh has been drawn.
  88127. */
  88128. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88129. /**
  88130. * @hidden
  88131. * Defines the actions happening just after a rendering group has been drawn.
  88132. */
  88133. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88134. /**
  88135. * @hidden
  88136. * Defines the actions happening just after the active camera has been drawn.
  88137. */
  88138. _afterCameraDrawStage: Stage<CameraStageAction>;
  88139. /**
  88140. * @hidden
  88141. * Defines the actions happening just after a render target has been drawn.
  88142. */
  88143. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88144. /**
  88145. * @hidden
  88146. * Defines the actions happening just after rendering all cameras and computing intersections.
  88147. */
  88148. _afterRenderStage: Stage<SimpleStageAction>;
  88149. /**
  88150. * @hidden
  88151. * Defines the actions happening when a pointer move event happens.
  88152. */
  88153. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88154. /**
  88155. * @hidden
  88156. * Defines the actions happening when a pointer down event happens.
  88157. */
  88158. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88159. /**
  88160. * @hidden
  88161. * Defines the actions happening when a pointer up event happens.
  88162. */
  88163. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88164. /**
  88165. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88166. */
  88167. private geometriesByUniqueId;
  88168. /**
  88169. * Creates a new Scene
  88170. * @param engine defines the engine to use to render this scene
  88171. * @param options defines the scene options
  88172. */
  88173. constructor(engine: Engine, options?: SceneOptions);
  88174. private _defaultMeshCandidates;
  88175. /**
  88176. * @hidden
  88177. */
  88178. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88179. private _defaultSubMeshCandidates;
  88180. /**
  88181. * @hidden
  88182. */
  88183. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88184. /**
  88185. * Sets the default candidate providers for the scene.
  88186. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88187. * and getCollidingSubMeshCandidates to their default function
  88188. */
  88189. setDefaultCandidateProviders(): void;
  88190. /**
  88191. * Gets the mesh that is currently under the pointer
  88192. */
  88193. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88194. /**
  88195. * Gets or sets the current on-screen X position of the pointer
  88196. */
  88197. pointerX: number;
  88198. /**
  88199. * Gets or sets the current on-screen Y position of the pointer
  88200. */
  88201. pointerY: number;
  88202. /**
  88203. * Gets the cached material (ie. the latest rendered one)
  88204. * @returns the cached material
  88205. */
  88206. getCachedMaterial(): Nullable<Material>;
  88207. /**
  88208. * Gets the cached effect (ie. the latest rendered one)
  88209. * @returns the cached effect
  88210. */
  88211. getCachedEffect(): Nullable<Effect>;
  88212. /**
  88213. * Gets the cached visibility state (ie. the latest rendered one)
  88214. * @returns the cached visibility state
  88215. */
  88216. getCachedVisibility(): Nullable<number>;
  88217. /**
  88218. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88219. * @param material defines the current material
  88220. * @param effect defines the current effect
  88221. * @param visibility defines the current visibility state
  88222. * @returns true if one parameter is not cached
  88223. */
  88224. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88225. /**
  88226. * Gets the engine associated with the scene
  88227. * @returns an Engine
  88228. */
  88229. getEngine(): Engine;
  88230. /**
  88231. * Gets the total number of vertices rendered per frame
  88232. * @returns the total number of vertices rendered per frame
  88233. */
  88234. getTotalVertices(): number;
  88235. /**
  88236. * Gets the performance counter for total vertices
  88237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88238. */
  88239. readonly totalVerticesPerfCounter: PerfCounter;
  88240. /**
  88241. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88242. * @returns the total number of active indices rendered per frame
  88243. */
  88244. getActiveIndices(): number;
  88245. /**
  88246. * Gets the performance counter for active indices
  88247. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88248. */
  88249. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88250. /**
  88251. * Gets the total number of active particles rendered per frame
  88252. * @returns the total number of active particles rendered per frame
  88253. */
  88254. getActiveParticles(): number;
  88255. /**
  88256. * Gets the performance counter for active particles
  88257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88258. */
  88259. readonly activeParticlesPerfCounter: PerfCounter;
  88260. /**
  88261. * Gets the total number of active bones rendered per frame
  88262. * @returns the total number of active bones rendered per frame
  88263. */
  88264. getActiveBones(): number;
  88265. /**
  88266. * Gets the performance counter for active bones
  88267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88268. */
  88269. readonly activeBonesPerfCounter: PerfCounter;
  88270. /**
  88271. * Gets the array of active meshes
  88272. * @returns an array of AbstractMesh
  88273. */
  88274. getActiveMeshes(): SmartArray<AbstractMesh>;
  88275. /**
  88276. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88277. * @returns a number
  88278. */
  88279. getAnimationRatio(): number;
  88280. /**
  88281. * Gets an unique Id for the current render phase
  88282. * @returns a number
  88283. */
  88284. getRenderId(): number;
  88285. /**
  88286. * Gets an unique Id for the current frame
  88287. * @returns a number
  88288. */
  88289. getFrameId(): number;
  88290. /** Call this function if you want to manually increment the render Id*/
  88291. incrementRenderId(): void;
  88292. private _updatePointerPosition;
  88293. private _createUbo;
  88294. private _createAlternateUbo;
  88295. private _setRayOnPointerInfo;
  88296. /**
  88297. * Use this method to simulate a pointer move on a mesh
  88298. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88299. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88300. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88301. * @returns the current scene
  88302. */
  88303. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88304. private _processPointerMove;
  88305. private _checkPrePointerObservable;
  88306. /**
  88307. * Use this method to simulate a pointer down on a mesh
  88308. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88309. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88310. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88311. * @returns the current scene
  88312. */
  88313. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88314. private _processPointerDown;
  88315. /**
  88316. * Use this method to simulate a pointer up on a mesh
  88317. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88318. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88319. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88320. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88321. * @returns the current scene
  88322. */
  88323. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88324. private _processPointerUp;
  88325. /**
  88326. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88327. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88328. * @returns true if the pointer was captured
  88329. */
  88330. isPointerCaptured(pointerId?: number): boolean;
  88331. /** @hidden */
  88332. _isPointerSwiping(): boolean;
  88333. /**
  88334. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88335. * @param attachUp defines if you want to attach events to pointerup
  88336. * @param attachDown defines if you want to attach events to pointerdown
  88337. * @param attachMove defines if you want to attach events to pointermove
  88338. */
  88339. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88340. /** Detaches all event handlers*/
  88341. detachControl(): void;
  88342. /**
  88343. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88344. * Delay loaded resources are not taking in account
  88345. * @return true if all required resources are ready
  88346. */
  88347. isReady(): boolean;
  88348. /** Resets all cached information relative to material (including effect and visibility) */
  88349. resetCachedMaterial(): void;
  88350. /**
  88351. * Registers a function to be called before every frame render
  88352. * @param func defines the function to register
  88353. */
  88354. registerBeforeRender(func: () => void): void;
  88355. /**
  88356. * Unregisters a function called before every frame render
  88357. * @param func defines the function to unregister
  88358. */
  88359. unregisterBeforeRender(func: () => void): void;
  88360. /**
  88361. * Registers a function to be called after every frame render
  88362. * @param func defines the function to register
  88363. */
  88364. registerAfterRender(func: () => void): void;
  88365. /**
  88366. * Unregisters a function called after every frame render
  88367. * @param func defines the function to unregister
  88368. */
  88369. unregisterAfterRender(func: () => void): void;
  88370. private _executeOnceBeforeRender;
  88371. /**
  88372. * The provided function will run before render once and will be disposed afterwards.
  88373. * A timeout delay can be provided so that the function will be executed in N ms.
  88374. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88375. * @param func The function to be executed.
  88376. * @param timeout optional delay in ms
  88377. */
  88378. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88379. /** @hidden */
  88380. _addPendingData(data: any): void;
  88381. /** @hidden */
  88382. _removePendingData(data: any): void;
  88383. /**
  88384. * Returns the number of items waiting to be loaded
  88385. * @returns the number of items waiting to be loaded
  88386. */
  88387. getWaitingItemsCount(): number;
  88388. /**
  88389. * Returns a boolean indicating if the scene is still loading data
  88390. */
  88391. readonly isLoading: boolean;
  88392. /**
  88393. * Registers a function to be executed when the scene is ready
  88394. * @param {Function} func - the function to be executed
  88395. */
  88396. executeWhenReady(func: () => void): void;
  88397. /**
  88398. * Returns a promise that resolves when the scene is ready
  88399. * @returns A promise that resolves when the scene is ready
  88400. */
  88401. whenReadyAsync(): Promise<void>;
  88402. /** @hidden */
  88403. _checkIsReady(): void;
  88404. /**
  88405. * Gets all animatable attached to the scene
  88406. */
  88407. readonly animatables: Animatable[];
  88408. /**
  88409. * Resets the last animation time frame.
  88410. * Useful to override when animations start running when loading a scene for the first time.
  88411. */
  88412. resetLastAnimationTimeFrame(): void;
  88413. /** @hidden */
  88414. _switchToAlternateCameraConfiguration(active: boolean): void;
  88415. /**
  88416. * Gets the current view matrix
  88417. * @returns a Matrix
  88418. */
  88419. getViewMatrix(): Matrix;
  88420. /**
  88421. * Gets the current projection matrix
  88422. * @returns a Matrix
  88423. */
  88424. getProjectionMatrix(): Matrix;
  88425. /**
  88426. * Gets the current transform matrix
  88427. * @returns a Matrix made of View * Projection
  88428. */
  88429. getTransformMatrix(): Matrix;
  88430. /**
  88431. * Sets the current transform matrix
  88432. * @param view defines the View matrix to use
  88433. * @param projection defines the Projection matrix to use
  88434. */
  88435. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88436. /** @hidden */
  88437. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88438. /**
  88439. * Gets the uniform buffer used to store scene data
  88440. * @returns a UniformBuffer
  88441. */
  88442. getSceneUniformBuffer(): UniformBuffer;
  88443. /**
  88444. * Gets an unique (relatively to the current scene) Id
  88445. * @returns an unique number for the scene
  88446. */
  88447. getUniqueId(): number;
  88448. /**
  88449. * Add a mesh to the list of scene's meshes
  88450. * @param newMesh defines the mesh to add
  88451. * @param recursive if all child meshes should also be added to the scene
  88452. */
  88453. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88454. /**
  88455. * Remove a mesh for the list of scene's meshes
  88456. * @param toRemove defines the mesh to remove
  88457. * @param recursive if all child meshes should also be removed from the scene
  88458. * @returns the index where the mesh was in the mesh list
  88459. */
  88460. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88461. /**
  88462. * Add a transform node to the list of scene's transform nodes
  88463. * @param newTransformNode defines the transform node to add
  88464. */
  88465. addTransformNode(newTransformNode: TransformNode): void;
  88466. /**
  88467. * Remove a transform node for the list of scene's transform nodes
  88468. * @param toRemove defines the transform node to remove
  88469. * @returns the index where the transform node was in the transform node list
  88470. */
  88471. removeTransformNode(toRemove: TransformNode): number;
  88472. /**
  88473. * Remove a skeleton for the list of scene's skeletons
  88474. * @param toRemove defines the skeleton to remove
  88475. * @returns the index where the skeleton was in the skeleton list
  88476. */
  88477. removeSkeleton(toRemove: Skeleton): number;
  88478. /**
  88479. * Remove a morph target for the list of scene's morph targets
  88480. * @param toRemove defines the morph target to remove
  88481. * @returns the index where the morph target was in the morph target list
  88482. */
  88483. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88484. /**
  88485. * Remove a light for the list of scene's lights
  88486. * @param toRemove defines the light to remove
  88487. * @returns the index where the light was in the light list
  88488. */
  88489. removeLight(toRemove: Light): number;
  88490. /**
  88491. * Remove a camera for the list of scene's cameras
  88492. * @param toRemove defines the camera to remove
  88493. * @returns the index where the camera was in the camera list
  88494. */
  88495. removeCamera(toRemove: Camera): number;
  88496. /**
  88497. * Remove a particle system for the list of scene's particle systems
  88498. * @param toRemove defines the particle system to remove
  88499. * @returns the index where the particle system was in the particle system list
  88500. */
  88501. removeParticleSystem(toRemove: IParticleSystem): number;
  88502. /**
  88503. * Remove a animation for the list of scene's animations
  88504. * @param toRemove defines the animation to remove
  88505. * @returns the index where the animation was in the animation list
  88506. */
  88507. removeAnimation(toRemove: Animation): number;
  88508. /**
  88509. * Removes the given animation group from this scene.
  88510. * @param toRemove The animation group to remove
  88511. * @returns The index of the removed animation group
  88512. */
  88513. removeAnimationGroup(toRemove: AnimationGroup): number;
  88514. /**
  88515. * Removes the given multi-material from this scene.
  88516. * @param toRemove The multi-material to remove
  88517. * @returns The index of the removed multi-material
  88518. */
  88519. removeMultiMaterial(toRemove: MultiMaterial): number;
  88520. /**
  88521. * Removes the given material from this scene.
  88522. * @param toRemove The material to remove
  88523. * @returns The index of the removed material
  88524. */
  88525. removeMaterial(toRemove: Material): number;
  88526. /**
  88527. * Removes the given action manager from this scene.
  88528. * @param toRemove The action manager to remove
  88529. * @returns The index of the removed action manager
  88530. */
  88531. removeActionManager(toRemove: AbstractActionManager): number;
  88532. /**
  88533. * Removes the given texture from this scene.
  88534. * @param toRemove The texture to remove
  88535. * @returns The index of the removed texture
  88536. */
  88537. removeTexture(toRemove: BaseTexture): number;
  88538. /**
  88539. * Adds the given light to this scene
  88540. * @param newLight The light to add
  88541. */
  88542. addLight(newLight: Light): void;
  88543. /**
  88544. * Sorts the list list based on light priorities
  88545. */
  88546. sortLightsByPriority(): void;
  88547. /**
  88548. * Adds the given camera to this scene
  88549. * @param newCamera The camera to add
  88550. */
  88551. addCamera(newCamera: Camera): void;
  88552. /**
  88553. * Adds the given skeleton to this scene
  88554. * @param newSkeleton The skeleton to add
  88555. */
  88556. addSkeleton(newSkeleton: Skeleton): void;
  88557. /**
  88558. * Adds the given particle system to this scene
  88559. * @param newParticleSystem The particle system to add
  88560. */
  88561. addParticleSystem(newParticleSystem: IParticleSystem): void;
  88562. /**
  88563. * Adds the given animation to this scene
  88564. * @param newAnimation The animation to add
  88565. */
  88566. addAnimation(newAnimation: Animation): void;
  88567. /**
  88568. * Adds the given animation group to this scene.
  88569. * @param newAnimationGroup The animation group to add
  88570. */
  88571. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  88572. /**
  88573. * Adds the given multi-material to this scene
  88574. * @param newMultiMaterial The multi-material to add
  88575. */
  88576. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  88577. /**
  88578. * Adds the given material to this scene
  88579. * @param newMaterial The material to add
  88580. */
  88581. addMaterial(newMaterial: Material): void;
  88582. /**
  88583. * Adds the given morph target to this scene
  88584. * @param newMorphTargetManager The morph target to add
  88585. */
  88586. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  88587. /**
  88588. * Adds the given geometry to this scene
  88589. * @param newGeometry The geometry to add
  88590. */
  88591. addGeometry(newGeometry: Geometry): void;
  88592. /**
  88593. * Adds the given action manager to this scene
  88594. * @param newActionManager The action manager to add
  88595. */
  88596. addActionManager(newActionManager: AbstractActionManager): void;
  88597. /**
  88598. * Adds the given texture to this scene.
  88599. * @param newTexture The texture to add
  88600. */
  88601. addTexture(newTexture: BaseTexture): void;
  88602. /**
  88603. * Switch active camera
  88604. * @param newCamera defines the new active camera
  88605. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  88606. */
  88607. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  88608. /**
  88609. * sets the active camera of the scene using its ID
  88610. * @param id defines the camera's ID
  88611. * @return the new active camera or null if none found.
  88612. */
  88613. setActiveCameraByID(id: string): Nullable<Camera>;
  88614. /**
  88615. * sets the active camera of the scene using its name
  88616. * @param name defines the camera's name
  88617. * @returns the new active camera or null if none found.
  88618. */
  88619. setActiveCameraByName(name: string): Nullable<Camera>;
  88620. /**
  88621. * get an animation group using its name
  88622. * @param name defines the material's name
  88623. * @return the animation group or null if none found.
  88624. */
  88625. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  88626. /**
  88627. * get a material using its id
  88628. * @param id defines the material's ID
  88629. * @return the material or null if none found.
  88630. */
  88631. getMaterialByID(id: string): Nullable<Material>;
  88632. /**
  88633. * Gets a material using its name
  88634. * @param name defines the material's name
  88635. * @return the material or null if none found.
  88636. */
  88637. getMaterialByName(name: string): Nullable<Material>;
  88638. /**
  88639. * Gets a camera using its id
  88640. * @param id defines the id to look for
  88641. * @returns the camera or null if not found
  88642. */
  88643. getCameraByID(id: string): Nullable<Camera>;
  88644. /**
  88645. * Gets a camera using its unique id
  88646. * @param uniqueId defines the unique id to look for
  88647. * @returns the camera or null if not found
  88648. */
  88649. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  88650. /**
  88651. * Gets a camera using its name
  88652. * @param name defines the camera's name
  88653. * @return the camera or null if none found.
  88654. */
  88655. getCameraByName(name: string): Nullable<Camera>;
  88656. /**
  88657. * Gets a bone using its id
  88658. * @param id defines the bone's id
  88659. * @return the bone or null if not found
  88660. */
  88661. getBoneByID(id: string): Nullable<Bone>;
  88662. /**
  88663. * Gets a bone using its id
  88664. * @param name defines the bone's name
  88665. * @return the bone or null if not found
  88666. */
  88667. getBoneByName(name: string): Nullable<Bone>;
  88668. /**
  88669. * Gets a light node using its name
  88670. * @param name defines the the light's name
  88671. * @return the light or null if none found.
  88672. */
  88673. getLightByName(name: string): Nullable<Light>;
  88674. /**
  88675. * Gets a light node using its id
  88676. * @param id defines the light's id
  88677. * @return the light or null if none found.
  88678. */
  88679. getLightByID(id: string): Nullable<Light>;
  88680. /**
  88681. * Gets a light node using its scene-generated unique ID
  88682. * @param uniqueId defines the light's unique id
  88683. * @return the light or null if none found.
  88684. */
  88685. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  88686. /**
  88687. * Gets a particle system by id
  88688. * @param id defines the particle system id
  88689. * @return the corresponding system or null if none found
  88690. */
  88691. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  88692. /**
  88693. * Gets a geometry using its ID
  88694. * @param id defines the geometry's id
  88695. * @return the geometry or null if none found.
  88696. */
  88697. getGeometryByID(id: string): Nullable<Geometry>;
  88698. private _getGeometryByUniqueID;
  88699. /**
  88700. * Add a new geometry to this scene
  88701. * @param geometry defines the geometry to be added to the scene.
  88702. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  88703. * @return a boolean defining if the geometry was added or not
  88704. */
  88705. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  88706. /**
  88707. * Removes an existing geometry
  88708. * @param geometry defines the geometry to be removed from the scene
  88709. * @return a boolean defining if the geometry was removed or not
  88710. */
  88711. removeGeometry(geometry: Geometry): boolean;
  88712. /**
  88713. * Gets the list of geometries attached to the scene
  88714. * @returns an array of Geometry
  88715. */
  88716. getGeometries(): Geometry[];
  88717. /**
  88718. * Gets the first added mesh found of a given ID
  88719. * @param id defines the id to search for
  88720. * @return the mesh found or null if not found at all
  88721. */
  88722. getMeshByID(id: string): Nullable<AbstractMesh>;
  88723. /**
  88724. * Gets a list of meshes using their id
  88725. * @param id defines the id to search for
  88726. * @returns a list of meshes
  88727. */
  88728. getMeshesByID(id: string): Array<AbstractMesh>;
  88729. /**
  88730. * Gets the first added transform node found of a given ID
  88731. * @param id defines the id to search for
  88732. * @return the found transform node or null if not found at all.
  88733. */
  88734. getTransformNodeByID(id: string): Nullable<TransformNode>;
  88735. /**
  88736. * Gets a list of transform nodes using their id
  88737. * @param id defines the id to search for
  88738. * @returns a list of transform nodes
  88739. */
  88740. getTransformNodesByID(id: string): Array<TransformNode>;
  88741. /**
  88742. * Gets a mesh with its auto-generated unique id
  88743. * @param uniqueId defines the unique id to search for
  88744. * @return the found mesh or null if not found at all.
  88745. */
  88746. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  88747. /**
  88748. * Gets a the last added mesh using a given id
  88749. * @param id defines the id to search for
  88750. * @return the found mesh or null if not found at all.
  88751. */
  88752. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  88753. /**
  88754. * Gets a the last added node (Mesh, Camera, Light) using a given id
  88755. * @param id defines the id to search for
  88756. * @return the found node or null if not found at all
  88757. */
  88758. getLastEntryByID(id: string): Nullable<Node>;
  88759. /**
  88760. * Gets a node (Mesh, Camera, Light) using a given id
  88761. * @param id defines the id to search for
  88762. * @return the found node or null if not found at all
  88763. */
  88764. getNodeByID(id: string): Nullable<Node>;
  88765. /**
  88766. * Gets a node (Mesh, Camera, Light) using a given name
  88767. * @param name defines the name to search for
  88768. * @return the found node or null if not found at all.
  88769. */
  88770. getNodeByName(name: string): Nullable<Node>;
  88771. /**
  88772. * Gets a mesh using a given name
  88773. * @param name defines the name to search for
  88774. * @return the found mesh or null if not found at all.
  88775. */
  88776. getMeshByName(name: string): Nullable<AbstractMesh>;
  88777. /**
  88778. * Gets a transform node using a given name
  88779. * @param name defines the name to search for
  88780. * @return the found transform node or null if not found at all.
  88781. */
  88782. getTransformNodeByName(name: string): Nullable<TransformNode>;
  88783. /**
  88784. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  88785. * @param id defines the id to search for
  88786. * @return the found skeleton or null if not found at all.
  88787. */
  88788. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  88789. /**
  88790. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  88791. * @param id defines the id to search for
  88792. * @return the found skeleton or null if not found at all.
  88793. */
  88794. getSkeletonById(id: string): Nullable<Skeleton>;
  88795. /**
  88796. * Gets a skeleton using a given name
  88797. * @param name defines the name to search for
  88798. * @return the found skeleton or null if not found at all.
  88799. */
  88800. getSkeletonByName(name: string): Nullable<Skeleton>;
  88801. /**
  88802. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  88803. * @param id defines the id to search for
  88804. * @return the found morph target manager or null if not found at all.
  88805. */
  88806. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  88807. /**
  88808. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  88809. * @param id defines the id to search for
  88810. * @return the found morph target or null if not found at all.
  88811. */
  88812. getMorphTargetById(id: string): Nullable<MorphTarget>;
  88813. /**
  88814. * Gets a boolean indicating if the given mesh is active
  88815. * @param mesh defines the mesh to look for
  88816. * @returns true if the mesh is in the active list
  88817. */
  88818. isActiveMesh(mesh: AbstractMesh): boolean;
  88819. /**
  88820. * Return a unique id as a string which can serve as an identifier for the scene
  88821. */
  88822. readonly uid: string;
  88823. /**
  88824. * Add an externaly attached data from its key.
  88825. * This method call will fail and return false, if such key already exists.
  88826. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88827. * @param key the unique key that identifies the data
  88828. * @param data the data object to associate to the key for this Engine instance
  88829. * @return true if no such key were already present and the data was added successfully, false otherwise
  88830. */
  88831. addExternalData<T>(key: string, data: T): boolean;
  88832. /**
  88833. * Get an externaly attached data from its key
  88834. * @param key the unique key that identifies the data
  88835. * @return the associated data, if present (can be null), or undefined if not present
  88836. */
  88837. getExternalData<T>(key: string): Nullable<T>;
  88838. /**
  88839. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88840. * @param key the unique key that identifies the data
  88841. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88842. * @return the associated data, can be null if the factory returned null.
  88843. */
  88844. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88845. /**
  88846. * Remove an externaly attached data from the Engine instance
  88847. * @param key the unique key that identifies the data
  88848. * @return true if the data was successfully removed, false if it doesn't exist
  88849. */
  88850. removeExternalData(key: string): boolean;
  88851. private _evaluateSubMesh;
  88852. /**
  88853. * Clear the processed materials smart array preventing retention point in material dispose.
  88854. */
  88855. freeProcessedMaterials(): void;
  88856. private _preventFreeActiveMeshesAndRenderingGroups;
  88857. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  88858. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  88859. * when disposing several meshes in a row or a hierarchy of meshes.
  88860. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  88861. */
  88862. blockfreeActiveMeshesAndRenderingGroups: boolean;
  88863. /**
  88864. * Clear the active meshes smart array preventing retention point in mesh dispose.
  88865. */
  88866. freeActiveMeshes(): void;
  88867. /**
  88868. * Clear the info related to rendering groups preventing retention points during dispose.
  88869. */
  88870. freeRenderingGroups(): void;
  88871. /** @hidden */
  88872. _isInIntermediateRendering(): boolean;
  88873. /**
  88874. * Lambda returning the list of potentially active meshes.
  88875. */
  88876. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  88877. /**
  88878. * Lambda returning the list of potentially active sub meshes.
  88879. */
  88880. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  88881. /**
  88882. * Lambda returning the list of potentially intersecting sub meshes.
  88883. */
  88884. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  88885. /**
  88886. * Lambda returning the list of potentially colliding sub meshes.
  88887. */
  88888. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  88889. private _activeMeshesFrozen;
  88890. /**
  88891. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  88892. * @returns the current scene
  88893. */
  88894. freezeActiveMeshes(): Scene;
  88895. /**
  88896. * Use this function to restart evaluating active meshes on every frame
  88897. * @returns the current scene
  88898. */
  88899. unfreezeActiveMeshes(): Scene;
  88900. private _evaluateActiveMeshes;
  88901. private _activeMesh;
  88902. /**
  88903. * Update the transform matrix to update from the current active camera
  88904. * @param force defines a boolean used to force the update even if cache is up to date
  88905. */
  88906. updateTransformMatrix(force?: boolean): void;
  88907. /**
  88908. * 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)
  88909. * @param alternateCamera defines the camera to use
  88910. */
  88911. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  88912. /** @hidden */
  88913. _allowPostProcessClearColor: boolean;
  88914. private _renderForCamera;
  88915. private _processSubCameras;
  88916. private _checkIntersections;
  88917. /** @hidden */
  88918. _advancePhysicsEngineStep(step: number): void;
  88919. /**
  88920. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  88921. */
  88922. getDeterministicFrameTime: () => number;
  88923. /** @hidden */
  88924. _animate(): void;
  88925. /**
  88926. * Render the scene
  88927. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  88928. */
  88929. render(updateCameras?: boolean): void;
  88930. /**
  88931. * Freeze all materials
  88932. * A frozen material will not be updatable but should be faster to render
  88933. */
  88934. freezeMaterials(): void;
  88935. /**
  88936. * Unfreeze all materials
  88937. * A frozen material will not be updatable but should be faster to render
  88938. */
  88939. unfreezeMaterials(): void;
  88940. /**
  88941. * Releases all held ressources
  88942. */
  88943. dispose(): void;
  88944. /**
  88945. * Gets if the scene is already disposed
  88946. */
  88947. readonly isDisposed: boolean;
  88948. /**
  88949. * Call this function to reduce memory footprint of the scene.
  88950. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  88951. */
  88952. clearCachedVertexData(): void;
  88953. /**
  88954. * This function will remove the local cached buffer data from texture.
  88955. * It will save memory but will prevent the texture from being rebuilt
  88956. */
  88957. cleanCachedTextureBuffer(): void;
  88958. /**
  88959. * Get the world extend vectors with an optional filter
  88960. *
  88961. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  88962. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  88963. */
  88964. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  88965. min: Vector3;
  88966. max: Vector3;
  88967. };
  88968. /**
  88969. * Creates a ray that can be used to pick in the scene
  88970. * @param x defines the x coordinate of the origin (on-screen)
  88971. * @param y defines the y coordinate of the origin (on-screen)
  88972. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88973. * @param camera defines the camera to use for the picking
  88974. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88975. * @returns a Ray
  88976. */
  88977. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  88978. /**
  88979. * Creates a ray that can be used to pick in the scene
  88980. * @param x defines the x coordinate of the origin (on-screen)
  88981. * @param y defines the y coordinate of the origin (on-screen)
  88982. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88983. * @param result defines the ray where to store the picking ray
  88984. * @param camera defines the camera to use for the picking
  88985. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88986. * @returns the current scene
  88987. */
  88988. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  88989. /**
  88990. * Creates a ray that can be used to pick in the scene
  88991. * @param x defines the x coordinate of the origin (on-screen)
  88992. * @param y defines the y coordinate of the origin (on-screen)
  88993. * @param camera defines the camera to use for the picking
  88994. * @returns a Ray
  88995. */
  88996. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  88997. /**
  88998. * Creates a ray that can be used to pick in the scene
  88999. * @param x defines the x coordinate of the origin (on-screen)
  89000. * @param y defines the y coordinate of the origin (on-screen)
  89001. * @param result defines the ray where to store the picking ray
  89002. * @param camera defines the camera to use for the picking
  89003. * @returns the current scene
  89004. */
  89005. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  89006. /** Launch a ray to try to pick a mesh in the scene
  89007. * @param x position on screen
  89008. * @param y position on screen
  89009. * @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
  89010. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  89011. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89012. * @returns a PickingInfo
  89013. */
  89014. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  89015. /** Use the given ray to pick a mesh in the scene
  89016. * @param ray The ray to use to pick meshes
  89017. * @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
  89018. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  89019. * @returns a PickingInfo
  89020. */
  89021. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89022. /**
  89023. * Launch a ray to try to pick a mesh in the scene
  89024. * @param x X position on screen
  89025. * @param y Y position on screen
  89026. * @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
  89027. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89028. * @returns an array of PickingInfo
  89029. */
  89030. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89031. /**
  89032. * Launch a ray to try to pick a mesh in the scene
  89033. * @param ray Ray to use
  89034. * @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
  89035. * @returns an array of PickingInfo
  89036. */
  89037. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  89038. /**
  89039. * Force the value of meshUnderPointer
  89040. * @param mesh defines the mesh to use
  89041. */
  89042. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  89043. /**
  89044. * Gets the mesh under the pointer
  89045. * @returns a Mesh or null if no mesh is under the pointer
  89046. */
  89047. getPointerOverMesh(): Nullable<AbstractMesh>;
  89048. /** @hidden */
  89049. _rebuildGeometries(): void;
  89050. /** @hidden */
  89051. _rebuildTextures(): void;
  89052. private _getByTags;
  89053. /**
  89054. * Get a list of meshes by tags
  89055. * @param tagsQuery defines the tags query to use
  89056. * @param forEach defines a predicate used to filter results
  89057. * @returns an array of Mesh
  89058. */
  89059. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  89060. /**
  89061. * Get a list of cameras by tags
  89062. * @param tagsQuery defines the tags query to use
  89063. * @param forEach defines a predicate used to filter results
  89064. * @returns an array of Camera
  89065. */
  89066. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  89067. /**
  89068. * Get a list of lights by tags
  89069. * @param tagsQuery defines the tags query to use
  89070. * @param forEach defines a predicate used to filter results
  89071. * @returns an array of Light
  89072. */
  89073. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89074. /**
  89075. * Get a list of materials by tags
  89076. * @param tagsQuery defines the tags query to use
  89077. * @param forEach defines a predicate used to filter results
  89078. * @returns an array of Material
  89079. */
  89080. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89081. /**
  89082. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89083. * This allowed control for front to back rendering or reversly depending of the special needs.
  89084. *
  89085. * @param renderingGroupId The rendering group id corresponding to its index
  89086. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89087. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89088. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89089. */
  89090. 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;
  89091. /**
  89092. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89093. *
  89094. * @param renderingGroupId The rendering group id corresponding to its index
  89095. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89096. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89097. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89098. */
  89099. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89100. /**
  89101. * Gets the current auto clear configuration for one rendering group of the rendering
  89102. * manager.
  89103. * @param index the rendering group index to get the information for
  89104. * @returns The auto clear setup for the requested rendering group
  89105. */
  89106. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89107. private _blockMaterialDirtyMechanism;
  89108. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89109. blockMaterialDirtyMechanism: boolean;
  89110. /**
  89111. * Will flag all materials as dirty to trigger new shader compilation
  89112. * @param flag defines the flag used to specify which material part must be marked as dirty
  89113. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89114. */
  89115. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89116. /** @hidden */
  89117. _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;
  89118. /** @hidden */
  89119. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89120. }
  89121. }
  89122. declare module BABYLON {
  89123. /**
  89124. * Set of assets to keep when moving a scene into an asset container.
  89125. */
  89126. export class KeepAssets extends AbstractScene {
  89127. }
  89128. /**
  89129. * Container with a set of assets that can be added or removed from a scene.
  89130. */
  89131. export class AssetContainer extends AbstractScene {
  89132. /**
  89133. * The scene the AssetContainer belongs to.
  89134. */
  89135. scene: Scene;
  89136. /**
  89137. * Instantiates an AssetContainer.
  89138. * @param scene The scene the AssetContainer belongs to.
  89139. */
  89140. constructor(scene: Scene);
  89141. /**
  89142. * Adds all the assets from the container to the scene.
  89143. */
  89144. addAllToScene(): void;
  89145. /**
  89146. * Removes all the assets in the container from the scene
  89147. */
  89148. removeAllFromScene(): void;
  89149. /**
  89150. * Disposes all the assets in the container
  89151. */
  89152. dispose(): void;
  89153. private _moveAssets;
  89154. /**
  89155. * Removes all the assets contained in the scene and adds them to the container.
  89156. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89157. */
  89158. moveAllFromScene(keepAssets?: KeepAssets): void;
  89159. /**
  89160. * 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.
  89161. * @returns the root mesh
  89162. */
  89163. createRootMesh(): Mesh;
  89164. }
  89165. }
  89166. declare module BABYLON {
  89167. /**
  89168. * Defines how the parser contract is defined.
  89169. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89170. */
  89171. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89172. /**
  89173. * Defines how the individual parser contract is defined.
  89174. * These parser can parse an individual asset
  89175. */
  89176. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89177. /**
  89178. * Base class of the scene acting as a container for the different elements composing a scene.
  89179. * This class is dynamically extended by the different components of the scene increasing
  89180. * flexibility and reducing coupling
  89181. */
  89182. export abstract class AbstractScene {
  89183. /**
  89184. * Stores the list of available parsers in the application.
  89185. */
  89186. private static _BabylonFileParsers;
  89187. /**
  89188. * Stores the list of available individual parsers in the application.
  89189. */
  89190. private static _IndividualBabylonFileParsers;
  89191. /**
  89192. * Adds a parser in the list of available ones
  89193. * @param name Defines the name of the parser
  89194. * @param parser Defines the parser to add
  89195. */
  89196. static AddParser(name: string, parser: BabylonFileParser): void;
  89197. /**
  89198. * Gets a general parser from the list of avaialble ones
  89199. * @param name Defines the name of the parser
  89200. * @returns the requested parser or null
  89201. */
  89202. static GetParser(name: string): Nullable<BabylonFileParser>;
  89203. /**
  89204. * Adds n individual parser in the list of available ones
  89205. * @param name Defines the name of the parser
  89206. * @param parser Defines the parser to add
  89207. */
  89208. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89209. /**
  89210. * Gets an individual parser from the list of avaialble ones
  89211. * @param name Defines the name of the parser
  89212. * @returns the requested parser or null
  89213. */
  89214. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89215. /**
  89216. * Parser json data and populate both a scene and its associated container object
  89217. * @param jsonData Defines the data to parse
  89218. * @param scene Defines the scene to parse the data for
  89219. * @param container Defines the container attached to the parsing sequence
  89220. * @param rootUrl Defines the root url of the data
  89221. */
  89222. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89223. /**
  89224. * Gets the list of root nodes (ie. nodes with no parent)
  89225. */
  89226. rootNodes: Node[];
  89227. /** All of the cameras added to this scene
  89228. * @see http://doc.babylonjs.com/babylon101/cameras
  89229. */
  89230. cameras: Camera[];
  89231. /**
  89232. * All of the lights added to this scene
  89233. * @see http://doc.babylonjs.com/babylon101/lights
  89234. */
  89235. lights: Light[];
  89236. /**
  89237. * All of the (abstract) meshes added to this scene
  89238. */
  89239. meshes: AbstractMesh[];
  89240. /**
  89241. * The list of skeletons added to the scene
  89242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89243. */
  89244. skeletons: Skeleton[];
  89245. /**
  89246. * All of the particle systems added to this scene
  89247. * @see http://doc.babylonjs.com/babylon101/particles
  89248. */
  89249. particleSystems: IParticleSystem[];
  89250. /**
  89251. * Gets a list of Animations associated with the scene
  89252. */
  89253. animations: Animation[];
  89254. /**
  89255. * All of the animation groups added to this scene
  89256. * @see http://doc.babylonjs.com/how_to/group
  89257. */
  89258. animationGroups: AnimationGroup[];
  89259. /**
  89260. * All of the multi-materials added to this scene
  89261. * @see http://doc.babylonjs.com/how_to/multi_materials
  89262. */
  89263. multiMaterials: MultiMaterial[];
  89264. /**
  89265. * All of the materials added to this scene
  89266. * In the context of a Scene, it is not supposed to be modified manually.
  89267. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89268. * Note also that the order of the Material wihin the array is not significant and might change.
  89269. * @see http://doc.babylonjs.com/babylon101/materials
  89270. */
  89271. materials: Material[];
  89272. /**
  89273. * The list of morph target managers added to the scene
  89274. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89275. */
  89276. morphTargetManagers: MorphTargetManager[];
  89277. /**
  89278. * The list of geometries used in the scene.
  89279. */
  89280. geometries: Geometry[];
  89281. /**
  89282. * All of the tranform nodes added to this scene
  89283. * In the context of a Scene, it is not supposed to be modified manually.
  89284. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89285. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89286. * @see http://doc.babylonjs.com/how_to/transformnode
  89287. */
  89288. transformNodes: TransformNode[];
  89289. /**
  89290. * ActionManagers available on the scene.
  89291. */
  89292. actionManagers: AbstractActionManager[];
  89293. /**
  89294. * Textures to keep.
  89295. */
  89296. textures: BaseTexture[];
  89297. }
  89298. }
  89299. declare module BABYLON {
  89300. /**
  89301. * Defines a sound that can be played in the application.
  89302. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89304. */
  89305. export class Sound {
  89306. /**
  89307. * The name of the sound in the scene.
  89308. */
  89309. name: string;
  89310. /**
  89311. * Does the sound autoplay once loaded.
  89312. */
  89313. autoplay: boolean;
  89314. /**
  89315. * Does the sound loop after it finishes playing once.
  89316. */
  89317. loop: boolean;
  89318. /**
  89319. * Does the sound use a custom attenuation curve to simulate the falloff
  89320. * happening when the source gets further away from the camera.
  89321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89322. */
  89323. useCustomAttenuation: boolean;
  89324. /**
  89325. * The sound track id this sound belongs to.
  89326. */
  89327. soundTrackId: number;
  89328. /**
  89329. * Is this sound currently played.
  89330. */
  89331. isPlaying: boolean;
  89332. /**
  89333. * Is this sound currently paused.
  89334. */
  89335. isPaused: boolean;
  89336. /**
  89337. * Does this sound enables spatial sound.
  89338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89339. */
  89340. spatialSound: boolean;
  89341. /**
  89342. * Define the reference distance the sound should be heard perfectly.
  89343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89344. */
  89345. refDistance: number;
  89346. /**
  89347. * Define the roll off factor of spatial sounds.
  89348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89349. */
  89350. rolloffFactor: number;
  89351. /**
  89352. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89354. */
  89355. maxDistance: number;
  89356. /**
  89357. * Define the distance attenuation model the sound will follow.
  89358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89359. */
  89360. distanceModel: string;
  89361. /**
  89362. * @hidden
  89363. * Back Compat
  89364. **/
  89365. onended: () => any;
  89366. /**
  89367. * Observable event when the current playing sound finishes.
  89368. */
  89369. onEndedObservable: Observable<Sound>;
  89370. private _panningModel;
  89371. private _playbackRate;
  89372. private _streaming;
  89373. private _startTime;
  89374. private _startOffset;
  89375. private _position;
  89376. /** @hidden */
  89377. _positionInEmitterSpace: boolean;
  89378. private _localDirection;
  89379. private _volume;
  89380. private _isReadyToPlay;
  89381. private _isDirectional;
  89382. private _readyToPlayCallback;
  89383. private _audioBuffer;
  89384. private _soundSource;
  89385. private _streamingSource;
  89386. private _soundPanner;
  89387. private _soundGain;
  89388. private _inputAudioNode;
  89389. private _outputAudioNode;
  89390. private _coneInnerAngle;
  89391. private _coneOuterAngle;
  89392. private _coneOuterGain;
  89393. private _scene;
  89394. private _connectedTransformNode;
  89395. private _customAttenuationFunction;
  89396. private _registerFunc;
  89397. private _isOutputConnected;
  89398. private _htmlAudioElement;
  89399. private _urlType;
  89400. /** @hidden */
  89401. static _SceneComponentInitialization: (scene: Scene) => void;
  89402. /**
  89403. * Create a sound and attach it to a scene
  89404. * @param name Name of your sound
  89405. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89406. * @param scene defines the scene the sound belongs to
  89407. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89408. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89409. */
  89410. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89411. /**
  89412. * Release the sound and its associated resources
  89413. */
  89414. dispose(): void;
  89415. /**
  89416. * Gets if the sounds is ready to be played or not.
  89417. * @returns true if ready, otherwise false
  89418. */
  89419. isReady(): boolean;
  89420. private _soundLoaded;
  89421. /**
  89422. * Sets the data of the sound from an audiobuffer
  89423. * @param audioBuffer The audioBuffer containing the data
  89424. */
  89425. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89426. /**
  89427. * Updates the current sounds options such as maxdistance, loop...
  89428. * @param options A JSON object containing values named as the object properties
  89429. */
  89430. updateOptions(options: any): void;
  89431. private _createSpatialParameters;
  89432. private _updateSpatialParameters;
  89433. /**
  89434. * Switch the panning model to HRTF:
  89435. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89437. */
  89438. switchPanningModelToHRTF(): void;
  89439. /**
  89440. * Switch the panning model to Equal Power:
  89441. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89443. */
  89444. switchPanningModelToEqualPower(): void;
  89445. private _switchPanningModel;
  89446. /**
  89447. * Connect this sound to a sound track audio node like gain...
  89448. * @param soundTrackAudioNode the sound track audio node to connect to
  89449. */
  89450. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89451. /**
  89452. * Transform this sound into a directional source
  89453. * @param coneInnerAngle Size of the inner cone in degree
  89454. * @param coneOuterAngle Size of the outer cone in degree
  89455. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89456. */
  89457. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89458. /**
  89459. * Gets or sets the inner angle for the directional cone.
  89460. */
  89461. /**
  89462. * Gets or sets the inner angle for the directional cone.
  89463. */
  89464. directionalConeInnerAngle: number;
  89465. /**
  89466. * Gets or sets the outer angle for the directional cone.
  89467. */
  89468. /**
  89469. * Gets or sets the outer angle for the directional cone.
  89470. */
  89471. directionalConeOuterAngle: number;
  89472. /**
  89473. * Sets the position of the emitter if spatial sound is enabled
  89474. * @param newPosition Defines the new posisiton
  89475. */
  89476. setPosition(newPosition: Vector3): void;
  89477. /**
  89478. * Sets the local direction of the emitter if spatial sound is enabled
  89479. * @param newLocalDirection Defines the new local direction
  89480. */
  89481. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89482. private _updateDirection;
  89483. /** @hidden */
  89484. updateDistanceFromListener(): void;
  89485. /**
  89486. * Sets a new custom attenuation function for the sound.
  89487. * @param callback Defines the function used for the attenuation
  89488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89489. */
  89490. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89491. /**
  89492. * Play the sound
  89493. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89494. * @param offset (optional) Start the sound setting it at a specific time
  89495. */
  89496. play(time?: number, offset?: number): void;
  89497. private _onended;
  89498. /**
  89499. * Stop the sound
  89500. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89501. */
  89502. stop(time?: number): void;
  89503. /**
  89504. * Put the sound in pause
  89505. */
  89506. pause(): void;
  89507. /**
  89508. * Sets a dedicated volume for this sounds
  89509. * @param newVolume Define the new volume of the sound
  89510. * @param time Define in how long the sound should be at this value
  89511. */
  89512. setVolume(newVolume: number, time?: number): void;
  89513. /**
  89514. * Set the sound play back rate
  89515. * @param newPlaybackRate Define the playback rate the sound should be played at
  89516. */
  89517. setPlaybackRate(newPlaybackRate: number): void;
  89518. /**
  89519. * Gets the volume of the sound.
  89520. * @returns the volume of the sound
  89521. */
  89522. getVolume(): number;
  89523. /**
  89524. * Attach the sound to a dedicated mesh
  89525. * @param transformNode The transform node to connect the sound with
  89526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89527. */
  89528. attachToMesh(transformNode: TransformNode): void;
  89529. /**
  89530. * Detach the sound from the previously attached mesh
  89531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89532. */
  89533. detachFromMesh(): void;
  89534. private _onRegisterAfterWorldMatrixUpdate;
  89535. /**
  89536. * Clone the current sound in the scene.
  89537. * @returns the new sound clone
  89538. */
  89539. clone(): Nullable<Sound>;
  89540. /**
  89541. * Gets the current underlying audio buffer containing the data
  89542. * @returns the audio buffer
  89543. */
  89544. getAudioBuffer(): Nullable<AudioBuffer>;
  89545. /**
  89546. * Serializes the Sound in a JSON representation
  89547. * @returns the JSON representation of the sound
  89548. */
  89549. serialize(): any;
  89550. /**
  89551. * Parse a JSON representation of a sound to innstantiate in a given scene
  89552. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  89553. * @param scene Define the scene the new parsed sound should be created in
  89554. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  89555. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  89556. * @returns the newly parsed sound
  89557. */
  89558. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  89559. }
  89560. }
  89561. declare module BABYLON {
  89562. /**
  89563. * This defines an action helpful to play a defined sound on a triggered action.
  89564. */
  89565. export class PlaySoundAction extends Action {
  89566. private _sound;
  89567. /**
  89568. * Instantiate the action
  89569. * @param triggerOptions defines the trigger options
  89570. * @param sound defines the sound to play
  89571. * @param condition defines the trigger related conditions
  89572. */
  89573. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89574. /** @hidden */
  89575. _prepare(): void;
  89576. /**
  89577. * Execute the action and play the sound.
  89578. */
  89579. execute(): void;
  89580. /**
  89581. * Serializes the actions and its related information.
  89582. * @param parent defines the object to serialize in
  89583. * @returns the serialized object
  89584. */
  89585. serialize(parent: any): any;
  89586. }
  89587. /**
  89588. * This defines an action helpful to stop a defined sound on a triggered action.
  89589. */
  89590. export class StopSoundAction extends Action {
  89591. private _sound;
  89592. /**
  89593. * Instantiate the action
  89594. * @param triggerOptions defines the trigger options
  89595. * @param sound defines the sound to stop
  89596. * @param condition defines the trigger related conditions
  89597. */
  89598. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89599. /** @hidden */
  89600. _prepare(): void;
  89601. /**
  89602. * Execute the action and stop the sound.
  89603. */
  89604. execute(): void;
  89605. /**
  89606. * Serializes the actions and its related information.
  89607. * @param parent defines the object to serialize in
  89608. * @returns the serialized object
  89609. */
  89610. serialize(parent: any): any;
  89611. }
  89612. }
  89613. declare module BABYLON {
  89614. /**
  89615. * This defines an action responsible to change the value of a property
  89616. * by interpolating between its current value and the newly set one once triggered.
  89617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89618. */
  89619. export class InterpolateValueAction extends Action {
  89620. /**
  89621. * Defines the path of the property where the value should be interpolated
  89622. */
  89623. propertyPath: string;
  89624. /**
  89625. * Defines the target value at the end of the interpolation.
  89626. */
  89627. value: any;
  89628. /**
  89629. * Defines the time it will take for the property to interpolate to the value.
  89630. */
  89631. duration: number;
  89632. /**
  89633. * Defines if the other scene animations should be stopped when the action has been triggered
  89634. */
  89635. stopOtherAnimations?: boolean;
  89636. /**
  89637. * Defines a callback raised once the interpolation animation has been done.
  89638. */
  89639. onInterpolationDone?: () => void;
  89640. /**
  89641. * Observable triggered once the interpolation animation has been done.
  89642. */
  89643. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  89644. private _target;
  89645. private _effectiveTarget;
  89646. private _property;
  89647. /**
  89648. * Instantiate the action
  89649. * @param triggerOptions defines the trigger options
  89650. * @param target defines the object containing the value to interpolate
  89651. * @param propertyPath defines the path to the property in the target object
  89652. * @param value defines the target value at the end of the interpolation
  89653. * @param duration deines the time it will take for the property to interpolate to the value.
  89654. * @param condition defines the trigger related conditions
  89655. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  89656. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  89657. */
  89658. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  89659. /** @hidden */
  89660. _prepare(): void;
  89661. /**
  89662. * Execute the action starts the value interpolation.
  89663. */
  89664. execute(): void;
  89665. /**
  89666. * Serializes the actions and its related information.
  89667. * @param parent defines the object to serialize in
  89668. * @returns the serialized object
  89669. */
  89670. serialize(parent: any): any;
  89671. }
  89672. }
  89673. declare module BABYLON {
  89674. /**
  89675. * Options allowed during the creation of a sound track.
  89676. */
  89677. export interface ISoundTrackOptions {
  89678. /**
  89679. * The volume the sound track should take during creation
  89680. */
  89681. volume?: number;
  89682. /**
  89683. * Define if the sound track is the main sound track of the scene
  89684. */
  89685. mainTrack?: boolean;
  89686. }
  89687. /**
  89688. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  89689. * It will be also used in a future release to apply effects on a specific track.
  89690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89691. */
  89692. export class SoundTrack {
  89693. /**
  89694. * The unique identifier of the sound track in the scene.
  89695. */
  89696. id: number;
  89697. /**
  89698. * The list of sounds included in the sound track.
  89699. */
  89700. soundCollection: Array<Sound>;
  89701. private _outputAudioNode;
  89702. private _scene;
  89703. private _isMainTrack;
  89704. private _connectedAnalyser;
  89705. private _options;
  89706. private _isInitialized;
  89707. /**
  89708. * Creates a new sound track.
  89709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89710. * @param scene Define the scene the sound track belongs to
  89711. * @param options
  89712. */
  89713. constructor(scene: Scene, options?: ISoundTrackOptions);
  89714. private _initializeSoundTrackAudioGraph;
  89715. /**
  89716. * Release the sound track and its associated resources
  89717. */
  89718. dispose(): void;
  89719. /**
  89720. * Adds a sound to this sound track
  89721. * @param sound define the cound to add
  89722. * @ignoreNaming
  89723. */
  89724. AddSound(sound: Sound): void;
  89725. /**
  89726. * Removes a sound to this sound track
  89727. * @param sound define the cound to remove
  89728. * @ignoreNaming
  89729. */
  89730. RemoveSound(sound: Sound): void;
  89731. /**
  89732. * Set a global volume for the full sound track.
  89733. * @param newVolume Define the new volume of the sound track
  89734. */
  89735. setVolume(newVolume: number): void;
  89736. /**
  89737. * Switch the panning model to HRTF:
  89738. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89740. */
  89741. switchPanningModelToHRTF(): void;
  89742. /**
  89743. * Switch the panning model to Equal Power:
  89744. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89746. */
  89747. switchPanningModelToEqualPower(): void;
  89748. /**
  89749. * Connect the sound track to an audio analyser allowing some amazing
  89750. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89752. * @param analyser The analyser to connect to the engine
  89753. */
  89754. connectToAnalyser(analyser: Analyser): void;
  89755. }
  89756. }
  89757. declare module BABYLON {
  89758. interface AbstractScene {
  89759. /**
  89760. * The list of sounds used in the scene.
  89761. */
  89762. sounds: Nullable<Array<Sound>>;
  89763. }
  89764. interface Scene {
  89765. /**
  89766. * @hidden
  89767. * Backing field
  89768. */
  89769. _mainSoundTrack: SoundTrack;
  89770. /**
  89771. * The main sound track played by the scene.
  89772. * It cotains your primary collection of sounds.
  89773. */
  89774. mainSoundTrack: SoundTrack;
  89775. /**
  89776. * The list of sound tracks added to the scene
  89777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89778. */
  89779. soundTracks: Nullable<Array<SoundTrack>>;
  89780. /**
  89781. * Gets a sound using a given name
  89782. * @param name defines the name to search for
  89783. * @return the found sound or null if not found at all.
  89784. */
  89785. getSoundByName(name: string): Nullable<Sound>;
  89786. /**
  89787. * Gets or sets if audio support is enabled
  89788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89789. */
  89790. audioEnabled: boolean;
  89791. /**
  89792. * Gets or sets if audio will be output to headphones
  89793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89794. */
  89795. headphone: boolean;
  89796. }
  89797. /**
  89798. * Defines the sound scene component responsible to manage any sounds
  89799. * in a given scene.
  89800. */
  89801. export class AudioSceneComponent implements ISceneSerializableComponent {
  89802. /**
  89803. * The component name helpfull to identify the component in the list of scene components.
  89804. */
  89805. readonly name: string;
  89806. /**
  89807. * The scene the component belongs to.
  89808. */
  89809. scene: Scene;
  89810. private _audioEnabled;
  89811. /**
  89812. * Gets whether audio is enabled or not.
  89813. * Please use related enable/disable method to switch state.
  89814. */
  89815. readonly audioEnabled: boolean;
  89816. private _headphone;
  89817. /**
  89818. * Gets whether audio is outputing to headphone or not.
  89819. * Please use the according Switch methods to change output.
  89820. */
  89821. readonly headphone: boolean;
  89822. /**
  89823. * Creates a new instance of the component for the given scene
  89824. * @param scene Defines the scene to register the component in
  89825. */
  89826. constructor(scene: Scene);
  89827. /**
  89828. * Registers the component in a given scene
  89829. */
  89830. register(): void;
  89831. /**
  89832. * Rebuilds the elements related to this component in case of
  89833. * context lost for instance.
  89834. */
  89835. rebuild(): void;
  89836. /**
  89837. * Serializes the component data to the specified json object
  89838. * @param serializationObject The object to serialize to
  89839. */
  89840. serialize(serializationObject: any): void;
  89841. /**
  89842. * Adds all the element from the container to the scene
  89843. * @param container the container holding the elements
  89844. */
  89845. addFromContainer(container: AbstractScene): void;
  89846. /**
  89847. * Removes all the elements in the container from the scene
  89848. * @param container contains the elements to remove
  89849. */
  89850. removeFromContainer(container: AbstractScene): void;
  89851. /**
  89852. * Disposes the component and the associated ressources.
  89853. */
  89854. dispose(): void;
  89855. /**
  89856. * Disables audio in the associated scene.
  89857. */
  89858. disableAudio(): void;
  89859. /**
  89860. * Enables audio in the associated scene.
  89861. */
  89862. enableAudio(): void;
  89863. /**
  89864. * Switch audio to headphone output.
  89865. */
  89866. switchAudioModeForHeadphones(): void;
  89867. /**
  89868. * Switch audio to normal speakers.
  89869. */
  89870. switchAudioModeForNormalSpeakers(): void;
  89871. private _afterRender;
  89872. }
  89873. }
  89874. declare module BABYLON {
  89875. /**
  89876. * Wraps one or more Sound objects and selects one with random weight for playback.
  89877. */
  89878. export class WeightedSound {
  89879. /** When true a Sound will be selected and played when the current playing Sound completes. */
  89880. loop: boolean;
  89881. private _coneInnerAngle;
  89882. private _coneOuterAngle;
  89883. private _volume;
  89884. /** A Sound is currently playing. */
  89885. isPlaying: boolean;
  89886. /** A Sound is currently paused. */
  89887. isPaused: boolean;
  89888. private _sounds;
  89889. private _weights;
  89890. private _currentIndex?;
  89891. /**
  89892. * Creates a new WeightedSound from the list of sounds given.
  89893. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  89894. * @param sounds Array of Sounds that will be selected from.
  89895. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  89896. */
  89897. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  89898. /**
  89899. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  89900. */
  89901. /**
  89902. * The size of cone in degress for a directional sound in which there will be no attenuation.
  89903. */
  89904. directionalConeInnerAngle: number;
  89905. /**
  89906. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89907. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89908. */
  89909. /**
  89910. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89911. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89912. */
  89913. directionalConeOuterAngle: number;
  89914. /**
  89915. * Playback volume.
  89916. */
  89917. /**
  89918. * Playback volume.
  89919. */
  89920. volume: number;
  89921. private _onended;
  89922. /**
  89923. * Suspend playback
  89924. */
  89925. pause(): void;
  89926. /**
  89927. * Stop playback
  89928. */
  89929. stop(): void;
  89930. /**
  89931. * Start playback.
  89932. * @param startOffset Position the clip head at a specific time in seconds.
  89933. */
  89934. play(startOffset?: number): void;
  89935. }
  89936. }
  89937. declare module BABYLON {
  89938. /**
  89939. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  89940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  89941. */
  89942. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  89943. /**
  89944. * Gets the name of the behavior.
  89945. */
  89946. readonly name: string;
  89947. /**
  89948. * The easing function used by animations
  89949. */
  89950. static EasingFunction: BackEase;
  89951. /**
  89952. * The easing mode used by animations
  89953. */
  89954. static EasingMode: number;
  89955. /**
  89956. * The duration of the animation, in milliseconds
  89957. */
  89958. transitionDuration: number;
  89959. /**
  89960. * Length of the distance animated by the transition when lower radius is reached
  89961. */
  89962. lowerRadiusTransitionRange: number;
  89963. /**
  89964. * Length of the distance animated by the transition when upper radius is reached
  89965. */
  89966. upperRadiusTransitionRange: number;
  89967. private _autoTransitionRange;
  89968. /**
  89969. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89970. */
  89971. /**
  89972. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89973. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  89974. */
  89975. autoTransitionRange: boolean;
  89976. private _attachedCamera;
  89977. private _onAfterCheckInputsObserver;
  89978. private _onMeshTargetChangedObserver;
  89979. /**
  89980. * Initializes the behavior.
  89981. */
  89982. init(): void;
  89983. /**
  89984. * Attaches the behavior to its arc rotate camera.
  89985. * @param camera Defines the camera to attach the behavior to
  89986. */
  89987. attach(camera: ArcRotateCamera): void;
  89988. /**
  89989. * Detaches the behavior from its current arc rotate camera.
  89990. */
  89991. detach(): void;
  89992. private _radiusIsAnimating;
  89993. private _radiusBounceTransition;
  89994. private _animatables;
  89995. private _cachedWheelPrecision;
  89996. /**
  89997. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  89998. * @param radiusLimit The limit to check against.
  89999. * @return Bool to indicate if at limit.
  90000. */
  90001. private _isRadiusAtLimit;
  90002. /**
  90003. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  90004. * @param radiusDelta The delta by which to animate to. Can be negative.
  90005. */
  90006. private _applyBoundRadiusAnimation;
  90007. /**
  90008. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  90009. */
  90010. protected _clearAnimationLocks(): void;
  90011. /**
  90012. * Stops and removes all animations that have been applied to the camera
  90013. */
  90014. stopAllAnimations(): void;
  90015. }
  90016. }
  90017. declare module BABYLON {
  90018. /**
  90019. * 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.
  90020. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90021. */
  90022. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  90023. /**
  90024. * Gets the name of the behavior.
  90025. */
  90026. readonly name: string;
  90027. private _mode;
  90028. private _radiusScale;
  90029. private _positionScale;
  90030. private _defaultElevation;
  90031. private _elevationReturnTime;
  90032. private _elevationReturnWaitTime;
  90033. private _zoomStopsAnimation;
  90034. private _framingTime;
  90035. /**
  90036. * The easing function used by animations
  90037. */
  90038. static EasingFunction: ExponentialEase;
  90039. /**
  90040. * The easing mode used by animations
  90041. */
  90042. static EasingMode: number;
  90043. /**
  90044. * Sets the current mode used by the behavior
  90045. */
  90046. /**
  90047. * Gets current mode used by the behavior.
  90048. */
  90049. mode: number;
  90050. /**
  90051. * Sets the scale applied to the radius (1 by default)
  90052. */
  90053. /**
  90054. * Gets the scale applied to the radius
  90055. */
  90056. radiusScale: number;
  90057. /**
  90058. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90059. */
  90060. /**
  90061. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90062. */
  90063. positionScale: number;
  90064. /**
  90065. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90066. * behaviour is triggered, in radians.
  90067. */
  90068. /**
  90069. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90070. * behaviour is triggered, in radians.
  90071. */
  90072. defaultElevation: number;
  90073. /**
  90074. * Sets the time (in milliseconds) taken to return to the default beta position.
  90075. * Negative value indicates camera should not return to default.
  90076. */
  90077. /**
  90078. * Gets the time (in milliseconds) taken to return to the default beta position.
  90079. * Negative value indicates camera should not return to default.
  90080. */
  90081. elevationReturnTime: number;
  90082. /**
  90083. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90084. */
  90085. /**
  90086. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90087. */
  90088. elevationReturnWaitTime: number;
  90089. /**
  90090. * Sets the flag that indicates if user zooming should stop animation.
  90091. */
  90092. /**
  90093. * Gets the flag that indicates if user zooming should stop animation.
  90094. */
  90095. zoomStopsAnimation: boolean;
  90096. /**
  90097. * Sets the transition time when framing the mesh, in milliseconds
  90098. */
  90099. /**
  90100. * Gets the transition time when framing the mesh, in milliseconds
  90101. */
  90102. framingTime: number;
  90103. /**
  90104. * Define if the behavior should automatically change the configured
  90105. * camera limits and sensibilities.
  90106. */
  90107. autoCorrectCameraLimitsAndSensibility: boolean;
  90108. private _onPrePointerObservableObserver;
  90109. private _onAfterCheckInputsObserver;
  90110. private _onMeshTargetChangedObserver;
  90111. private _attachedCamera;
  90112. private _isPointerDown;
  90113. private _lastInteractionTime;
  90114. /**
  90115. * Initializes the behavior.
  90116. */
  90117. init(): void;
  90118. /**
  90119. * Attaches the behavior to its arc rotate camera.
  90120. * @param camera Defines the camera to attach the behavior to
  90121. */
  90122. attach(camera: ArcRotateCamera): void;
  90123. /**
  90124. * Detaches the behavior from its current arc rotate camera.
  90125. */
  90126. detach(): void;
  90127. private _animatables;
  90128. private _betaIsAnimating;
  90129. private _betaTransition;
  90130. private _radiusTransition;
  90131. private _vectorTransition;
  90132. /**
  90133. * Targets the given mesh and updates zoom level accordingly.
  90134. * @param mesh The mesh to target.
  90135. * @param radius Optional. If a cached radius position already exists, overrides default.
  90136. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90137. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90138. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90139. */
  90140. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90141. /**
  90142. * Targets the given mesh with its children and updates zoom level accordingly.
  90143. * @param mesh The mesh to target.
  90144. * @param radius Optional. If a cached radius position already exists, overrides default.
  90145. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90146. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90147. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90148. */
  90149. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90150. /**
  90151. * Targets the given meshes with their children and updates zoom level accordingly.
  90152. * @param meshes The mesh to target.
  90153. * @param radius Optional. If a cached radius position already exists, overrides default.
  90154. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90155. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90156. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90157. */
  90158. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90159. /**
  90160. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90161. * @param minimumWorld Determines the smaller position of the bounding box extend
  90162. * @param maximumWorld Determines the bigger position of the bounding box extend
  90163. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90164. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90165. */
  90166. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90167. /**
  90168. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90169. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90170. * frustum width.
  90171. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90172. * to fully enclose the mesh in the viewing frustum.
  90173. */
  90174. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90175. /**
  90176. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90177. * is automatically returned to its default position (expected to be above ground plane).
  90178. */
  90179. private _maintainCameraAboveGround;
  90180. /**
  90181. * Returns the frustum slope based on the canvas ratio and camera FOV
  90182. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90183. */
  90184. private _getFrustumSlope;
  90185. /**
  90186. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90187. */
  90188. private _clearAnimationLocks;
  90189. /**
  90190. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90191. */
  90192. private _applyUserInteraction;
  90193. /**
  90194. * Stops and removes all animations that have been applied to the camera
  90195. */
  90196. stopAllAnimations(): void;
  90197. /**
  90198. * Gets a value indicating if the user is moving the camera
  90199. */
  90200. readonly isUserIsMoving: boolean;
  90201. /**
  90202. * The camera can move all the way towards the mesh.
  90203. */
  90204. static IgnoreBoundsSizeMode: number;
  90205. /**
  90206. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90207. */
  90208. static FitFrustumSidesMode: number;
  90209. }
  90210. }
  90211. declare module BABYLON {
  90212. /**
  90213. * Manage the pointers inputs to control an arc rotate camera.
  90214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90215. */
  90216. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90217. /**
  90218. * Defines the camera the input is attached to.
  90219. */
  90220. camera: ArcRotateCamera;
  90221. /**
  90222. * Defines the buttons associated with the input to handle camera move.
  90223. */
  90224. buttons: number[];
  90225. /**
  90226. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90227. */
  90228. angularSensibilityX: number;
  90229. /**
  90230. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90231. */
  90232. angularSensibilityY: number;
  90233. /**
  90234. * Defines the pointer pinch precision or how fast is the camera zooming.
  90235. */
  90236. pinchPrecision: number;
  90237. /**
  90238. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90239. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90240. */
  90241. pinchDeltaPercentage: number;
  90242. /**
  90243. * Defines the pointer panning sensibility or how fast is the camera moving.
  90244. */
  90245. panningSensibility: number;
  90246. /**
  90247. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90248. */
  90249. multiTouchPanning: boolean;
  90250. /**
  90251. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90252. */
  90253. multiTouchPanAndZoom: boolean;
  90254. /**
  90255. * Revers pinch action direction.
  90256. */
  90257. pinchInwards: boolean;
  90258. private _isPanClick;
  90259. private _pointerInput;
  90260. private _observer;
  90261. private _onMouseMove;
  90262. private _onGestureStart;
  90263. private _onGesture;
  90264. private _MSGestureHandler;
  90265. private _onLostFocus;
  90266. private _onContextMenu;
  90267. /**
  90268. * Attach the input controls to a specific dom element to get the input from.
  90269. * @param element Defines the element the controls should be listened from
  90270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90271. */
  90272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90273. /**
  90274. * Detach the current controls from the specified dom element.
  90275. * @param element Defines the element to stop listening the inputs from
  90276. */
  90277. detachControl(element: Nullable<HTMLElement>): void;
  90278. /**
  90279. * Gets the class name of the current intput.
  90280. * @returns the class name
  90281. */
  90282. getClassName(): string;
  90283. /**
  90284. * Get the friendly name associated with the input class.
  90285. * @returns the input friendly name
  90286. */
  90287. getSimpleName(): string;
  90288. }
  90289. }
  90290. declare module BABYLON {
  90291. /**
  90292. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90294. */
  90295. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90296. /**
  90297. * Defines the camera the input is attached to.
  90298. */
  90299. camera: ArcRotateCamera;
  90300. /**
  90301. * Defines the list of key codes associated with the up action (increase alpha)
  90302. */
  90303. keysUp: number[];
  90304. /**
  90305. * Defines the list of key codes associated with the down action (decrease alpha)
  90306. */
  90307. keysDown: number[];
  90308. /**
  90309. * Defines the list of key codes associated with the left action (increase beta)
  90310. */
  90311. keysLeft: number[];
  90312. /**
  90313. * Defines the list of key codes associated with the right action (decrease beta)
  90314. */
  90315. keysRight: number[];
  90316. /**
  90317. * Defines the list of key codes associated with the reset action.
  90318. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90319. */
  90320. keysReset: number[];
  90321. /**
  90322. * Defines the panning sensibility of the inputs.
  90323. * (How fast is the camera paning)
  90324. */
  90325. panningSensibility: number;
  90326. /**
  90327. * Defines the zooming sensibility of the inputs.
  90328. * (How fast is the camera zooming)
  90329. */
  90330. zoomingSensibility: number;
  90331. /**
  90332. * Defines wether maintaining the alt key down switch the movement mode from
  90333. * orientation to zoom.
  90334. */
  90335. useAltToZoom: boolean;
  90336. /**
  90337. * Rotation speed of the camera
  90338. */
  90339. angularSpeed: number;
  90340. private _keys;
  90341. private _ctrlPressed;
  90342. private _altPressed;
  90343. private _onCanvasBlurObserver;
  90344. private _onKeyboardObserver;
  90345. private _engine;
  90346. private _scene;
  90347. /**
  90348. * Attach the input controls to a specific dom element to get the input from.
  90349. * @param element Defines the element the controls should be listened from
  90350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90351. */
  90352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90353. /**
  90354. * Detach the current controls from the specified dom element.
  90355. * @param element Defines the element to stop listening the inputs from
  90356. */
  90357. detachControl(element: Nullable<HTMLElement>): void;
  90358. /**
  90359. * Update the current camera state depending on the inputs that have been used this frame.
  90360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90361. */
  90362. checkInputs(): void;
  90363. /**
  90364. * Gets the class name of the current intput.
  90365. * @returns the class name
  90366. */
  90367. getClassName(): string;
  90368. /**
  90369. * Get the friendly name associated with the input class.
  90370. * @returns the input friendly name
  90371. */
  90372. getSimpleName(): string;
  90373. }
  90374. }
  90375. declare module BABYLON {
  90376. /**
  90377. * Manage the mouse wheel inputs to control an arc rotate camera.
  90378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90379. */
  90380. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90381. /**
  90382. * Defines the camera the input is attached to.
  90383. */
  90384. camera: ArcRotateCamera;
  90385. /**
  90386. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90387. */
  90388. wheelPrecision: number;
  90389. /**
  90390. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90391. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90392. */
  90393. wheelDeltaPercentage: number;
  90394. private _wheel;
  90395. private _observer;
  90396. /**
  90397. * Attach the input controls to a specific dom element to get the input from.
  90398. * @param element Defines the element the controls should be listened from
  90399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90400. */
  90401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90402. /**
  90403. * Detach the current controls from the specified dom element.
  90404. * @param element Defines the element to stop listening the inputs from
  90405. */
  90406. detachControl(element: Nullable<HTMLElement>): void;
  90407. /**
  90408. * Gets the class name of the current intput.
  90409. * @returns the class name
  90410. */
  90411. getClassName(): string;
  90412. /**
  90413. * Get the friendly name associated with the input class.
  90414. * @returns the input friendly name
  90415. */
  90416. getSimpleName(): string;
  90417. }
  90418. }
  90419. declare module BABYLON {
  90420. /**
  90421. * Default Inputs manager for the ArcRotateCamera.
  90422. * It groups all the default supported inputs for ease of use.
  90423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90424. */
  90425. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90426. /**
  90427. * Instantiates a new ArcRotateCameraInputsManager.
  90428. * @param camera Defines the camera the inputs belong to
  90429. */
  90430. constructor(camera: ArcRotateCamera);
  90431. /**
  90432. * Add mouse wheel input support to the input manager.
  90433. * @returns the current input manager
  90434. */
  90435. addMouseWheel(): ArcRotateCameraInputsManager;
  90436. /**
  90437. * Add pointers input support to the input manager.
  90438. * @returns the current input manager
  90439. */
  90440. addPointers(): ArcRotateCameraInputsManager;
  90441. /**
  90442. * Add keyboard input support to the input manager.
  90443. * @returns the current input manager
  90444. */
  90445. addKeyboard(): ArcRotateCameraInputsManager;
  90446. }
  90447. }
  90448. declare module BABYLON {
  90449. /**
  90450. * This represents an orbital type of camera.
  90451. *
  90452. * 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.
  90453. * 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.
  90454. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90455. */
  90456. export class ArcRotateCamera extends TargetCamera {
  90457. /**
  90458. * Defines the rotation angle of the camera along the longitudinal axis.
  90459. */
  90460. alpha: number;
  90461. /**
  90462. * Defines the rotation angle of the camera along the latitudinal axis.
  90463. */
  90464. beta: number;
  90465. /**
  90466. * Defines the radius of the camera from it s target point.
  90467. */
  90468. radius: number;
  90469. protected _target: Vector3;
  90470. protected _targetHost: Nullable<AbstractMesh>;
  90471. /**
  90472. * Defines the target point of the camera.
  90473. * The camera looks towards it form the radius distance.
  90474. */
  90475. target: Vector3;
  90476. /**
  90477. * Current inertia value on the longitudinal axis.
  90478. * The bigger this number the longer it will take for the camera to stop.
  90479. */
  90480. inertialAlphaOffset: number;
  90481. /**
  90482. * Current inertia value on the latitudinal axis.
  90483. * The bigger this number the longer it will take for the camera to stop.
  90484. */
  90485. inertialBetaOffset: number;
  90486. /**
  90487. * Current inertia value on the radius axis.
  90488. * The bigger this number the longer it will take for the camera to stop.
  90489. */
  90490. inertialRadiusOffset: number;
  90491. /**
  90492. * Minimum allowed angle on the longitudinal axis.
  90493. * This can help limiting how the Camera is able to move in the scene.
  90494. */
  90495. lowerAlphaLimit: Nullable<number>;
  90496. /**
  90497. * Maximum allowed angle on the longitudinal axis.
  90498. * This can help limiting how the Camera is able to move in the scene.
  90499. */
  90500. upperAlphaLimit: Nullable<number>;
  90501. /**
  90502. * Minimum allowed angle on the latitudinal axis.
  90503. * This can help limiting how the Camera is able to move in the scene.
  90504. */
  90505. lowerBetaLimit: number;
  90506. /**
  90507. * Maximum allowed angle on the latitudinal axis.
  90508. * This can help limiting how the Camera is able to move in the scene.
  90509. */
  90510. upperBetaLimit: number;
  90511. /**
  90512. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90513. * This can help limiting how the Camera is able to move in the scene.
  90514. */
  90515. lowerRadiusLimit: Nullable<number>;
  90516. /**
  90517. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90518. * This can help limiting how the Camera is able to move in the scene.
  90519. */
  90520. upperRadiusLimit: Nullable<number>;
  90521. /**
  90522. * Defines the current inertia value used during panning of the camera along the X axis.
  90523. */
  90524. inertialPanningX: number;
  90525. /**
  90526. * Defines the current inertia value used during panning of the camera along the Y axis.
  90527. */
  90528. inertialPanningY: number;
  90529. /**
  90530. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  90531. * Basically if your fingers moves away from more than this distance you will be considered
  90532. * in pinch mode.
  90533. */
  90534. pinchToPanMaxDistance: number;
  90535. /**
  90536. * Defines the maximum distance the camera can pan.
  90537. * This could help keeping the cammera always in your scene.
  90538. */
  90539. panningDistanceLimit: Nullable<number>;
  90540. /**
  90541. * Defines the target of the camera before paning.
  90542. */
  90543. panningOriginTarget: Vector3;
  90544. /**
  90545. * Defines the value of the inertia used during panning.
  90546. * 0 would mean stop inertia and one would mean no decelleration at all.
  90547. */
  90548. panningInertia: number;
  90549. /**
  90550. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90551. */
  90552. angularSensibilityX: number;
  90553. /**
  90554. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90555. */
  90556. angularSensibilityY: number;
  90557. /**
  90558. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  90559. */
  90560. pinchPrecision: number;
  90561. /**
  90562. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  90563. * It will be used instead of pinchDeltaPrecision if different from 0.
  90564. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90565. */
  90566. pinchDeltaPercentage: number;
  90567. /**
  90568. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  90569. */
  90570. panningSensibility: number;
  90571. /**
  90572. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  90573. */
  90574. keysUp: number[];
  90575. /**
  90576. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  90577. */
  90578. keysDown: number[];
  90579. /**
  90580. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  90581. */
  90582. keysLeft: number[];
  90583. /**
  90584. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  90585. */
  90586. keysRight: number[];
  90587. /**
  90588. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90589. */
  90590. wheelPrecision: number;
  90591. /**
  90592. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  90593. * It will be used instead of pinchDeltaPrecision if different from 0.
  90594. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90595. */
  90596. wheelDeltaPercentage: number;
  90597. /**
  90598. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  90599. */
  90600. zoomOnFactor: number;
  90601. /**
  90602. * Defines a screen offset for the camera position.
  90603. */
  90604. targetScreenOffset: Vector2;
  90605. /**
  90606. * Allows the camera to be completely reversed.
  90607. * If false the camera can not arrive upside down.
  90608. */
  90609. allowUpsideDown: boolean;
  90610. /**
  90611. * Define if double tap/click is used to restore the previously saved state of the camera.
  90612. */
  90613. useInputToRestoreState: boolean;
  90614. /** @hidden */
  90615. _viewMatrix: Matrix;
  90616. /** @hidden */
  90617. _useCtrlForPanning: boolean;
  90618. /** @hidden */
  90619. _panningMouseButton: number;
  90620. /**
  90621. * Defines the input associated to the camera.
  90622. */
  90623. inputs: ArcRotateCameraInputsManager;
  90624. /** @hidden */
  90625. _reset: () => void;
  90626. /**
  90627. * Defines the allowed panning axis.
  90628. */
  90629. panningAxis: Vector3;
  90630. protected _localDirection: Vector3;
  90631. protected _transformedDirection: Vector3;
  90632. private _bouncingBehavior;
  90633. /**
  90634. * Gets the bouncing behavior of the camera if it has been enabled.
  90635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90636. */
  90637. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  90638. /**
  90639. * Defines if the bouncing behavior of the camera is enabled on the camera.
  90640. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90641. */
  90642. useBouncingBehavior: boolean;
  90643. private _framingBehavior;
  90644. /**
  90645. * Gets the framing behavior of the camera if it has been enabled.
  90646. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90647. */
  90648. readonly framingBehavior: Nullable<FramingBehavior>;
  90649. /**
  90650. * Defines if the framing behavior of the camera is enabled on the camera.
  90651. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90652. */
  90653. useFramingBehavior: boolean;
  90654. private _autoRotationBehavior;
  90655. /**
  90656. * Gets the auto rotation behavior of the camera if it has been enabled.
  90657. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90658. */
  90659. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  90660. /**
  90661. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  90662. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90663. */
  90664. useAutoRotationBehavior: boolean;
  90665. /**
  90666. * Observable triggered when the mesh target has been changed on the camera.
  90667. */
  90668. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  90669. /**
  90670. * Event raised when the camera is colliding with a mesh.
  90671. */
  90672. onCollide: (collidedMesh: AbstractMesh) => void;
  90673. /**
  90674. * Defines whether the camera should check collision with the objects oh the scene.
  90675. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  90676. */
  90677. checkCollisions: boolean;
  90678. /**
  90679. * Defines the collision radius of the camera.
  90680. * This simulates a sphere around the camera.
  90681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  90682. */
  90683. collisionRadius: Vector3;
  90684. protected _collider: Collider;
  90685. protected _previousPosition: Vector3;
  90686. protected _collisionVelocity: Vector3;
  90687. protected _newPosition: Vector3;
  90688. protected _previousAlpha: number;
  90689. protected _previousBeta: number;
  90690. protected _previousRadius: number;
  90691. protected _collisionTriggered: boolean;
  90692. protected _targetBoundingCenter: Nullable<Vector3>;
  90693. private _computationVector;
  90694. private _tempAxisVector;
  90695. private _tempAxisRotationMatrix;
  90696. /**
  90697. * Instantiates a new ArcRotateCamera in a given scene
  90698. * @param name Defines the name of the camera
  90699. * @param alpha Defines the camera rotation along the logitudinal axis
  90700. * @param beta Defines the camera rotation along the latitudinal axis
  90701. * @param radius Defines the camera distance from its target
  90702. * @param target Defines the camera target
  90703. * @param scene Defines the scene the camera belongs to
  90704. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90705. */
  90706. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90707. /** @hidden */
  90708. _initCache(): void;
  90709. /** @hidden */
  90710. _updateCache(ignoreParentClass?: boolean): void;
  90711. protected _getTargetPosition(): Vector3;
  90712. private _storedAlpha;
  90713. private _storedBeta;
  90714. private _storedRadius;
  90715. private _storedTarget;
  90716. /**
  90717. * Stores the current state of the camera (alpha, beta, radius and target)
  90718. * @returns the camera itself
  90719. */
  90720. storeState(): Camera;
  90721. /**
  90722. * @hidden
  90723. * Restored camera state. You must call storeState() first
  90724. */
  90725. _restoreStateValues(): boolean;
  90726. /** @hidden */
  90727. _isSynchronizedViewMatrix(): boolean;
  90728. /**
  90729. * Attached controls to the current camera.
  90730. * @param element Defines the element the controls should be listened from
  90731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90732. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  90733. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  90734. */
  90735. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  90736. /**
  90737. * Detach the current controls from the camera.
  90738. * The camera will stop reacting to inputs.
  90739. * @param element Defines the element to stop listening the inputs from
  90740. */
  90741. detachControl(element: HTMLElement): void;
  90742. /** @hidden */
  90743. _checkInputs(): void;
  90744. protected _checkLimits(): void;
  90745. /**
  90746. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  90747. */
  90748. rebuildAnglesAndRadius(): void;
  90749. /**
  90750. * Use a position to define the current camera related information like aplha, beta and radius
  90751. * @param position Defines the position to set the camera at
  90752. */
  90753. setPosition(position: Vector3): void;
  90754. /**
  90755. * Defines the target the camera should look at.
  90756. * This will automatically adapt alpha beta and radius to fit within the new target.
  90757. * @param target Defines the new target as a Vector or a mesh
  90758. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  90759. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  90760. */
  90761. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  90762. /** @hidden */
  90763. _getViewMatrix(): Matrix;
  90764. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  90765. /**
  90766. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  90767. * @param meshes Defines the mesh to zoom on
  90768. * @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)
  90769. */
  90770. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  90771. /**
  90772. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  90773. * The target will be changed but the radius
  90774. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  90775. * @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)
  90776. */
  90777. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  90778. min: Vector3;
  90779. max: Vector3;
  90780. distance: number;
  90781. }, doNotUpdateMaxZ?: boolean): void;
  90782. /**
  90783. * @override
  90784. * Override Camera.createRigCamera
  90785. */
  90786. createRigCamera(name: string, cameraIndex: number): Camera;
  90787. /**
  90788. * @hidden
  90789. * @override
  90790. * Override Camera._updateRigCameras
  90791. */
  90792. _updateRigCameras(): void;
  90793. /**
  90794. * Destroy the camera and release the current resources hold by it.
  90795. */
  90796. dispose(): void;
  90797. /**
  90798. * Gets the current object class name.
  90799. * @return the class name
  90800. */
  90801. getClassName(): string;
  90802. }
  90803. }
  90804. declare module BABYLON {
  90805. /**
  90806. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  90807. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90808. */
  90809. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  90810. /**
  90811. * Gets the name of the behavior.
  90812. */
  90813. readonly name: string;
  90814. private _zoomStopsAnimation;
  90815. private _idleRotationSpeed;
  90816. private _idleRotationWaitTime;
  90817. private _idleRotationSpinupTime;
  90818. /**
  90819. * Sets the flag that indicates if user zooming should stop animation.
  90820. */
  90821. /**
  90822. * Gets the flag that indicates if user zooming should stop animation.
  90823. */
  90824. zoomStopsAnimation: boolean;
  90825. /**
  90826. * Sets the default speed at which the camera rotates around the model.
  90827. */
  90828. /**
  90829. * Gets the default speed at which the camera rotates around the model.
  90830. */
  90831. idleRotationSpeed: number;
  90832. /**
  90833. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  90834. */
  90835. /**
  90836. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  90837. */
  90838. idleRotationWaitTime: number;
  90839. /**
  90840. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90841. */
  90842. /**
  90843. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90844. */
  90845. idleRotationSpinupTime: number;
  90846. /**
  90847. * Gets a value indicating if the camera is currently rotating because of this behavior
  90848. */
  90849. readonly rotationInProgress: boolean;
  90850. private _onPrePointerObservableObserver;
  90851. private _onAfterCheckInputsObserver;
  90852. private _attachedCamera;
  90853. private _isPointerDown;
  90854. private _lastFrameTime;
  90855. private _lastInteractionTime;
  90856. private _cameraRotationSpeed;
  90857. /**
  90858. * Initializes the behavior.
  90859. */
  90860. init(): void;
  90861. /**
  90862. * Attaches the behavior to its arc rotate camera.
  90863. * @param camera Defines the camera to attach the behavior to
  90864. */
  90865. attach(camera: ArcRotateCamera): void;
  90866. /**
  90867. * Detaches the behavior from its current arc rotate camera.
  90868. */
  90869. detach(): void;
  90870. /**
  90871. * Returns true if user is scrolling.
  90872. * @return true if user is scrolling.
  90873. */
  90874. private _userIsZooming;
  90875. private _lastFrameRadius;
  90876. private _shouldAnimationStopForInteraction;
  90877. /**
  90878. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90879. */
  90880. private _applyUserInteraction;
  90881. private _userIsMoving;
  90882. }
  90883. }
  90884. declare module BABYLON {
  90885. /**
  90886. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  90887. */
  90888. export class AttachToBoxBehavior implements Behavior<Mesh> {
  90889. private ui;
  90890. /**
  90891. * The name of the behavior
  90892. */
  90893. name: string;
  90894. /**
  90895. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  90896. */
  90897. distanceAwayFromFace: number;
  90898. /**
  90899. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  90900. */
  90901. distanceAwayFromBottomOfFace: number;
  90902. private _faceVectors;
  90903. private _target;
  90904. private _scene;
  90905. private _onRenderObserver;
  90906. private _tmpMatrix;
  90907. private _tmpVector;
  90908. /**
  90909. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  90910. * @param ui The transform node that should be attched to the mesh
  90911. */
  90912. constructor(ui: TransformNode);
  90913. /**
  90914. * Initializes the behavior
  90915. */
  90916. init(): void;
  90917. private _closestFace;
  90918. private _zeroVector;
  90919. private _lookAtTmpMatrix;
  90920. private _lookAtToRef;
  90921. /**
  90922. * Attaches the AttachToBoxBehavior to the passed in mesh
  90923. * @param target The mesh that the specified node will be attached to
  90924. */
  90925. attach(target: Mesh): void;
  90926. /**
  90927. * Detaches the behavior from the mesh
  90928. */
  90929. detach(): void;
  90930. }
  90931. }
  90932. declare module BABYLON {
  90933. /**
  90934. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  90935. */
  90936. export class FadeInOutBehavior implements Behavior<Mesh> {
  90937. /**
  90938. * Time in milliseconds to delay before fading in (Default: 0)
  90939. */
  90940. delay: number;
  90941. /**
  90942. * Time in milliseconds for the mesh to fade in (Default: 300)
  90943. */
  90944. fadeInTime: number;
  90945. private _millisecondsPerFrame;
  90946. private _hovered;
  90947. private _hoverValue;
  90948. private _ownerNode;
  90949. /**
  90950. * Instatiates the FadeInOutBehavior
  90951. */
  90952. constructor();
  90953. /**
  90954. * The name of the behavior
  90955. */
  90956. readonly name: string;
  90957. /**
  90958. * Initializes the behavior
  90959. */
  90960. init(): void;
  90961. /**
  90962. * Attaches the fade behavior on the passed in mesh
  90963. * @param ownerNode The mesh that will be faded in/out once attached
  90964. */
  90965. attach(ownerNode: Mesh): void;
  90966. /**
  90967. * Detaches the behavior from the mesh
  90968. */
  90969. detach(): void;
  90970. /**
  90971. * Triggers the mesh to begin fading in or out
  90972. * @param value if the object should fade in or out (true to fade in)
  90973. */
  90974. fadeIn(value: boolean): void;
  90975. private _update;
  90976. private _setAllVisibility;
  90977. }
  90978. }
  90979. declare module BABYLON {
  90980. /**
  90981. * Class containing a set of static utilities functions for managing Pivots
  90982. * @hidden
  90983. */
  90984. export class PivotTools {
  90985. private static _PivotCached;
  90986. private static _OldPivotPoint;
  90987. private static _PivotTranslation;
  90988. private static _PivotTmpVector;
  90989. /** @hidden */
  90990. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  90991. /** @hidden */
  90992. static _RestorePivotPoint(mesh: AbstractMesh): void;
  90993. }
  90994. }
  90995. declare module BABYLON {
  90996. /**
  90997. * Class containing static functions to help procedurally build meshes
  90998. */
  90999. export class PlaneBuilder {
  91000. /**
  91001. * Creates a plane mesh
  91002. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  91003. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  91004. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  91005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91008. * @param name defines the name of the mesh
  91009. * @param options defines the options used to create the mesh
  91010. * @param scene defines the hosting scene
  91011. * @returns the plane mesh
  91012. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  91013. */
  91014. static CreatePlane(name: string, options: {
  91015. size?: number;
  91016. width?: number;
  91017. height?: number;
  91018. sideOrientation?: number;
  91019. frontUVs?: Vector4;
  91020. backUVs?: Vector4;
  91021. updatable?: boolean;
  91022. sourcePlane?: Plane;
  91023. }, scene: Scene): Mesh;
  91024. }
  91025. }
  91026. declare module BABYLON {
  91027. /**
  91028. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  91029. */
  91030. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  91031. private static _AnyMouseID;
  91032. private _attachedNode;
  91033. private _dragPlane;
  91034. private _scene;
  91035. private _pointerObserver;
  91036. private _beforeRenderObserver;
  91037. private static _planeScene;
  91038. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  91039. /**
  91040. * 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)
  91041. */
  91042. maxDragAngle: number;
  91043. /**
  91044. * @hidden
  91045. */
  91046. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  91047. /**
  91048. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91049. */
  91050. currentDraggingPointerID: number;
  91051. /**
  91052. * The last position where the pointer hit the drag plane in world space
  91053. */
  91054. lastDragPosition: Vector3;
  91055. /**
  91056. * If the behavior is currently in a dragging state
  91057. */
  91058. dragging: boolean;
  91059. /**
  91060. * 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)
  91061. */
  91062. dragDeltaRatio: number;
  91063. /**
  91064. * If the drag plane orientation should be updated during the dragging (Default: true)
  91065. */
  91066. updateDragPlane: boolean;
  91067. private _debugMode;
  91068. private _moving;
  91069. /**
  91070. * Fires each time the attached mesh is dragged with the pointer
  91071. * * delta between last drag position and current drag position in world space
  91072. * * dragDistance along the drag axis
  91073. * * dragPlaneNormal normal of the current drag plane used during the drag
  91074. * * dragPlanePoint in world space where the drag intersects the drag plane
  91075. */
  91076. onDragObservable: Observable<{
  91077. delta: Vector3;
  91078. dragPlanePoint: Vector3;
  91079. dragPlaneNormal: Vector3;
  91080. dragDistance: number;
  91081. pointerId: number;
  91082. }>;
  91083. /**
  91084. * Fires each time a drag begins (eg. mouse down on mesh)
  91085. */
  91086. onDragStartObservable: Observable<{
  91087. dragPlanePoint: Vector3;
  91088. pointerId: number;
  91089. }>;
  91090. /**
  91091. * Fires each time a drag ends (eg. mouse release after drag)
  91092. */
  91093. onDragEndObservable: Observable<{
  91094. dragPlanePoint: Vector3;
  91095. pointerId: number;
  91096. }>;
  91097. /**
  91098. * If the attached mesh should be moved when dragged
  91099. */
  91100. moveAttached: boolean;
  91101. /**
  91102. * If the drag behavior will react to drag events (Default: true)
  91103. */
  91104. enabled: boolean;
  91105. /**
  91106. * If camera controls should be detached during the drag
  91107. */
  91108. detachCameraControls: boolean;
  91109. /**
  91110. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91111. */
  91112. useObjectOrienationForDragging: boolean;
  91113. private _options;
  91114. /**
  91115. * Creates a pointer drag behavior that can be attached to a mesh
  91116. * @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)
  91117. */
  91118. constructor(options?: {
  91119. dragAxis?: Vector3;
  91120. dragPlaneNormal?: Vector3;
  91121. });
  91122. /**
  91123. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91124. */
  91125. validateDrag: (targetPosition: Vector3) => boolean;
  91126. /**
  91127. * The name of the behavior
  91128. */
  91129. readonly name: string;
  91130. /**
  91131. * Initializes the behavior
  91132. */
  91133. init(): void;
  91134. private _tmpVector;
  91135. private _alternatePickedPoint;
  91136. private _worldDragAxis;
  91137. private _targetPosition;
  91138. private _attachedElement;
  91139. /**
  91140. * Attaches the drag behavior the passed in mesh
  91141. * @param ownerNode The mesh that will be dragged around once attached
  91142. */
  91143. attach(ownerNode: AbstractMesh): void;
  91144. /**
  91145. * Force relase the drag action by code.
  91146. */
  91147. releaseDrag(): void;
  91148. private _startDragRay;
  91149. private _lastPointerRay;
  91150. /**
  91151. * Simulates the start of a pointer drag event on the behavior
  91152. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91153. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91154. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91155. */
  91156. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91157. private _startDrag;
  91158. private _dragDelta;
  91159. private _moveDrag;
  91160. private _pickWithRayOnDragPlane;
  91161. private _pointA;
  91162. private _pointB;
  91163. private _pointC;
  91164. private _lineA;
  91165. private _lineB;
  91166. private _localAxis;
  91167. private _lookAt;
  91168. private _updateDragPlanePosition;
  91169. /**
  91170. * Detaches the behavior from the mesh
  91171. */
  91172. detach(): void;
  91173. }
  91174. }
  91175. declare module BABYLON {
  91176. /**
  91177. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91178. */
  91179. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91180. private _dragBehaviorA;
  91181. private _dragBehaviorB;
  91182. private _startDistance;
  91183. private _initialScale;
  91184. private _targetScale;
  91185. private _ownerNode;
  91186. private _sceneRenderObserver;
  91187. /**
  91188. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91189. */
  91190. constructor();
  91191. /**
  91192. * The name of the behavior
  91193. */
  91194. readonly name: string;
  91195. /**
  91196. * Initializes the behavior
  91197. */
  91198. init(): void;
  91199. private _getCurrentDistance;
  91200. /**
  91201. * Attaches the scale behavior the passed in mesh
  91202. * @param ownerNode The mesh that will be scaled around once attached
  91203. */
  91204. attach(ownerNode: Mesh): void;
  91205. /**
  91206. * Detaches the behavior from the mesh
  91207. */
  91208. detach(): void;
  91209. }
  91210. }
  91211. declare module BABYLON {
  91212. /**
  91213. * 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
  91214. */
  91215. export class SixDofDragBehavior implements Behavior<Mesh> {
  91216. private static _virtualScene;
  91217. private _ownerNode;
  91218. private _sceneRenderObserver;
  91219. private _scene;
  91220. private _targetPosition;
  91221. private _virtualOriginMesh;
  91222. private _virtualDragMesh;
  91223. private _pointerObserver;
  91224. private _moving;
  91225. private _startingOrientation;
  91226. /**
  91227. * 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)
  91228. */
  91229. private zDragFactor;
  91230. /**
  91231. * If the object should rotate to face the drag origin
  91232. */
  91233. rotateDraggedObject: boolean;
  91234. /**
  91235. * If the behavior is currently in a dragging state
  91236. */
  91237. dragging: boolean;
  91238. /**
  91239. * 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)
  91240. */
  91241. dragDeltaRatio: number;
  91242. /**
  91243. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91244. */
  91245. currentDraggingPointerID: number;
  91246. /**
  91247. * If camera controls should be detached during the drag
  91248. */
  91249. detachCameraControls: boolean;
  91250. /**
  91251. * Fires each time a drag starts
  91252. */
  91253. onDragStartObservable: Observable<{}>;
  91254. /**
  91255. * Fires each time a drag ends (eg. mouse release after drag)
  91256. */
  91257. onDragEndObservable: Observable<{}>;
  91258. /**
  91259. * 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
  91260. */
  91261. constructor();
  91262. /**
  91263. * The name of the behavior
  91264. */
  91265. readonly name: string;
  91266. /**
  91267. * Initializes the behavior
  91268. */
  91269. init(): void;
  91270. /**
  91271. * Attaches the scale behavior the passed in mesh
  91272. * @param ownerNode The mesh that will be scaled around once attached
  91273. */
  91274. attach(ownerNode: Mesh): void;
  91275. /**
  91276. * Detaches the behavior from the mesh
  91277. */
  91278. detach(): void;
  91279. }
  91280. }
  91281. declare module BABYLON {
  91282. /**
  91283. * Class used to apply inverse kinematics to bones
  91284. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91285. */
  91286. export class BoneIKController {
  91287. private static _tmpVecs;
  91288. private static _tmpQuat;
  91289. private static _tmpMats;
  91290. /**
  91291. * Gets or sets the target mesh
  91292. */
  91293. targetMesh: AbstractMesh;
  91294. /** Gets or sets the mesh used as pole */
  91295. poleTargetMesh: AbstractMesh;
  91296. /**
  91297. * Gets or sets the bone used as pole
  91298. */
  91299. poleTargetBone: Nullable<Bone>;
  91300. /**
  91301. * Gets or sets the target position
  91302. */
  91303. targetPosition: Vector3;
  91304. /**
  91305. * Gets or sets the pole target position
  91306. */
  91307. poleTargetPosition: Vector3;
  91308. /**
  91309. * Gets or sets the pole target local offset
  91310. */
  91311. poleTargetLocalOffset: Vector3;
  91312. /**
  91313. * Gets or sets the pole angle
  91314. */
  91315. poleAngle: number;
  91316. /**
  91317. * Gets or sets the mesh associated with the controller
  91318. */
  91319. mesh: AbstractMesh;
  91320. /**
  91321. * 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)
  91322. */
  91323. slerpAmount: number;
  91324. private _bone1Quat;
  91325. private _bone1Mat;
  91326. private _bone2Ang;
  91327. private _bone1;
  91328. private _bone2;
  91329. private _bone1Length;
  91330. private _bone2Length;
  91331. private _maxAngle;
  91332. private _maxReach;
  91333. private _rightHandedSystem;
  91334. private _bendAxis;
  91335. private _slerping;
  91336. private _adjustRoll;
  91337. /**
  91338. * Gets or sets maximum allowed angle
  91339. */
  91340. maxAngle: number;
  91341. /**
  91342. * Creates a new BoneIKController
  91343. * @param mesh defines the mesh to control
  91344. * @param bone defines the bone to control
  91345. * @param options defines options to set up the controller
  91346. */
  91347. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91348. targetMesh?: AbstractMesh;
  91349. poleTargetMesh?: AbstractMesh;
  91350. poleTargetBone?: Bone;
  91351. poleTargetLocalOffset?: Vector3;
  91352. poleAngle?: number;
  91353. bendAxis?: Vector3;
  91354. maxAngle?: number;
  91355. slerpAmount?: number;
  91356. });
  91357. private _setMaxAngle;
  91358. /**
  91359. * Force the controller to update the bones
  91360. */
  91361. update(): void;
  91362. }
  91363. }
  91364. declare module BABYLON {
  91365. /**
  91366. * Class used to make a bone look toward a point in space
  91367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91368. */
  91369. export class BoneLookController {
  91370. private static _tmpVecs;
  91371. private static _tmpQuat;
  91372. private static _tmpMats;
  91373. /**
  91374. * The target Vector3 that the bone will look at
  91375. */
  91376. target: Vector3;
  91377. /**
  91378. * The mesh that the bone is attached to
  91379. */
  91380. mesh: AbstractMesh;
  91381. /**
  91382. * The bone that will be looking to the target
  91383. */
  91384. bone: Bone;
  91385. /**
  91386. * The up axis of the coordinate system that is used when the bone is rotated
  91387. */
  91388. upAxis: Vector3;
  91389. /**
  91390. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91391. */
  91392. upAxisSpace: Space;
  91393. /**
  91394. * Used to make an adjustment to the yaw of the bone
  91395. */
  91396. adjustYaw: number;
  91397. /**
  91398. * Used to make an adjustment to the pitch of the bone
  91399. */
  91400. adjustPitch: number;
  91401. /**
  91402. * Used to make an adjustment to the roll of the bone
  91403. */
  91404. adjustRoll: number;
  91405. /**
  91406. * 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)
  91407. */
  91408. slerpAmount: number;
  91409. private _minYaw;
  91410. private _maxYaw;
  91411. private _minPitch;
  91412. private _maxPitch;
  91413. private _minYawSin;
  91414. private _minYawCos;
  91415. private _maxYawSin;
  91416. private _maxYawCos;
  91417. private _midYawConstraint;
  91418. private _minPitchTan;
  91419. private _maxPitchTan;
  91420. private _boneQuat;
  91421. private _slerping;
  91422. private _transformYawPitch;
  91423. private _transformYawPitchInv;
  91424. private _firstFrameSkipped;
  91425. private _yawRange;
  91426. private _fowardAxis;
  91427. /**
  91428. * Gets or sets the minimum yaw angle that the bone can look to
  91429. */
  91430. minYaw: number;
  91431. /**
  91432. * Gets or sets the maximum yaw angle that the bone can look to
  91433. */
  91434. maxYaw: number;
  91435. /**
  91436. * Gets or sets the minimum pitch angle that the bone can look to
  91437. */
  91438. minPitch: number;
  91439. /**
  91440. * Gets or sets the maximum pitch angle that the bone can look to
  91441. */
  91442. maxPitch: number;
  91443. /**
  91444. * Create a BoneLookController
  91445. * @param mesh the mesh that the bone belongs to
  91446. * @param bone the bone that will be looking to the target
  91447. * @param target the target Vector3 to look at
  91448. * @param options optional settings:
  91449. * * maxYaw: the maximum angle the bone will yaw to
  91450. * * minYaw: the minimum angle the bone will yaw to
  91451. * * maxPitch: the maximum angle the bone will pitch to
  91452. * * minPitch: the minimum angle the bone will yaw to
  91453. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91454. * * upAxis: the up axis of the coordinate system
  91455. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91456. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91457. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91458. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91459. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91460. * * adjustRoll: used to make an adjustment to the roll of the bone
  91461. **/
  91462. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91463. maxYaw?: number;
  91464. minYaw?: number;
  91465. maxPitch?: number;
  91466. minPitch?: number;
  91467. slerpAmount?: number;
  91468. upAxis?: Vector3;
  91469. upAxisSpace?: Space;
  91470. yawAxis?: Vector3;
  91471. pitchAxis?: Vector3;
  91472. adjustYaw?: number;
  91473. adjustPitch?: number;
  91474. adjustRoll?: number;
  91475. });
  91476. /**
  91477. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91478. */
  91479. update(): void;
  91480. private _getAngleDiff;
  91481. private _getAngleBetween;
  91482. private _isAngleBetween;
  91483. }
  91484. }
  91485. declare module BABYLON {
  91486. /**
  91487. * Manage the gamepad inputs to control an arc rotate camera.
  91488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91489. */
  91490. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91491. /**
  91492. * Defines the camera the input is attached to.
  91493. */
  91494. camera: ArcRotateCamera;
  91495. /**
  91496. * Defines the gamepad the input is gathering event from.
  91497. */
  91498. gamepad: Nullable<Gamepad>;
  91499. /**
  91500. * Defines the gamepad rotation sensiblity.
  91501. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91502. */
  91503. gamepadRotationSensibility: number;
  91504. /**
  91505. * Defines the gamepad move sensiblity.
  91506. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91507. */
  91508. gamepadMoveSensibility: number;
  91509. private _onGamepadConnectedObserver;
  91510. private _onGamepadDisconnectedObserver;
  91511. /**
  91512. * Attach the input controls to a specific dom element to get the input from.
  91513. * @param element Defines the element the controls should be listened from
  91514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91515. */
  91516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91517. /**
  91518. * Detach the current controls from the specified dom element.
  91519. * @param element Defines the element to stop listening the inputs from
  91520. */
  91521. detachControl(element: Nullable<HTMLElement>): void;
  91522. /**
  91523. * Update the current camera state depending on the inputs that have been used this frame.
  91524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91525. */
  91526. checkInputs(): void;
  91527. /**
  91528. * Gets the class name of the current intput.
  91529. * @returns the class name
  91530. */
  91531. getClassName(): string;
  91532. /**
  91533. * Get the friendly name associated with the input class.
  91534. * @returns the input friendly name
  91535. */
  91536. getSimpleName(): string;
  91537. }
  91538. }
  91539. declare module BABYLON {
  91540. interface ArcRotateCameraInputsManager {
  91541. /**
  91542. * Add orientation input support to the input manager.
  91543. * @returns the current input manager
  91544. */
  91545. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  91546. }
  91547. /**
  91548. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  91549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91550. */
  91551. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  91552. /**
  91553. * Defines the camera the input is attached to.
  91554. */
  91555. camera: ArcRotateCamera;
  91556. /**
  91557. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  91558. */
  91559. alphaCorrection: number;
  91560. /**
  91561. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  91562. */
  91563. gammaCorrection: number;
  91564. private _alpha;
  91565. private _gamma;
  91566. private _dirty;
  91567. private _deviceOrientationHandler;
  91568. /**
  91569. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  91570. */
  91571. constructor();
  91572. /**
  91573. * Attach the input controls to a specific dom element to get the input from.
  91574. * @param element Defines the element the controls should be listened from
  91575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91576. */
  91577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91578. /** @hidden */
  91579. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  91580. /**
  91581. * Update the current camera state depending on the inputs that have been used this frame.
  91582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91583. */
  91584. checkInputs(): void;
  91585. /**
  91586. * Detach the current controls from the specified dom element.
  91587. * @param element Defines the element to stop listening the inputs from
  91588. */
  91589. detachControl(element: Nullable<HTMLElement>): void;
  91590. /**
  91591. * Gets the class name of the current intput.
  91592. * @returns the class name
  91593. */
  91594. getClassName(): string;
  91595. /**
  91596. * Get the friendly name associated with the input class.
  91597. * @returns the input friendly name
  91598. */
  91599. getSimpleName(): string;
  91600. }
  91601. }
  91602. declare module BABYLON {
  91603. /**
  91604. * Listen to mouse events to control the camera.
  91605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91606. */
  91607. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  91608. /**
  91609. * Defines the camera the input is attached to.
  91610. */
  91611. camera: FlyCamera;
  91612. /**
  91613. * Defines if touch is enabled. (Default is true.)
  91614. */
  91615. touchEnabled: boolean;
  91616. /**
  91617. * Defines the buttons associated with the input to handle camera rotation.
  91618. */
  91619. buttons: number[];
  91620. /**
  91621. * Assign buttons for Yaw control.
  91622. */
  91623. buttonsYaw: number[];
  91624. /**
  91625. * Assign buttons for Pitch control.
  91626. */
  91627. buttonsPitch: number[];
  91628. /**
  91629. * Assign buttons for Roll control.
  91630. */
  91631. buttonsRoll: number[];
  91632. /**
  91633. * Detect if any button is being pressed while mouse is moved.
  91634. * -1 = Mouse locked.
  91635. * 0 = Left button.
  91636. * 1 = Middle Button.
  91637. * 2 = Right Button.
  91638. */
  91639. activeButton: number;
  91640. /**
  91641. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  91642. * Higher values reduce its sensitivity.
  91643. */
  91644. angularSensibility: number;
  91645. private _mousemoveCallback;
  91646. private _observer;
  91647. private _rollObserver;
  91648. private previousPosition;
  91649. private noPreventDefault;
  91650. private element;
  91651. /**
  91652. * Listen to mouse events to control the camera.
  91653. * @param touchEnabled Define if touch is enabled. (Default is true.)
  91654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91655. */
  91656. constructor(touchEnabled?: boolean);
  91657. /**
  91658. * Attach the mouse control to the HTML DOM element.
  91659. * @param element Defines the element that listens to the input events.
  91660. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  91661. */
  91662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91663. /**
  91664. * Detach the current controls from the specified dom element.
  91665. * @param element Defines the element to stop listening the inputs from
  91666. */
  91667. detachControl(element: Nullable<HTMLElement>): void;
  91668. /**
  91669. * Gets the class name of the current input.
  91670. * @returns the class name.
  91671. */
  91672. getClassName(): string;
  91673. /**
  91674. * Get the friendly name associated with the input class.
  91675. * @returns the input's friendly name.
  91676. */
  91677. getSimpleName(): string;
  91678. private _pointerInput;
  91679. private _onMouseMove;
  91680. /**
  91681. * Rotate camera by mouse offset.
  91682. */
  91683. private rotateCamera;
  91684. }
  91685. }
  91686. declare module BABYLON {
  91687. /**
  91688. * Default Inputs manager for the FlyCamera.
  91689. * It groups all the default supported inputs for ease of use.
  91690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91691. */
  91692. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  91693. /**
  91694. * Instantiates a new FlyCameraInputsManager.
  91695. * @param camera Defines the camera the inputs belong to.
  91696. */
  91697. constructor(camera: FlyCamera);
  91698. /**
  91699. * Add keyboard input support to the input manager.
  91700. * @returns the new FlyCameraKeyboardMoveInput().
  91701. */
  91702. addKeyboard(): FlyCameraInputsManager;
  91703. /**
  91704. * Add mouse input support to the input manager.
  91705. * @param touchEnabled Enable touch screen support.
  91706. * @returns the new FlyCameraMouseInput().
  91707. */
  91708. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  91709. }
  91710. }
  91711. declare module BABYLON {
  91712. /**
  91713. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91714. * such as in a 3D Space Shooter or a Flight Simulator.
  91715. */
  91716. export class FlyCamera extends TargetCamera {
  91717. /**
  91718. * Define the collision ellipsoid of the camera.
  91719. * This is helpful for simulating a camera body, like a player's body.
  91720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91721. */
  91722. ellipsoid: Vector3;
  91723. /**
  91724. * Define an offset for the position of the ellipsoid around the camera.
  91725. * This can be helpful if the camera is attached away from the player's body center,
  91726. * such as at its head.
  91727. */
  91728. ellipsoidOffset: Vector3;
  91729. /**
  91730. * Enable or disable collisions of the camera with the rest of the scene objects.
  91731. */
  91732. checkCollisions: boolean;
  91733. /**
  91734. * Enable or disable gravity on the camera.
  91735. */
  91736. applyGravity: boolean;
  91737. /**
  91738. * Define the current direction the camera is moving to.
  91739. */
  91740. cameraDirection: Vector3;
  91741. /**
  91742. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  91743. * This overrides and empties cameraRotation.
  91744. */
  91745. rotationQuaternion: Quaternion;
  91746. /**
  91747. * Track Roll to maintain the wanted Rolling when looking around.
  91748. */
  91749. _trackRoll: number;
  91750. /**
  91751. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  91752. */
  91753. rollCorrect: number;
  91754. /**
  91755. * Mimic a banked turn, Rolling the camera when Yawing.
  91756. * It's recommended to use rollCorrect = 10 for faster banking correction.
  91757. */
  91758. bankedTurn: boolean;
  91759. /**
  91760. * Limit in radians for how much Roll banking will add. (Default: 90°)
  91761. */
  91762. bankedTurnLimit: number;
  91763. /**
  91764. * Value of 0 disables the banked Roll.
  91765. * Value of 1 is equal to the Yaw angle in radians.
  91766. */
  91767. bankedTurnMultiplier: number;
  91768. /**
  91769. * The inputs manager loads all the input sources, such as keyboard and mouse.
  91770. */
  91771. inputs: FlyCameraInputsManager;
  91772. /**
  91773. * Gets the input sensibility for mouse input.
  91774. * Higher values reduce sensitivity.
  91775. */
  91776. /**
  91777. * Sets the input sensibility for a mouse input.
  91778. * Higher values reduce sensitivity.
  91779. */
  91780. angularSensibility: number;
  91781. /**
  91782. * Get the keys for camera movement forward.
  91783. */
  91784. /**
  91785. * Set the keys for camera movement forward.
  91786. */
  91787. keysForward: number[];
  91788. /**
  91789. * Get the keys for camera movement backward.
  91790. */
  91791. keysBackward: number[];
  91792. /**
  91793. * Get the keys for camera movement up.
  91794. */
  91795. /**
  91796. * Set the keys for camera movement up.
  91797. */
  91798. keysUp: number[];
  91799. /**
  91800. * Get the keys for camera movement down.
  91801. */
  91802. /**
  91803. * Set the keys for camera movement down.
  91804. */
  91805. keysDown: number[];
  91806. /**
  91807. * Get the keys for camera movement left.
  91808. */
  91809. /**
  91810. * Set the keys for camera movement left.
  91811. */
  91812. keysLeft: number[];
  91813. /**
  91814. * Set the keys for camera movement right.
  91815. */
  91816. /**
  91817. * Set the keys for camera movement right.
  91818. */
  91819. keysRight: number[];
  91820. /**
  91821. * Event raised when the camera collides with a mesh in the scene.
  91822. */
  91823. onCollide: (collidedMesh: AbstractMesh) => void;
  91824. private _collider;
  91825. private _needMoveForGravity;
  91826. private _oldPosition;
  91827. private _diffPosition;
  91828. private _newPosition;
  91829. /** @hidden */
  91830. _localDirection: Vector3;
  91831. /** @hidden */
  91832. _transformedDirection: Vector3;
  91833. /**
  91834. * Instantiates a FlyCamera.
  91835. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91836. * such as in a 3D Space Shooter or a Flight Simulator.
  91837. * @param name Define the name of the camera in the scene.
  91838. * @param position Define the starting position of the camera in the scene.
  91839. * @param scene Define the scene the camera belongs to.
  91840. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  91841. */
  91842. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91843. /**
  91844. * Attach a control to the HTML DOM element.
  91845. * @param element Defines the element that listens to the input events.
  91846. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  91847. */
  91848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91849. /**
  91850. * Detach a control from the HTML DOM element.
  91851. * The camera will stop reacting to that input.
  91852. * @param element Defines the element that listens to the input events.
  91853. */
  91854. detachControl(element: HTMLElement): void;
  91855. private _collisionMask;
  91856. /**
  91857. * Get the mask that the camera ignores in collision events.
  91858. */
  91859. /**
  91860. * Set the mask that the camera ignores in collision events.
  91861. */
  91862. collisionMask: number;
  91863. /** @hidden */
  91864. _collideWithWorld(displacement: Vector3): void;
  91865. /** @hidden */
  91866. private _onCollisionPositionChange;
  91867. /** @hidden */
  91868. _checkInputs(): void;
  91869. /** @hidden */
  91870. _decideIfNeedsToMove(): boolean;
  91871. /** @hidden */
  91872. _updatePosition(): void;
  91873. /**
  91874. * Restore the Roll to its target value at the rate specified.
  91875. * @param rate - Higher means slower restoring.
  91876. * @hidden
  91877. */
  91878. restoreRoll(rate: number): void;
  91879. /**
  91880. * Destroy the camera and release the current resources held by it.
  91881. */
  91882. dispose(): void;
  91883. /**
  91884. * Get the current object class name.
  91885. * @returns the class name.
  91886. */
  91887. getClassName(): string;
  91888. }
  91889. }
  91890. declare module BABYLON {
  91891. /**
  91892. * Listen to keyboard events to control the camera.
  91893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91894. */
  91895. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  91896. /**
  91897. * Defines the camera the input is attached to.
  91898. */
  91899. camera: FlyCamera;
  91900. /**
  91901. * The list of keyboard keys used to control the forward move of the camera.
  91902. */
  91903. keysForward: number[];
  91904. /**
  91905. * The list of keyboard keys used to control the backward move of the camera.
  91906. */
  91907. keysBackward: number[];
  91908. /**
  91909. * The list of keyboard keys used to control the forward move of the camera.
  91910. */
  91911. keysUp: number[];
  91912. /**
  91913. * The list of keyboard keys used to control the backward move of the camera.
  91914. */
  91915. keysDown: number[];
  91916. /**
  91917. * The list of keyboard keys used to control the right strafe move of the camera.
  91918. */
  91919. keysRight: number[];
  91920. /**
  91921. * The list of keyboard keys used to control the left strafe move of the camera.
  91922. */
  91923. keysLeft: number[];
  91924. private _keys;
  91925. private _onCanvasBlurObserver;
  91926. private _onKeyboardObserver;
  91927. private _engine;
  91928. private _scene;
  91929. /**
  91930. * Attach the input controls to a specific dom element to get the input from.
  91931. * @param element Defines the element the controls should be listened from
  91932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91933. */
  91934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91935. /**
  91936. * Detach the current controls from the specified dom element.
  91937. * @param element Defines the element to stop listening the inputs from
  91938. */
  91939. detachControl(element: Nullable<HTMLElement>): void;
  91940. /**
  91941. * Gets the class name of the current intput.
  91942. * @returns the class name
  91943. */
  91944. getClassName(): string;
  91945. /** @hidden */
  91946. _onLostFocus(e: FocusEvent): void;
  91947. /**
  91948. * Get the friendly name associated with the input class.
  91949. * @returns the input friendly name
  91950. */
  91951. getSimpleName(): string;
  91952. /**
  91953. * Update the current camera state depending on the inputs that have been used this frame.
  91954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91955. */
  91956. checkInputs(): void;
  91957. }
  91958. }
  91959. declare module BABYLON {
  91960. interface FreeCameraInputsManager {
  91961. /**
  91962. * Add orientation input support to the input manager.
  91963. * @returns the current input manager
  91964. */
  91965. addDeviceOrientation(): FreeCameraInputsManager;
  91966. }
  91967. /**
  91968. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  91969. * Screen rotation is taken into account.
  91970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91971. */
  91972. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  91973. private _camera;
  91974. private _screenOrientationAngle;
  91975. private _constantTranform;
  91976. private _screenQuaternion;
  91977. private _alpha;
  91978. private _beta;
  91979. private _gamma;
  91980. /**
  91981. * Instantiates a new input
  91982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91983. */
  91984. constructor();
  91985. /**
  91986. * Define the camera controlled by the input.
  91987. */
  91988. camera: FreeCamera;
  91989. /**
  91990. * Attach the input controls to a specific dom element to get the input from.
  91991. * @param element Defines the element the controls should be listened from
  91992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91993. */
  91994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91995. private _orientationChanged;
  91996. private _deviceOrientation;
  91997. /**
  91998. * Detach the current controls from the specified dom element.
  91999. * @param element Defines the element to stop listening the inputs from
  92000. */
  92001. detachControl(element: Nullable<HTMLElement>): void;
  92002. /**
  92003. * Update the current camera state depending on the inputs that have been used this frame.
  92004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92005. */
  92006. checkInputs(): void;
  92007. /**
  92008. * Gets the class name of the current intput.
  92009. * @returns the class name
  92010. */
  92011. getClassName(): string;
  92012. /**
  92013. * Get the friendly name associated with the input class.
  92014. * @returns the input friendly name
  92015. */
  92016. getSimpleName(): string;
  92017. }
  92018. }
  92019. declare module BABYLON {
  92020. /**
  92021. * Manage the gamepad inputs to control a free camera.
  92022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92023. */
  92024. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  92025. /**
  92026. * Define the camera the input is attached to.
  92027. */
  92028. camera: FreeCamera;
  92029. /**
  92030. * Define the Gamepad controlling the input
  92031. */
  92032. gamepad: Nullable<Gamepad>;
  92033. /**
  92034. * Defines the gamepad rotation sensiblity.
  92035. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92036. */
  92037. gamepadAngularSensibility: number;
  92038. /**
  92039. * Defines the gamepad move sensiblity.
  92040. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92041. */
  92042. gamepadMoveSensibility: number;
  92043. private _onGamepadConnectedObserver;
  92044. private _onGamepadDisconnectedObserver;
  92045. private _cameraTransform;
  92046. private _deltaTransform;
  92047. private _vector3;
  92048. private _vector2;
  92049. /**
  92050. * Attach the input controls to a specific dom element to get the input from.
  92051. * @param element Defines the element the controls should be listened from
  92052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92053. */
  92054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92055. /**
  92056. * Detach the current controls from the specified dom element.
  92057. * @param element Defines the element to stop listening the inputs from
  92058. */
  92059. detachControl(element: Nullable<HTMLElement>): void;
  92060. /**
  92061. * Update the current camera state depending on the inputs that have been used this frame.
  92062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92063. */
  92064. checkInputs(): void;
  92065. /**
  92066. * Gets the class name of the current intput.
  92067. * @returns the class name
  92068. */
  92069. getClassName(): string;
  92070. /**
  92071. * Get the friendly name associated with the input class.
  92072. * @returns the input friendly name
  92073. */
  92074. getSimpleName(): string;
  92075. }
  92076. }
  92077. declare module BABYLON {
  92078. /**
  92079. * Defines the potential axis of a Joystick
  92080. */
  92081. export enum JoystickAxis {
  92082. /** X axis */
  92083. X = 0,
  92084. /** Y axis */
  92085. Y = 1,
  92086. /** Z axis */
  92087. Z = 2
  92088. }
  92089. /**
  92090. * Class used to define virtual joystick (used in touch mode)
  92091. */
  92092. export class VirtualJoystick {
  92093. /**
  92094. * Gets or sets a boolean indicating that left and right values must be inverted
  92095. */
  92096. reverseLeftRight: boolean;
  92097. /**
  92098. * Gets or sets a boolean indicating that up and down values must be inverted
  92099. */
  92100. reverseUpDown: boolean;
  92101. /**
  92102. * Gets the offset value for the position (ie. the change of the position value)
  92103. */
  92104. deltaPosition: Vector3;
  92105. /**
  92106. * Gets a boolean indicating if the virtual joystick was pressed
  92107. */
  92108. pressed: boolean;
  92109. /**
  92110. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92111. */
  92112. static Canvas: Nullable<HTMLCanvasElement>;
  92113. private static _globalJoystickIndex;
  92114. private static vjCanvasContext;
  92115. private static vjCanvasWidth;
  92116. private static vjCanvasHeight;
  92117. private static halfWidth;
  92118. private _action;
  92119. private _axisTargetedByLeftAndRight;
  92120. private _axisTargetedByUpAndDown;
  92121. private _joystickSensibility;
  92122. private _inversedSensibility;
  92123. private _joystickPointerID;
  92124. private _joystickColor;
  92125. private _joystickPointerPos;
  92126. private _joystickPreviousPointerPos;
  92127. private _joystickPointerStartPos;
  92128. private _deltaJoystickVector;
  92129. private _leftJoystick;
  92130. private _touches;
  92131. private _onPointerDownHandlerRef;
  92132. private _onPointerMoveHandlerRef;
  92133. private _onPointerUpHandlerRef;
  92134. private _onResize;
  92135. /**
  92136. * Creates a new virtual joystick
  92137. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92138. */
  92139. constructor(leftJoystick?: boolean);
  92140. /**
  92141. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92142. * @param newJoystickSensibility defines the new sensibility
  92143. */
  92144. setJoystickSensibility(newJoystickSensibility: number): void;
  92145. private _onPointerDown;
  92146. private _onPointerMove;
  92147. private _onPointerUp;
  92148. /**
  92149. * Change the color of the virtual joystick
  92150. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92151. */
  92152. setJoystickColor(newColor: string): void;
  92153. /**
  92154. * Defines a callback to call when the joystick is touched
  92155. * @param action defines the callback
  92156. */
  92157. setActionOnTouch(action: () => any): void;
  92158. /**
  92159. * Defines which axis you'd like to control for left & right
  92160. * @param axis defines the axis to use
  92161. */
  92162. setAxisForLeftRight(axis: JoystickAxis): void;
  92163. /**
  92164. * Defines which axis you'd like to control for up & down
  92165. * @param axis defines the axis to use
  92166. */
  92167. setAxisForUpDown(axis: JoystickAxis): void;
  92168. private _drawVirtualJoystick;
  92169. /**
  92170. * Release internal HTML canvas
  92171. */
  92172. releaseCanvas(): void;
  92173. }
  92174. }
  92175. declare module BABYLON {
  92176. interface FreeCameraInputsManager {
  92177. /**
  92178. * Add virtual joystick input support to the input manager.
  92179. * @returns the current input manager
  92180. */
  92181. addVirtualJoystick(): FreeCameraInputsManager;
  92182. }
  92183. /**
  92184. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92186. */
  92187. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92188. /**
  92189. * Defines the camera the input is attached to.
  92190. */
  92191. camera: FreeCamera;
  92192. private _leftjoystick;
  92193. private _rightjoystick;
  92194. /**
  92195. * Gets the left stick of the virtual joystick.
  92196. * @returns The virtual Joystick
  92197. */
  92198. getLeftJoystick(): VirtualJoystick;
  92199. /**
  92200. * Gets the right stick of the virtual joystick.
  92201. * @returns The virtual Joystick
  92202. */
  92203. getRightJoystick(): VirtualJoystick;
  92204. /**
  92205. * Update the current camera state depending on the inputs that have been used this frame.
  92206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92207. */
  92208. checkInputs(): void;
  92209. /**
  92210. * Attach the input controls to a specific dom element to get the input from.
  92211. * @param element Defines the element the controls should be listened from
  92212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92213. */
  92214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92215. /**
  92216. * Detach the current controls from the specified dom element.
  92217. * @param element Defines the element to stop listening the inputs from
  92218. */
  92219. detachControl(element: Nullable<HTMLElement>): void;
  92220. /**
  92221. * Gets the class name of the current intput.
  92222. * @returns the class name
  92223. */
  92224. getClassName(): string;
  92225. /**
  92226. * Get the friendly name associated with the input class.
  92227. * @returns the input friendly name
  92228. */
  92229. getSimpleName(): string;
  92230. }
  92231. }
  92232. declare module BABYLON {
  92233. /**
  92234. * This represents a FPS type of camera controlled by touch.
  92235. * This is like a universal camera minus the Gamepad controls.
  92236. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92237. */
  92238. export class TouchCamera extends FreeCamera {
  92239. /**
  92240. * Defines the touch sensibility for rotation.
  92241. * The higher the faster.
  92242. */
  92243. touchAngularSensibility: number;
  92244. /**
  92245. * Defines the touch sensibility for move.
  92246. * The higher the faster.
  92247. */
  92248. touchMoveSensibility: number;
  92249. /**
  92250. * Instantiates a new touch camera.
  92251. * This represents a FPS type of camera controlled by touch.
  92252. * This is like a universal camera minus the Gamepad controls.
  92253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92254. * @param name Define the name of the camera in the scene
  92255. * @param position Define the start position of the camera in the scene
  92256. * @param scene Define the scene the camera belongs to
  92257. */
  92258. constructor(name: string, position: Vector3, scene: Scene);
  92259. /**
  92260. * Gets the current object class name.
  92261. * @return the class name
  92262. */
  92263. getClassName(): string;
  92264. /** @hidden */
  92265. _setupInputs(): void;
  92266. }
  92267. }
  92268. declare module BABYLON {
  92269. /**
  92270. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92271. * being tilted forward or back and left or right.
  92272. */
  92273. export class DeviceOrientationCamera extends FreeCamera {
  92274. private _initialQuaternion;
  92275. private _quaternionCache;
  92276. /**
  92277. * Creates a new device orientation camera
  92278. * @param name The name of the camera
  92279. * @param position The start position camera
  92280. * @param scene The scene the camera belongs to
  92281. */
  92282. constructor(name: string, position: Vector3, scene: Scene);
  92283. /**
  92284. * Gets the current instance class name ("DeviceOrientationCamera").
  92285. * This helps avoiding instanceof at run time.
  92286. * @returns the class name
  92287. */
  92288. getClassName(): string;
  92289. /**
  92290. * @hidden
  92291. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92292. */
  92293. _checkInputs(): void;
  92294. /**
  92295. * Reset the camera to its default orientation on the specified axis only.
  92296. * @param axis The axis to reset
  92297. */
  92298. resetToCurrentRotation(axis?: Axis): void;
  92299. }
  92300. }
  92301. declare module BABYLON {
  92302. /**
  92303. * Manage the keyboard inputs to control the movement of a follow camera.
  92304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92305. */
  92306. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92307. /**
  92308. * Defines the camera the input is attached to.
  92309. */
  92310. camera: FollowCamera;
  92311. /**
  92312. * Defines the list of key codes associated with the up action (increase heightOffset)
  92313. */
  92314. keysHeightOffsetIncr: number[];
  92315. /**
  92316. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92317. */
  92318. keysHeightOffsetDecr: number[];
  92319. /**
  92320. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92321. */
  92322. keysHeightOffsetModifierAlt: boolean;
  92323. /**
  92324. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92325. */
  92326. keysHeightOffsetModifierCtrl: boolean;
  92327. /**
  92328. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92329. */
  92330. keysHeightOffsetModifierShift: boolean;
  92331. /**
  92332. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92333. */
  92334. keysRotationOffsetIncr: number[];
  92335. /**
  92336. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92337. */
  92338. keysRotationOffsetDecr: number[];
  92339. /**
  92340. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92341. */
  92342. keysRotationOffsetModifierAlt: boolean;
  92343. /**
  92344. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92345. */
  92346. keysRotationOffsetModifierCtrl: boolean;
  92347. /**
  92348. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92349. */
  92350. keysRotationOffsetModifierShift: boolean;
  92351. /**
  92352. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92353. */
  92354. keysRadiusIncr: number[];
  92355. /**
  92356. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92357. */
  92358. keysRadiusDecr: number[];
  92359. /**
  92360. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92361. */
  92362. keysRadiusModifierAlt: boolean;
  92363. /**
  92364. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92365. */
  92366. keysRadiusModifierCtrl: boolean;
  92367. /**
  92368. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92369. */
  92370. keysRadiusModifierShift: boolean;
  92371. /**
  92372. * Defines the rate of change of heightOffset.
  92373. */
  92374. heightSensibility: number;
  92375. /**
  92376. * Defines the rate of change of rotationOffset.
  92377. */
  92378. rotationSensibility: number;
  92379. /**
  92380. * Defines the rate of change of radius.
  92381. */
  92382. radiusSensibility: number;
  92383. private _keys;
  92384. private _ctrlPressed;
  92385. private _altPressed;
  92386. private _shiftPressed;
  92387. private _onCanvasBlurObserver;
  92388. private _onKeyboardObserver;
  92389. private _engine;
  92390. private _scene;
  92391. /**
  92392. * Attach the input controls to a specific dom element to get the input from.
  92393. * @param element Defines the element the controls should be listened from
  92394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92395. */
  92396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92397. /**
  92398. * Detach the current controls from the specified dom element.
  92399. * @param element Defines the element to stop listening the inputs from
  92400. */
  92401. detachControl(element: Nullable<HTMLElement>): void;
  92402. /**
  92403. * Update the current camera state depending on the inputs that have been used this frame.
  92404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92405. */
  92406. checkInputs(): void;
  92407. /**
  92408. * Gets the class name of the current input.
  92409. * @returns the class name
  92410. */
  92411. getClassName(): string;
  92412. /**
  92413. * Get the friendly name associated with the input class.
  92414. * @returns the input friendly name
  92415. */
  92416. getSimpleName(): string;
  92417. /**
  92418. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92419. * allow modification of the heightOffset value.
  92420. */
  92421. private _modifierHeightOffset;
  92422. /**
  92423. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92424. * allow modification of the rotationOffset value.
  92425. */
  92426. private _modifierRotationOffset;
  92427. /**
  92428. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92429. * allow modification of the radius value.
  92430. */
  92431. private _modifierRadius;
  92432. }
  92433. }
  92434. declare module BABYLON {
  92435. /**
  92436. * Manage the mouse wheel inputs to control a follow camera.
  92437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92438. */
  92439. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92440. /**
  92441. * Defines the camera the input is attached to.
  92442. */
  92443. camera: FollowCamera;
  92444. /**
  92445. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92446. */
  92447. axisControlRadius: boolean;
  92448. /**
  92449. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92450. */
  92451. axisControlHeight: boolean;
  92452. /**
  92453. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92454. */
  92455. axisControlRotation: boolean;
  92456. /**
  92457. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92458. * relation to mouseWheel events.
  92459. */
  92460. wheelPrecision: number;
  92461. /**
  92462. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92463. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92464. */
  92465. wheelDeltaPercentage: number;
  92466. private _wheel;
  92467. private _observer;
  92468. /**
  92469. * Attach the input controls to a specific dom element to get the input from.
  92470. * @param element Defines the element the controls should be listened from
  92471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92472. */
  92473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92474. /**
  92475. * Detach the current controls from the specified dom element.
  92476. * @param element Defines the element to stop listening the inputs from
  92477. */
  92478. detachControl(element: Nullable<HTMLElement>): void;
  92479. /**
  92480. * Gets the class name of the current intput.
  92481. * @returns the class name
  92482. */
  92483. getClassName(): string;
  92484. /**
  92485. * Get the friendly name associated with the input class.
  92486. * @returns the input friendly name
  92487. */
  92488. getSimpleName(): string;
  92489. }
  92490. }
  92491. declare module BABYLON {
  92492. /**
  92493. * Default Inputs manager for the FollowCamera.
  92494. * It groups all the default supported inputs for ease of use.
  92495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92496. */
  92497. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92498. /**
  92499. * Instantiates a new FollowCameraInputsManager.
  92500. * @param camera Defines the camera the inputs belong to
  92501. */
  92502. constructor(camera: FollowCamera);
  92503. /**
  92504. * Add keyboard input support to the input manager.
  92505. * @returns the current input manager
  92506. */
  92507. addKeyboard(): FollowCameraInputsManager;
  92508. /**
  92509. * Add mouse wheel input support to the input manager.
  92510. * @returns the current input manager
  92511. */
  92512. addMouseWheel(): FollowCameraInputsManager;
  92513. /**
  92514. * Add pointers input support to the input manager.
  92515. * @returns the current input manager
  92516. */
  92517. addPointers(): FollowCameraInputsManager;
  92518. /**
  92519. * Add orientation input support to the input manager.
  92520. * @returns the current input manager
  92521. */
  92522. addVRDeviceOrientation(): FollowCameraInputsManager;
  92523. }
  92524. }
  92525. declare module BABYLON {
  92526. /**
  92527. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92528. * an arc rotate version arcFollowCamera are available.
  92529. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92530. */
  92531. export class FollowCamera extends TargetCamera {
  92532. /**
  92533. * Distance the follow camera should follow an object at
  92534. */
  92535. radius: number;
  92536. /**
  92537. * Minimum allowed distance of the camera to the axis of rotation
  92538. * (The camera can not get closer).
  92539. * This can help limiting how the Camera is able to move in the scene.
  92540. */
  92541. lowerRadiusLimit: Nullable<number>;
  92542. /**
  92543. * Maximum allowed distance of the camera to the axis of rotation
  92544. * (The camera can not get further).
  92545. * This can help limiting how the Camera is able to move in the scene.
  92546. */
  92547. upperRadiusLimit: Nullable<number>;
  92548. /**
  92549. * Define a rotation offset between the camera and the object it follows
  92550. */
  92551. rotationOffset: number;
  92552. /**
  92553. * Minimum allowed angle to camera position relative to target object.
  92554. * This can help limiting how the Camera is able to move in the scene.
  92555. */
  92556. lowerRotationOffsetLimit: Nullable<number>;
  92557. /**
  92558. * Maximum allowed angle to camera position relative to target object.
  92559. * This can help limiting how the Camera is able to move in the scene.
  92560. */
  92561. upperRotationOffsetLimit: Nullable<number>;
  92562. /**
  92563. * Define a height offset between the camera and the object it follows.
  92564. * It can help following an object from the top (like a car chaing a plane)
  92565. */
  92566. heightOffset: number;
  92567. /**
  92568. * Minimum allowed height of camera position relative to target object.
  92569. * This can help limiting how the Camera is able to move in the scene.
  92570. */
  92571. lowerHeightOffsetLimit: Nullable<number>;
  92572. /**
  92573. * Maximum allowed height of camera position relative to target object.
  92574. * This can help limiting how the Camera is able to move in the scene.
  92575. */
  92576. upperHeightOffsetLimit: Nullable<number>;
  92577. /**
  92578. * Define how fast the camera can accelerate to follow it s target.
  92579. */
  92580. cameraAcceleration: number;
  92581. /**
  92582. * Define the speed limit of the camera following an object.
  92583. */
  92584. maxCameraSpeed: number;
  92585. /**
  92586. * Define the target of the camera.
  92587. */
  92588. lockedTarget: Nullable<AbstractMesh>;
  92589. /**
  92590. * Defines the input associated with the camera.
  92591. */
  92592. inputs: FollowCameraInputsManager;
  92593. /**
  92594. * Instantiates the follow camera.
  92595. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92596. * @param name Define the name of the camera in the scene
  92597. * @param position Define the position of the camera
  92598. * @param scene Define the scene the camera belong to
  92599. * @param lockedTarget Define the target of the camera
  92600. */
  92601. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  92602. private _follow;
  92603. /**
  92604. * Attached controls to the current camera.
  92605. * @param element Defines the element the controls should be listened from
  92606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92607. */
  92608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92609. /**
  92610. * Detach the current controls from the camera.
  92611. * The camera will stop reacting to inputs.
  92612. * @param element Defines the element to stop listening the inputs from
  92613. */
  92614. detachControl(element: HTMLElement): void;
  92615. /** @hidden */
  92616. _checkInputs(): void;
  92617. private _checkLimits;
  92618. /**
  92619. * Gets the camera class name.
  92620. * @returns the class name
  92621. */
  92622. getClassName(): string;
  92623. }
  92624. /**
  92625. * Arc Rotate version of the follow camera.
  92626. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  92627. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92628. */
  92629. export class ArcFollowCamera extends TargetCamera {
  92630. /** The longitudinal angle of the camera */
  92631. alpha: number;
  92632. /** The latitudinal angle of the camera */
  92633. beta: number;
  92634. /** The radius of the camera from its target */
  92635. radius: number;
  92636. /** Define the camera target (the messh it should follow) */
  92637. target: Nullable<AbstractMesh>;
  92638. private _cartesianCoordinates;
  92639. /**
  92640. * Instantiates a new ArcFollowCamera
  92641. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92642. * @param name Define the name of the camera
  92643. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  92644. * @param beta Define the rotation angle of the camera around the elevation axis
  92645. * @param radius Define the radius of the camera from its target point
  92646. * @param target Define the target of the camera
  92647. * @param scene Define the scene the camera belongs to
  92648. */
  92649. constructor(name: string,
  92650. /** The longitudinal angle of the camera */
  92651. alpha: number,
  92652. /** The latitudinal angle of the camera */
  92653. beta: number,
  92654. /** The radius of the camera from its target */
  92655. radius: number,
  92656. /** Define the camera target (the messh it should follow) */
  92657. target: Nullable<AbstractMesh>, scene: Scene);
  92658. private _follow;
  92659. /** @hidden */
  92660. _checkInputs(): void;
  92661. /**
  92662. * Returns the class name of the object.
  92663. * It is mostly used internally for serialization purposes.
  92664. */
  92665. getClassName(): string;
  92666. }
  92667. }
  92668. declare module BABYLON {
  92669. /**
  92670. * 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,
  92671. * which still works and will still be found in many Playgrounds.
  92672. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92673. */
  92674. export class UniversalCamera extends TouchCamera {
  92675. /**
  92676. * Defines the gamepad rotation sensiblity.
  92677. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92678. */
  92679. gamepadAngularSensibility: number;
  92680. /**
  92681. * Defines the gamepad move sensiblity.
  92682. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92683. */
  92684. gamepadMoveSensibility: number;
  92685. /**
  92686. * 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,
  92687. * which still works and will still be found in many Playgrounds.
  92688. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92689. * @param name Define the name of the camera in the scene
  92690. * @param position Define the start position of the camera in the scene
  92691. * @param scene Define the scene the camera belongs to
  92692. */
  92693. constructor(name: string, position: Vector3, scene: Scene);
  92694. /**
  92695. * Gets the current object class name.
  92696. * @return the class name
  92697. */
  92698. getClassName(): string;
  92699. }
  92700. }
  92701. declare module BABYLON {
  92702. /**
  92703. * This represents a FPS type of camera. This is only here for back compat purpose.
  92704. * Please use the UniversalCamera instead as both are identical.
  92705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92706. */
  92707. export class GamepadCamera extends UniversalCamera {
  92708. /**
  92709. * Instantiates a new Gamepad Camera
  92710. * This represents a FPS type of camera. This is only here for back compat purpose.
  92711. * Please use the UniversalCamera instead as both are identical.
  92712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92713. * @param name Define the name of the camera in the scene
  92714. * @param position Define the start position of the camera in the scene
  92715. * @param scene Define the scene the camera belongs to
  92716. */
  92717. constructor(name: string, position: Vector3, scene: Scene);
  92718. /**
  92719. * Gets the current object class name.
  92720. * @return the class name
  92721. */
  92722. getClassName(): string;
  92723. }
  92724. }
  92725. declare module BABYLON {
  92726. /** @hidden */
  92727. export var passPixelShader: {
  92728. name: string;
  92729. shader: string;
  92730. };
  92731. }
  92732. declare module BABYLON {
  92733. /** @hidden */
  92734. export var passCubePixelShader: {
  92735. name: string;
  92736. shader: string;
  92737. };
  92738. }
  92739. declare module BABYLON {
  92740. /**
  92741. * PassPostProcess which produces an output the same as it's input
  92742. */
  92743. export class PassPostProcess extends PostProcess {
  92744. /**
  92745. * Creates the PassPostProcess
  92746. * @param name The name of the effect.
  92747. * @param options The required width/height ratio to downsize to before computing the render pass.
  92748. * @param camera The camera to apply the render pass to.
  92749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92750. * @param engine The engine which the post process will be applied. (default: current engine)
  92751. * @param reusable If the post process can be reused on the same frame. (default: false)
  92752. * @param textureType The type of texture to be used when performing the post processing.
  92753. * @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)
  92754. */
  92755. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92756. }
  92757. /**
  92758. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  92759. */
  92760. export class PassCubePostProcess extends PostProcess {
  92761. private _face;
  92762. /**
  92763. * Gets or sets the cube face to display.
  92764. * * 0 is +X
  92765. * * 1 is -X
  92766. * * 2 is +Y
  92767. * * 3 is -Y
  92768. * * 4 is +Z
  92769. * * 5 is -Z
  92770. */
  92771. face: number;
  92772. /**
  92773. * Creates the PassCubePostProcess
  92774. * @param name The name of the effect.
  92775. * @param options The required width/height ratio to downsize to before computing the render pass.
  92776. * @param camera The camera to apply the render pass to.
  92777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92778. * @param engine The engine which the post process will be applied. (default: current engine)
  92779. * @param reusable If the post process can be reused on the same frame. (default: false)
  92780. * @param textureType The type of texture to be used when performing the post processing.
  92781. * @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)
  92782. */
  92783. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92784. }
  92785. }
  92786. declare module BABYLON {
  92787. /** @hidden */
  92788. export var anaglyphPixelShader: {
  92789. name: string;
  92790. shader: string;
  92791. };
  92792. }
  92793. declare module BABYLON {
  92794. /**
  92795. * Postprocess used to generate anaglyphic rendering
  92796. */
  92797. export class AnaglyphPostProcess extends PostProcess {
  92798. private _passedProcess;
  92799. /**
  92800. * Creates a new AnaglyphPostProcess
  92801. * @param name defines postprocess name
  92802. * @param options defines creation options or target ratio scale
  92803. * @param rigCameras defines cameras using this postprocess
  92804. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  92805. * @param engine defines hosting engine
  92806. * @param reusable defines if the postprocess will be reused multiple times per frame
  92807. */
  92808. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  92809. }
  92810. }
  92811. declare module BABYLON {
  92812. /**
  92813. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  92814. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92815. */
  92816. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  92817. /**
  92818. * Creates a new AnaglyphArcRotateCamera
  92819. * @param name defines camera name
  92820. * @param alpha defines alpha angle (in radians)
  92821. * @param beta defines beta angle (in radians)
  92822. * @param radius defines radius
  92823. * @param target defines camera target
  92824. * @param interaxialDistance defines distance between each color axis
  92825. * @param scene defines the hosting scene
  92826. */
  92827. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  92828. /**
  92829. * Gets camera class name
  92830. * @returns AnaglyphArcRotateCamera
  92831. */
  92832. getClassName(): string;
  92833. }
  92834. }
  92835. declare module BABYLON {
  92836. /**
  92837. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  92838. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92839. */
  92840. export class AnaglyphFreeCamera extends FreeCamera {
  92841. /**
  92842. * Creates a new AnaglyphFreeCamera
  92843. * @param name defines camera name
  92844. * @param position defines initial position
  92845. * @param interaxialDistance defines distance between each color axis
  92846. * @param scene defines the hosting scene
  92847. */
  92848. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92849. /**
  92850. * Gets camera class name
  92851. * @returns AnaglyphFreeCamera
  92852. */
  92853. getClassName(): string;
  92854. }
  92855. }
  92856. declare module BABYLON {
  92857. /**
  92858. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  92859. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92860. */
  92861. export class AnaglyphGamepadCamera extends GamepadCamera {
  92862. /**
  92863. * Creates a new AnaglyphGamepadCamera
  92864. * @param name defines camera name
  92865. * @param position defines initial position
  92866. * @param interaxialDistance defines distance between each color axis
  92867. * @param scene defines the hosting scene
  92868. */
  92869. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92870. /**
  92871. * Gets camera class name
  92872. * @returns AnaglyphGamepadCamera
  92873. */
  92874. getClassName(): string;
  92875. }
  92876. }
  92877. declare module BABYLON {
  92878. /**
  92879. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  92880. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92881. */
  92882. export class AnaglyphUniversalCamera extends UniversalCamera {
  92883. /**
  92884. * Creates a new AnaglyphUniversalCamera
  92885. * @param name defines camera name
  92886. * @param position defines initial position
  92887. * @param interaxialDistance defines distance between each color axis
  92888. * @param scene defines the hosting scene
  92889. */
  92890. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92891. /**
  92892. * Gets camera class name
  92893. * @returns AnaglyphUniversalCamera
  92894. */
  92895. getClassName(): string;
  92896. }
  92897. }
  92898. declare module BABYLON {
  92899. /** @hidden */
  92900. export var stereoscopicInterlacePixelShader: {
  92901. name: string;
  92902. shader: string;
  92903. };
  92904. }
  92905. declare module BABYLON {
  92906. /**
  92907. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  92908. */
  92909. export class StereoscopicInterlacePostProcess extends PostProcess {
  92910. private _stepSize;
  92911. private _passedProcess;
  92912. /**
  92913. * Initializes a StereoscopicInterlacePostProcess
  92914. * @param name The name of the effect.
  92915. * @param rigCameras The rig cameras to be appled to the post process
  92916. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  92917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92918. * @param engine The engine which the post process will be applied. (default: current engine)
  92919. * @param reusable If the post process can be reused on the same frame. (default: false)
  92920. */
  92921. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  92922. }
  92923. }
  92924. declare module BABYLON {
  92925. /**
  92926. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  92927. * @see http://doc.babylonjs.com/features/cameras
  92928. */
  92929. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  92930. /**
  92931. * Creates a new StereoscopicArcRotateCamera
  92932. * @param name defines camera name
  92933. * @param alpha defines alpha angle (in radians)
  92934. * @param beta defines beta angle (in radians)
  92935. * @param radius defines radius
  92936. * @param target defines camera target
  92937. * @param interaxialDistance defines distance between each color axis
  92938. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92939. * @param scene defines the hosting scene
  92940. */
  92941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92942. /**
  92943. * Gets camera class name
  92944. * @returns StereoscopicArcRotateCamera
  92945. */
  92946. getClassName(): string;
  92947. }
  92948. }
  92949. declare module BABYLON {
  92950. /**
  92951. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  92952. * @see http://doc.babylonjs.com/features/cameras
  92953. */
  92954. export class StereoscopicFreeCamera extends FreeCamera {
  92955. /**
  92956. * Creates a new StereoscopicFreeCamera
  92957. * @param name defines camera name
  92958. * @param position defines initial position
  92959. * @param interaxialDistance defines distance between each color axis
  92960. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92961. * @param scene defines the hosting scene
  92962. */
  92963. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92964. /**
  92965. * Gets camera class name
  92966. * @returns StereoscopicFreeCamera
  92967. */
  92968. getClassName(): string;
  92969. }
  92970. }
  92971. declare module BABYLON {
  92972. /**
  92973. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  92974. * @see http://doc.babylonjs.com/features/cameras
  92975. */
  92976. export class StereoscopicGamepadCamera extends GamepadCamera {
  92977. /**
  92978. * Creates a new StereoscopicGamepadCamera
  92979. * @param name defines camera name
  92980. * @param position defines initial position
  92981. * @param interaxialDistance defines distance between each color axis
  92982. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92983. * @param scene defines the hosting scene
  92984. */
  92985. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92986. /**
  92987. * Gets camera class name
  92988. * @returns StereoscopicGamepadCamera
  92989. */
  92990. getClassName(): string;
  92991. }
  92992. }
  92993. declare module BABYLON {
  92994. /**
  92995. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  92996. * @see http://doc.babylonjs.com/features/cameras
  92997. */
  92998. export class StereoscopicUniversalCamera extends UniversalCamera {
  92999. /**
  93000. * Creates a new StereoscopicUniversalCamera
  93001. * @param name defines camera name
  93002. * @param position defines initial position
  93003. * @param interaxialDistance defines distance between each color axis
  93004. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93005. * @param scene defines the hosting scene
  93006. */
  93007. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93008. /**
  93009. * Gets camera class name
  93010. * @returns StereoscopicUniversalCamera
  93011. */
  93012. getClassName(): string;
  93013. }
  93014. }
  93015. declare module BABYLON {
  93016. /**
  93017. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93018. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93019. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93020. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93021. */
  93022. export class VirtualJoysticksCamera extends FreeCamera {
  93023. /**
  93024. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  93025. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93026. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93027. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93028. * @param name Define the name of the camera in the scene
  93029. * @param position Define the start position of the camera in the scene
  93030. * @param scene Define the scene the camera belongs to
  93031. */
  93032. constructor(name: string, position: Vector3, scene: Scene);
  93033. /**
  93034. * Gets the current object class name.
  93035. * @return the class name
  93036. */
  93037. getClassName(): string;
  93038. }
  93039. }
  93040. declare module BABYLON {
  93041. /**
  93042. * This represents all the required metrics to create a VR camera.
  93043. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  93044. */
  93045. export class VRCameraMetrics {
  93046. /**
  93047. * Define the horizontal resolution off the screen.
  93048. */
  93049. hResolution: number;
  93050. /**
  93051. * Define the vertical resolution off the screen.
  93052. */
  93053. vResolution: number;
  93054. /**
  93055. * Define the horizontal screen size.
  93056. */
  93057. hScreenSize: number;
  93058. /**
  93059. * Define the vertical screen size.
  93060. */
  93061. vScreenSize: number;
  93062. /**
  93063. * Define the vertical screen center position.
  93064. */
  93065. vScreenCenter: number;
  93066. /**
  93067. * Define the distance of the eyes to the screen.
  93068. */
  93069. eyeToScreenDistance: number;
  93070. /**
  93071. * Define the distance between both lenses
  93072. */
  93073. lensSeparationDistance: number;
  93074. /**
  93075. * Define the distance between both viewer's eyes.
  93076. */
  93077. interpupillaryDistance: number;
  93078. /**
  93079. * Define the distortion factor of the VR postprocess.
  93080. * Please, touch with care.
  93081. */
  93082. distortionK: number[];
  93083. /**
  93084. * Define the chromatic aberration correction factors for the VR post process.
  93085. */
  93086. chromaAbCorrection: number[];
  93087. /**
  93088. * Define the scale factor of the post process.
  93089. * The smaller the better but the slower.
  93090. */
  93091. postProcessScaleFactor: number;
  93092. /**
  93093. * Define an offset for the lens center.
  93094. */
  93095. lensCenterOffset: number;
  93096. /**
  93097. * Define if the current vr camera should compensate the distortion of the lense or not.
  93098. */
  93099. compensateDistortion: boolean;
  93100. /**
  93101. * Gets the rendering aspect ratio based on the provided resolutions.
  93102. */
  93103. readonly aspectRatio: number;
  93104. /**
  93105. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93106. */
  93107. readonly aspectRatioFov: number;
  93108. /**
  93109. * @hidden
  93110. */
  93111. readonly leftHMatrix: Matrix;
  93112. /**
  93113. * @hidden
  93114. */
  93115. readonly rightHMatrix: Matrix;
  93116. /**
  93117. * @hidden
  93118. */
  93119. readonly leftPreViewMatrix: Matrix;
  93120. /**
  93121. * @hidden
  93122. */
  93123. readonly rightPreViewMatrix: Matrix;
  93124. /**
  93125. * Get the default VRMetrics based on the most generic setup.
  93126. * @returns the default vr metrics
  93127. */
  93128. static GetDefault(): VRCameraMetrics;
  93129. }
  93130. }
  93131. declare module BABYLON {
  93132. /** @hidden */
  93133. export var vrDistortionCorrectionPixelShader: {
  93134. name: string;
  93135. shader: string;
  93136. };
  93137. }
  93138. declare module BABYLON {
  93139. /**
  93140. * VRDistortionCorrectionPostProcess used for mobile VR
  93141. */
  93142. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93143. private _isRightEye;
  93144. private _distortionFactors;
  93145. private _postProcessScaleFactor;
  93146. private _lensCenterOffset;
  93147. private _scaleIn;
  93148. private _scaleFactor;
  93149. private _lensCenter;
  93150. /**
  93151. * Initializes the VRDistortionCorrectionPostProcess
  93152. * @param name The name of the effect.
  93153. * @param camera The camera to apply the render pass to.
  93154. * @param isRightEye If this is for the right eye distortion
  93155. * @param vrMetrics All the required metrics for the VR camera
  93156. */
  93157. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93158. }
  93159. }
  93160. declare module BABYLON {
  93161. /**
  93162. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93163. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93164. */
  93165. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93166. /**
  93167. * Creates a new VRDeviceOrientationArcRotateCamera
  93168. * @param name defines camera name
  93169. * @param alpha defines the camera rotation along the logitudinal axis
  93170. * @param beta defines the camera rotation along the latitudinal axis
  93171. * @param radius defines the camera distance from its target
  93172. * @param target defines the camera target
  93173. * @param scene defines the scene the camera belongs to
  93174. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93175. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93176. */
  93177. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93178. /**
  93179. * Gets camera class name
  93180. * @returns VRDeviceOrientationArcRotateCamera
  93181. */
  93182. getClassName(): string;
  93183. }
  93184. }
  93185. declare module BABYLON {
  93186. /**
  93187. * Camera used to simulate VR rendering (based on FreeCamera)
  93188. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93189. */
  93190. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93191. /**
  93192. * Creates a new VRDeviceOrientationFreeCamera
  93193. * @param name defines camera name
  93194. * @param position defines the start position of the camera
  93195. * @param scene defines the scene the camera belongs to
  93196. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93197. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93198. */
  93199. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93200. /**
  93201. * Gets camera class name
  93202. * @returns VRDeviceOrientationFreeCamera
  93203. */
  93204. getClassName(): string;
  93205. }
  93206. }
  93207. declare module BABYLON {
  93208. /**
  93209. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93210. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93211. */
  93212. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93213. /**
  93214. * Creates a new VRDeviceOrientationGamepadCamera
  93215. * @param name defines camera name
  93216. * @param position defines the start position of the camera
  93217. * @param scene defines the scene the camera belongs to
  93218. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93219. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93220. */
  93221. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93222. /**
  93223. * Gets camera class name
  93224. * @returns VRDeviceOrientationGamepadCamera
  93225. */
  93226. getClassName(): string;
  93227. }
  93228. }
  93229. declare module BABYLON {
  93230. /**
  93231. * Defines supported buttons for XBox360 compatible gamepads
  93232. */
  93233. export enum Xbox360Button {
  93234. /** A */
  93235. A = 0,
  93236. /** B */
  93237. B = 1,
  93238. /** X */
  93239. X = 2,
  93240. /** Y */
  93241. Y = 3,
  93242. /** Start */
  93243. Start = 4,
  93244. /** Back */
  93245. Back = 5,
  93246. /** Left button */
  93247. LB = 6,
  93248. /** Right button */
  93249. RB = 7,
  93250. /** Left stick */
  93251. LeftStick = 8,
  93252. /** Right stick */
  93253. RightStick = 9
  93254. }
  93255. /** Defines values for XBox360 DPad */
  93256. export enum Xbox360Dpad {
  93257. /** Up */
  93258. Up = 0,
  93259. /** Down */
  93260. Down = 1,
  93261. /** Left */
  93262. Left = 2,
  93263. /** Right */
  93264. Right = 3
  93265. }
  93266. /**
  93267. * Defines a XBox360 gamepad
  93268. */
  93269. export class Xbox360Pad extends Gamepad {
  93270. private _leftTrigger;
  93271. private _rightTrigger;
  93272. private _onlefttriggerchanged;
  93273. private _onrighttriggerchanged;
  93274. private _onbuttondown;
  93275. private _onbuttonup;
  93276. private _ondpaddown;
  93277. private _ondpadup;
  93278. /** Observable raised when a button is pressed */
  93279. onButtonDownObservable: Observable<Xbox360Button>;
  93280. /** Observable raised when a button is released */
  93281. onButtonUpObservable: Observable<Xbox360Button>;
  93282. /** Observable raised when a pad is pressed */
  93283. onPadDownObservable: Observable<Xbox360Dpad>;
  93284. /** Observable raised when a pad is released */
  93285. onPadUpObservable: Observable<Xbox360Dpad>;
  93286. private _buttonA;
  93287. private _buttonB;
  93288. private _buttonX;
  93289. private _buttonY;
  93290. private _buttonBack;
  93291. private _buttonStart;
  93292. private _buttonLB;
  93293. private _buttonRB;
  93294. private _buttonLeftStick;
  93295. private _buttonRightStick;
  93296. private _dPadUp;
  93297. private _dPadDown;
  93298. private _dPadLeft;
  93299. private _dPadRight;
  93300. private _isXboxOnePad;
  93301. /**
  93302. * Creates a new XBox360 gamepad object
  93303. * @param id defines the id of this gamepad
  93304. * @param index defines its index
  93305. * @param gamepad defines the internal HTML gamepad object
  93306. * @param xboxOne defines if it is a XBox One gamepad
  93307. */
  93308. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93309. /**
  93310. * Defines the callback to call when left trigger is pressed
  93311. * @param callback defines the callback to use
  93312. */
  93313. onlefttriggerchanged(callback: (value: number) => void): void;
  93314. /**
  93315. * Defines the callback to call when right trigger is pressed
  93316. * @param callback defines the callback to use
  93317. */
  93318. onrighttriggerchanged(callback: (value: number) => void): void;
  93319. /**
  93320. * Gets the left trigger value
  93321. */
  93322. /**
  93323. * Sets the left trigger value
  93324. */
  93325. leftTrigger: number;
  93326. /**
  93327. * Gets the right trigger value
  93328. */
  93329. /**
  93330. * Sets the right trigger value
  93331. */
  93332. rightTrigger: number;
  93333. /**
  93334. * Defines the callback to call when a button is pressed
  93335. * @param callback defines the callback to use
  93336. */
  93337. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93338. /**
  93339. * Defines the callback to call when a button is released
  93340. * @param callback defines the callback to use
  93341. */
  93342. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93343. /**
  93344. * Defines the callback to call when a pad is pressed
  93345. * @param callback defines the callback to use
  93346. */
  93347. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93348. /**
  93349. * Defines the callback to call when a pad is released
  93350. * @param callback defines the callback to use
  93351. */
  93352. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93353. private _setButtonValue;
  93354. private _setDPadValue;
  93355. /**
  93356. * Gets the value of the `A` button
  93357. */
  93358. /**
  93359. * Sets the value of the `A` button
  93360. */
  93361. buttonA: number;
  93362. /**
  93363. * Gets the value of the `B` button
  93364. */
  93365. /**
  93366. * Sets the value of the `B` button
  93367. */
  93368. buttonB: number;
  93369. /**
  93370. * Gets the value of the `X` button
  93371. */
  93372. /**
  93373. * Sets the value of the `X` button
  93374. */
  93375. buttonX: number;
  93376. /**
  93377. * Gets the value of the `Y` button
  93378. */
  93379. /**
  93380. * Sets the value of the `Y` button
  93381. */
  93382. buttonY: number;
  93383. /**
  93384. * Gets the value of the `Start` button
  93385. */
  93386. /**
  93387. * Sets the value of the `Start` button
  93388. */
  93389. buttonStart: number;
  93390. /**
  93391. * Gets the value of the `Back` button
  93392. */
  93393. /**
  93394. * Sets the value of the `Back` button
  93395. */
  93396. buttonBack: number;
  93397. /**
  93398. * Gets the value of the `Left` button
  93399. */
  93400. /**
  93401. * Sets the value of the `Left` button
  93402. */
  93403. buttonLB: number;
  93404. /**
  93405. * Gets the value of the `Right` button
  93406. */
  93407. /**
  93408. * Sets the value of the `Right` button
  93409. */
  93410. buttonRB: number;
  93411. /**
  93412. * Gets the value of the Left joystick
  93413. */
  93414. /**
  93415. * Sets the value of the Left joystick
  93416. */
  93417. buttonLeftStick: number;
  93418. /**
  93419. * Gets the value of the Right joystick
  93420. */
  93421. /**
  93422. * Sets the value of the Right joystick
  93423. */
  93424. buttonRightStick: number;
  93425. /**
  93426. * Gets the value of D-pad up
  93427. */
  93428. /**
  93429. * Sets the value of D-pad up
  93430. */
  93431. dPadUp: number;
  93432. /**
  93433. * Gets the value of D-pad down
  93434. */
  93435. /**
  93436. * Sets the value of D-pad down
  93437. */
  93438. dPadDown: number;
  93439. /**
  93440. * Gets the value of D-pad left
  93441. */
  93442. /**
  93443. * Sets the value of D-pad left
  93444. */
  93445. dPadLeft: number;
  93446. /**
  93447. * Gets the value of D-pad right
  93448. */
  93449. /**
  93450. * Sets the value of D-pad right
  93451. */
  93452. dPadRight: number;
  93453. /**
  93454. * Force the gamepad to synchronize with device values
  93455. */
  93456. update(): void;
  93457. /**
  93458. * Disposes the gamepad
  93459. */
  93460. dispose(): void;
  93461. }
  93462. }
  93463. declare module BABYLON {
  93464. /**
  93465. * Base class of materials working in push mode in babylon JS
  93466. * @hidden
  93467. */
  93468. export class PushMaterial extends Material {
  93469. protected _activeEffect: Effect;
  93470. protected _normalMatrix: Matrix;
  93471. /**
  93472. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93473. * This means that the material can keep using a previous shader while a new one is being compiled.
  93474. * This is mostly used when shader parallel compilation is supported (true by default)
  93475. */
  93476. allowShaderHotSwapping: boolean;
  93477. constructor(name: string, scene: Scene);
  93478. getEffect(): Effect;
  93479. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93480. /**
  93481. * Binds the given world matrix to the active effect
  93482. *
  93483. * @param world the matrix to bind
  93484. */
  93485. bindOnlyWorldMatrix(world: Matrix): void;
  93486. /**
  93487. * Binds the given normal matrix to the active effect
  93488. *
  93489. * @param normalMatrix the matrix to bind
  93490. */
  93491. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93492. bind(world: Matrix, mesh?: Mesh): void;
  93493. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93494. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93495. }
  93496. }
  93497. declare module BABYLON {
  93498. /**
  93499. * This groups all the flags used to control the materials channel.
  93500. */
  93501. export class MaterialFlags {
  93502. private static _DiffuseTextureEnabled;
  93503. /**
  93504. * Are diffuse textures enabled in the application.
  93505. */
  93506. static DiffuseTextureEnabled: boolean;
  93507. private static _AmbientTextureEnabled;
  93508. /**
  93509. * Are ambient textures enabled in the application.
  93510. */
  93511. static AmbientTextureEnabled: boolean;
  93512. private static _OpacityTextureEnabled;
  93513. /**
  93514. * Are opacity textures enabled in the application.
  93515. */
  93516. static OpacityTextureEnabled: boolean;
  93517. private static _ReflectionTextureEnabled;
  93518. /**
  93519. * Are reflection textures enabled in the application.
  93520. */
  93521. static ReflectionTextureEnabled: boolean;
  93522. private static _EmissiveTextureEnabled;
  93523. /**
  93524. * Are emissive textures enabled in the application.
  93525. */
  93526. static EmissiveTextureEnabled: boolean;
  93527. private static _SpecularTextureEnabled;
  93528. /**
  93529. * Are specular textures enabled in the application.
  93530. */
  93531. static SpecularTextureEnabled: boolean;
  93532. private static _BumpTextureEnabled;
  93533. /**
  93534. * Are bump textures enabled in the application.
  93535. */
  93536. static BumpTextureEnabled: boolean;
  93537. private static _LightmapTextureEnabled;
  93538. /**
  93539. * Are lightmap textures enabled in the application.
  93540. */
  93541. static LightmapTextureEnabled: boolean;
  93542. private static _RefractionTextureEnabled;
  93543. /**
  93544. * Are refraction textures enabled in the application.
  93545. */
  93546. static RefractionTextureEnabled: boolean;
  93547. private static _ColorGradingTextureEnabled;
  93548. /**
  93549. * Are color grading textures enabled in the application.
  93550. */
  93551. static ColorGradingTextureEnabled: boolean;
  93552. private static _FresnelEnabled;
  93553. /**
  93554. * Are fresnels enabled in the application.
  93555. */
  93556. static FresnelEnabled: boolean;
  93557. }
  93558. }
  93559. declare module BABYLON {
  93560. /** @hidden */
  93561. export var defaultFragmentDeclaration: {
  93562. name: string;
  93563. shader: string;
  93564. };
  93565. }
  93566. declare module BABYLON {
  93567. /** @hidden */
  93568. export var defaultUboDeclaration: {
  93569. name: string;
  93570. shader: string;
  93571. };
  93572. }
  93573. declare module BABYLON {
  93574. /** @hidden */
  93575. export var lightFragmentDeclaration: {
  93576. name: string;
  93577. shader: string;
  93578. };
  93579. }
  93580. declare module BABYLON {
  93581. /** @hidden */
  93582. export var lightUboDeclaration: {
  93583. name: string;
  93584. shader: string;
  93585. };
  93586. }
  93587. declare module BABYLON {
  93588. /** @hidden */
  93589. export var lightsFragmentFunctions: {
  93590. name: string;
  93591. shader: string;
  93592. };
  93593. }
  93594. declare module BABYLON {
  93595. /** @hidden */
  93596. export var shadowsFragmentFunctions: {
  93597. name: string;
  93598. shader: string;
  93599. };
  93600. }
  93601. declare module BABYLON {
  93602. /** @hidden */
  93603. export var fresnelFunction: {
  93604. name: string;
  93605. shader: string;
  93606. };
  93607. }
  93608. declare module BABYLON {
  93609. /** @hidden */
  93610. export var reflectionFunction: {
  93611. name: string;
  93612. shader: string;
  93613. };
  93614. }
  93615. declare module BABYLON {
  93616. /** @hidden */
  93617. export var bumpFragmentFunctions: {
  93618. name: string;
  93619. shader: string;
  93620. };
  93621. }
  93622. declare module BABYLON {
  93623. /** @hidden */
  93624. export var logDepthDeclaration: {
  93625. name: string;
  93626. shader: string;
  93627. };
  93628. }
  93629. declare module BABYLON {
  93630. /** @hidden */
  93631. export var bumpFragment: {
  93632. name: string;
  93633. shader: string;
  93634. };
  93635. }
  93636. declare module BABYLON {
  93637. /** @hidden */
  93638. export var depthPrePass: {
  93639. name: string;
  93640. shader: string;
  93641. };
  93642. }
  93643. declare module BABYLON {
  93644. /** @hidden */
  93645. export var lightFragment: {
  93646. name: string;
  93647. shader: string;
  93648. };
  93649. }
  93650. declare module BABYLON {
  93651. /** @hidden */
  93652. export var logDepthFragment: {
  93653. name: string;
  93654. shader: string;
  93655. };
  93656. }
  93657. declare module BABYLON {
  93658. /** @hidden */
  93659. export var defaultPixelShader: {
  93660. name: string;
  93661. shader: string;
  93662. };
  93663. }
  93664. declare module BABYLON {
  93665. /** @hidden */
  93666. export var defaultVertexDeclaration: {
  93667. name: string;
  93668. shader: string;
  93669. };
  93670. }
  93671. declare module BABYLON {
  93672. /** @hidden */
  93673. export var bumpVertexDeclaration: {
  93674. name: string;
  93675. shader: string;
  93676. };
  93677. }
  93678. declare module BABYLON {
  93679. /** @hidden */
  93680. export var bumpVertex: {
  93681. name: string;
  93682. shader: string;
  93683. };
  93684. }
  93685. declare module BABYLON {
  93686. /** @hidden */
  93687. export var fogVertex: {
  93688. name: string;
  93689. shader: string;
  93690. };
  93691. }
  93692. declare module BABYLON {
  93693. /** @hidden */
  93694. export var shadowsVertex: {
  93695. name: string;
  93696. shader: string;
  93697. };
  93698. }
  93699. declare module BABYLON {
  93700. /** @hidden */
  93701. export var pointCloudVertex: {
  93702. name: string;
  93703. shader: string;
  93704. };
  93705. }
  93706. declare module BABYLON {
  93707. /** @hidden */
  93708. export var logDepthVertex: {
  93709. name: string;
  93710. shader: string;
  93711. };
  93712. }
  93713. declare module BABYLON {
  93714. /** @hidden */
  93715. export var defaultVertexShader: {
  93716. name: string;
  93717. shader: string;
  93718. };
  93719. }
  93720. declare module BABYLON {
  93721. /** @hidden */
  93722. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93723. MAINUV1: boolean;
  93724. MAINUV2: boolean;
  93725. DIFFUSE: boolean;
  93726. DIFFUSEDIRECTUV: number;
  93727. AMBIENT: boolean;
  93728. AMBIENTDIRECTUV: number;
  93729. OPACITY: boolean;
  93730. OPACITYDIRECTUV: number;
  93731. OPACITYRGB: boolean;
  93732. REFLECTION: boolean;
  93733. EMISSIVE: boolean;
  93734. EMISSIVEDIRECTUV: number;
  93735. SPECULAR: boolean;
  93736. SPECULARDIRECTUV: number;
  93737. BUMP: boolean;
  93738. BUMPDIRECTUV: number;
  93739. PARALLAX: boolean;
  93740. PARALLAXOCCLUSION: boolean;
  93741. SPECULAROVERALPHA: boolean;
  93742. CLIPPLANE: boolean;
  93743. CLIPPLANE2: boolean;
  93744. CLIPPLANE3: boolean;
  93745. CLIPPLANE4: boolean;
  93746. ALPHATEST: boolean;
  93747. DEPTHPREPASS: boolean;
  93748. ALPHAFROMDIFFUSE: boolean;
  93749. POINTSIZE: boolean;
  93750. FOG: boolean;
  93751. SPECULARTERM: boolean;
  93752. DIFFUSEFRESNEL: boolean;
  93753. OPACITYFRESNEL: boolean;
  93754. REFLECTIONFRESNEL: boolean;
  93755. REFRACTIONFRESNEL: boolean;
  93756. EMISSIVEFRESNEL: boolean;
  93757. FRESNEL: boolean;
  93758. NORMAL: boolean;
  93759. UV1: boolean;
  93760. UV2: boolean;
  93761. VERTEXCOLOR: boolean;
  93762. VERTEXALPHA: boolean;
  93763. NUM_BONE_INFLUENCERS: number;
  93764. BonesPerMesh: number;
  93765. BONETEXTURE: boolean;
  93766. INSTANCES: boolean;
  93767. GLOSSINESS: boolean;
  93768. ROUGHNESS: boolean;
  93769. EMISSIVEASILLUMINATION: boolean;
  93770. LINKEMISSIVEWITHDIFFUSE: boolean;
  93771. REFLECTIONFRESNELFROMSPECULAR: boolean;
  93772. LIGHTMAP: boolean;
  93773. LIGHTMAPDIRECTUV: number;
  93774. OBJECTSPACE_NORMALMAP: boolean;
  93775. USELIGHTMAPASSHADOWMAP: boolean;
  93776. REFLECTIONMAP_3D: boolean;
  93777. REFLECTIONMAP_SPHERICAL: boolean;
  93778. REFLECTIONMAP_PLANAR: boolean;
  93779. REFLECTIONMAP_CUBIC: boolean;
  93780. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  93781. REFLECTIONMAP_PROJECTION: boolean;
  93782. REFLECTIONMAP_SKYBOX: boolean;
  93783. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  93784. REFLECTIONMAP_EXPLICIT: boolean;
  93785. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  93786. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  93787. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  93788. INVERTCUBICMAP: boolean;
  93789. LOGARITHMICDEPTH: boolean;
  93790. REFRACTION: boolean;
  93791. REFRACTIONMAP_3D: boolean;
  93792. REFLECTIONOVERALPHA: boolean;
  93793. TWOSIDEDLIGHTING: boolean;
  93794. SHADOWFLOAT: boolean;
  93795. MORPHTARGETS: boolean;
  93796. MORPHTARGETS_NORMAL: boolean;
  93797. MORPHTARGETS_TANGENT: boolean;
  93798. NUM_MORPH_INFLUENCERS: number;
  93799. NONUNIFORMSCALING: boolean;
  93800. PREMULTIPLYALPHA: boolean;
  93801. IMAGEPROCESSING: boolean;
  93802. VIGNETTE: boolean;
  93803. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93804. VIGNETTEBLENDMODEOPAQUE: boolean;
  93805. TONEMAPPING: boolean;
  93806. TONEMAPPING_ACES: boolean;
  93807. CONTRAST: boolean;
  93808. COLORCURVES: boolean;
  93809. COLORGRADING: boolean;
  93810. COLORGRADING3D: boolean;
  93811. SAMPLER3DGREENDEPTH: boolean;
  93812. SAMPLER3DBGRMAP: boolean;
  93813. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93814. /**
  93815. * If the reflection texture on this material is in linear color space
  93816. * @hidden
  93817. */
  93818. IS_REFLECTION_LINEAR: boolean;
  93819. /**
  93820. * If the refraction texture on this material is in linear color space
  93821. * @hidden
  93822. */
  93823. IS_REFRACTION_LINEAR: boolean;
  93824. EXPOSURE: boolean;
  93825. constructor();
  93826. setReflectionMode(modeToEnable: string): void;
  93827. }
  93828. /**
  93829. * This is the default material used in Babylon. It is the best trade off between quality
  93830. * and performances.
  93831. * @see http://doc.babylonjs.com/babylon101/materials
  93832. */
  93833. export class StandardMaterial extends PushMaterial {
  93834. private _diffuseTexture;
  93835. /**
  93836. * The basic texture of the material as viewed under a light.
  93837. */
  93838. diffuseTexture: Nullable<BaseTexture>;
  93839. private _ambientTexture;
  93840. /**
  93841. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  93842. */
  93843. ambientTexture: Nullable<BaseTexture>;
  93844. private _opacityTexture;
  93845. /**
  93846. * Define the transparency of the material from a texture.
  93847. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  93848. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  93849. */
  93850. opacityTexture: Nullable<BaseTexture>;
  93851. private _reflectionTexture;
  93852. /**
  93853. * Define the texture used to display the reflection.
  93854. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93855. */
  93856. reflectionTexture: Nullable<BaseTexture>;
  93857. private _emissiveTexture;
  93858. /**
  93859. * Define texture of the material as if self lit.
  93860. * This will be mixed in the final result even in the absence of light.
  93861. */
  93862. emissiveTexture: Nullable<BaseTexture>;
  93863. private _specularTexture;
  93864. /**
  93865. * Define how the color and intensity of the highlight given by the light in the material.
  93866. */
  93867. specularTexture: Nullable<BaseTexture>;
  93868. private _bumpTexture;
  93869. /**
  93870. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  93871. * 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.
  93872. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  93873. */
  93874. bumpTexture: Nullable<BaseTexture>;
  93875. private _lightmapTexture;
  93876. /**
  93877. * Complex lighting can be computationally expensive to compute at runtime.
  93878. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  93879. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  93880. */
  93881. lightmapTexture: Nullable<BaseTexture>;
  93882. private _refractionTexture;
  93883. /**
  93884. * Define the texture used to display the refraction.
  93885. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93886. */
  93887. refractionTexture: Nullable<BaseTexture>;
  93888. /**
  93889. * The color of the material lit by the environmental background lighting.
  93890. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  93891. */
  93892. ambientColor: Color3;
  93893. /**
  93894. * The basic color of the material as viewed under a light.
  93895. */
  93896. diffuseColor: Color3;
  93897. /**
  93898. * Define how the color and intensity of the highlight given by the light in the material.
  93899. */
  93900. specularColor: Color3;
  93901. /**
  93902. * Define the color of the material as if self lit.
  93903. * This will be mixed in the final result even in the absence of light.
  93904. */
  93905. emissiveColor: Color3;
  93906. /**
  93907. * Defines how sharp are the highlights in the material.
  93908. * The bigger the value the sharper giving a more glossy feeling to the result.
  93909. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  93910. */
  93911. specularPower: number;
  93912. private _useAlphaFromDiffuseTexture;
  93913. /**
  93914. * Does the transparency come from the diffuse texture alpha channel.
  93915. */
  93916. useAlphaFromDiffuseTexture: boolean;
  93917. private _useEmissiveAsIllumination;
  93918. /**
  93919. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  93920. */
  93921. useEmissiveAsIllumination: boolean;
  93922. private _linkEmissiveWithDiffuse;
  93923. /**
  93924. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  93925. * the emissive level when the final color is close to one.
  93926. */
  93927. linkEmissiveWithDiffuse: boolean;
  93928. private _useSpecularOverAlpha;
  93929. /**
  93930. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  93931. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  93932. */
  93933. useSpecularOverAlpha: boolean;
  93934. private _useReflectionOverAlpha;
  93935. /**
  93936. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  93937. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  93938. */
  93939. useReflectionOverAlpha: boolean;
  93940. private _disableLighting;
  93941. /**
  93942. * Does lights from the scene impacts this material.
  93943. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  93944. */
  93945. disableLighting: boolean;
  93946. private _useObjectSpaceNormalMap;
  93947. /**
  93948. * Allows using an object space normal map (instead of tangent space).
  93949. */
  93950. useObjectSpaceNormalMap: boolean;
  93951. private _useParallax;
  93952. /**
  93953. * Is parallax enabled or not.
  93954. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93955. */
  93956. useParallax: boolean;
  93957. private _useParallaxOcclusion;
  93958. /**
  93959. * Is parallax occlusion enabled or not.
  93960. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  93961. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93962. */
  93963. useParallaxOcclusion: boolean;
  93964. /**
  93965. * 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.
  93966. */
  93967. parallaxScaleBias: number;
  93968. private _roughness;
  93969. /**
  93970. * Helps to define how blurry the reflections should appears in the material.
  93971. */
  93972. roughness: number;
  93973. /**
  93974. * In case of refraction, define the value of the indice of refraction.
  93975. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93976. */
  93977. indexOfRefraction: number;
  93978. /**
  93979. * Invert the refraction texture alongside the y axis.
  93980. * It can be useful with procedural textures or probe for instance.
  93981. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93982. */
  93983. invertRefractionY: boolean;
  93984. /**
  93985. * Defines the alpha limits in alpha test mode.
  93986. */
  93987. alphaCutOff: number;
  93988. private _useLightmapAsShadowmap;
  93989. /**
  93990. * In case of light mapping, define whether the map contains light or shadow informations.
  93991. */
  93992. useLightmapAsShadowmap: boolean;
  93993. private _diffuseFresnelParameters;
  93994. /**
  93995. * Define the diffuse fresnel parameters of the material.
  93996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93997. */
  93998. diffuseFresnelParameters: FresnelParameters;
  93999. private _opacityFresnelParameters;
  94000. /**
  94001. * Define the opacity fresnel parameters of the material.
  94002. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94003. */
  94004. opacityFresnelParameters: FresnelParameters;
  94005. private _reflectionFresnelParameters;
  94006. /**
  94007. * Define the reflection fresnel parameters of the material.
  94008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94009. */
  94010. reflectionFresnelParameters: FresnelParameters;
  94011. private _refractionFresnelParameters;
  94012. /**
  94013. * Define the refraction fresnel parameters of the material.
  94014. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94015. */
  94016. refractionFresnelParameters: FresnelParameters;
  94017. private _emissiveFresnelParameters;
  94018. /**
  94019. * Define the emissive fresnel parameters of the material.
  94020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94021. */
  94022. emissiveFresnelParameters: FresnelParameters;
  94023. private _useReflectionFresnelFromSpecular;
  94024. /**
  94025. * If true automatically deducts the fresnels values from the material specularity.
  94026. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94027. */
  94028. useReflectionFresnelFromSpecular: boolean;
  94029. private _useGlossinessFromSpecularMapAlpha;
  94030. /**
  94031. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  94032. */
  94033. useGlossinessFromSpecularMapAlpha: boolean;
  94034. private _maxSimultaneousLights;
  94035. /**
  94036. * Defines the maximum number of lights that can be used in the material
  94037. */
  94038. maxSimultaneousLights: number;
  94039. private _invertNormalMapX;
  94040. /**
  94041. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  94042. */
  94043. invertNormalMapX: boolean;
  94044. private _invertNormalMapY;
  94045. /**
  94046. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  94047. */
  94048. invertNormalMapY: boolean;
  94049. private _twoSidedLighting;
  94050. /**
  94051. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  94052. */
  94053. twoSidedLighting: boolean;
  94054. /**
  94055. * Default configuration related to image processing available in the standard Material.
  94056. */
  94057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94058. /**
  94059. * Gets the image processing configuration used either in this material.
  94060. */
  94061. /**
  94062. * Sets the Default image processing configuration used either in the this material.
  94063. *
  94064. * If sets to null, the scene one is in use.
  94065. */
  94066. imageProcessingConfiguration: ImageProcessingConfiguration;
  94067. /**
  94068. * Keep track of the image processing observer to allow dispose and replace.
  94069. */
  94070. private _imageProcessingObserver;
  94071. /**
  94072. * Attaches a new image processing configuration to the Standard Material.
  94073. * @param configuration
  94074. */
  94075. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94076. /**
  94077. * Gets wether the color curves effect is enabled.
  94078. */
  94079. /**
  94080. * Sets wether the color curves effect is enabled.
  94081. */
  94082. cameraColorCurvesEnabled: boolean;
  94083. /**
  94084. * Gets wether the color grading effect is enabled.
  94085. */
  94086. /**
  94087. * Gets wether the color grading effect is enabled.
  94088. */
  94089. cameraColorGradingEnabled: boolean;
  94090. /**
  94091. * Gets wether tonemapping is enabled or not.
  94092. */
  94093. /**
  94094. * Sets wether tonemapping is enabled or not
  94095. */
  94096. cameraToneMappingEnabled: boolean;
  94097. /**
  94098. * The camera exposure used on this material.
  94099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94100. * This corresponds to a photographic exposure.
  94101. */
  94102. /**
  94103. * The camera exposure used on this material.
  94104. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94105. * This corresponds to a photographic exposure.
  94106. */
  94107. cameraExposure: number;
  94108. /**
  94109. * Gets The camera contrast used on this material.
  94110. */
  94111. /**
  94112. * Sets The camera contrast used on this material.
  94113. */
  94114. cameraContrast: number;
  94115. /**
  94116. * Gets the Color Grading 2D Lookup Texture.
  94117. */
  94118. /**
  94119. * Sets the Color Grading 2D Lookup Texture.
  94120. */
  94121. cameraColorGradingTexture: Nullable<BaseTexture>;
  94122. /**
  94123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94125. * 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;
  94126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94127. */
  94128. /**
  94129. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94130. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94131. * 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;
  94132. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94133. */
  94134. cameraColorCurves: Nullable<ColorCurves>;
  94135. /**
  94136. * Custom callback helping to override the default shader used in the material.
  94137. */
  94138. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94139. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94140. protected _worldViewProjectionMatrix: Matrix;
  94141. protected _globalAmbientColor: Color3;
  94142. protected _useLogarithmicDepth: boolean;
  94143. /**
  94144. * Instantiates a new standard material.
  94145. * This is the default material used in Babylon. It is the best trade off between quality
  94146. * and performances.
  94147. * @see http://doc.babylonjs.com/babylon101/materials
  94148. * @param name Define the name of the material in the scene
  94149. * @param scene Define the scene the material belong to
  94150. */
  94151. constructor(name: string, scene: Scene);
  94152. /**
  94153. * Gets a boolean indicating that current material needs to register RTT
  94154. */
  94155. readonly hasRenderTargetTextures: boolean;
  94156. /**
  94157. * Gets the current class name of the material e.g. "StandardMaterial"
  94158. * Mainly use in serialization.
  94159. * @returns the class name
  94160. */
  94161. getClassName(): string;
  94162. /**
  94163. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94164. * You can try switching to logarithmic depth.
  94165. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94166. */
  94167. useLogarithmicDepth: boolean;
  94168. /**
  94169. * Specifies if the material will require alpha blending
  94170. * @returns a boolean specifying if alpha blending is needed
  94171. */
  94172. needAlphaBlending(): boolean;
  94173. /**
  94174. * Specifies if this material should be rendered in alpha test mode
  94175. * @returns a boolean specifying if an alpha test is needed.
  94176. */
  94177. needAlphaTesting(): boolean;
  94178. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94179. /**
  94180. * Get the texture used for alpha test purpose.
  94181. * @returns the diffuse texture in case of the standard material.
  94182. */
  94183. getAlphaTestTexture(): Nullable<BaseTexture>;
  94184. /**
  94185. * Get if the submesh is ready to be used and all its information available.
  94186. * Child classes can use it to update shaders
  94187. * @param mesh defines the mesh to check
  94188. * @param subMesh defines which submesh to check
  94189. * @param useInstances specifies that instances should be used
  94190. * @returns a boolean indicating that the submesh is ready or not
  94191. */
  94192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94193. /**
  94194. * Builds the material UBO layouts.
  94195. * Used internally during the effect preparation.
  94196. */
  94197. buildUniformLayout(): void;
  94198. /**
  94199. * Unbinds the material from the mesh
  94200. */
  94201. unbind(): void;
  94202. /**
  94203. * Binds the submesh to this material by preparing the effect and shader to draw
  94204. * @param world defines the world transformation matrix
  94205. * @param mesh defines the mesh containing the submesh
  94206. * @param subMesh defines the submesh to bind the material to
  94207. */
  94208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94209. /**
  94210. * Get the list of animatables in the material.
  94211. * @returns the list of animatables object used in the material
  94212. */
  94213. getAnimatables(): IAnimatable[];
  94214. /**
  94215. * Gets the active textures from the material
  94216. * @returns an array of textures
  94217. */
  94218. getActiveTextures(): BaseTexture[];
  94219. /**
  94220. * Specifies if the material uses a texture
  94221. * @param texture defines the texture to check against the material
  94222. * @returns a boolean specifying if the material uses the texture
  94223. */
  94224. hasTexture(texture: BaseTexture): boolean;
  94225. /**
  94226. * Disposes the material
  94227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94229. */
  94230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94231. /**
  94232. * Makes a duplicate of the material, and gives it a new name
  94233. * @param name defines the new name for the duplicated material
  94234. * @returns the cloned material
  94235. */
  94236. clone(name: string): StandardMaterial;
  94237. /**
  94238. * Serializes this material in a JSON representation
  94239. * @returns the serialized material object
  94240. */
  94241. serialize(): any;
  94242. /**
  94243. * Creates a standard material from parsed material data
  94244. * @param source defines the JSON representation of the material
  94245. * @param scene defines the hosting scene
  94246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94247. * @returns a new standard material
  94248. */
  94249. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94250. /**
  94251. * Are diffuse textures enabled in the application.
  94252. */
  94253. static DiffuseTextureEnabled: boolean;
  94254. /**
  94255. * Are ambient textures enabled in the application.
  94256. */
  94257. static AmbientTextureEnabled: boolean;
  94258. /**
  94259. * Are opacity textures enabled in the application.
  94260. */
  94261. static OpacityTextureEnabled: boolean;
  94262. /**
  94263. * Are reflection textures enabled in the application.
  94264. */
  94265. static ReflectionTextureEnabled: boolean;
  94266. /**
  94267. * Are emissive textures enabled in the application.
  94268. */
  94269. static EmissiveTextureEnabled: boolean;
  94270. /**
  94271. * Are specular textures enabled in the application.
  94272. */
  94273. static SpecularTextureEnabled: boolean;
  94274. /**
  94275. * Are bump textures enabled in the application.
  94276. */
  94277. static BumpTextureEnabled: boolean;
  94278. /**
  94279. * Are lightmap textures enabled in the application.
  94280. */
  94281. static LightmapTextureEnabled: boolean;
  94282. /**
  94283. * Are refraction textures enabled in the application.
  94284. */
  94285. static RefractionTextureEnabled: boolean;
  94286. /**
  94287. * Are color grading textures enabled in the application.
  94288. */
  94289. static ColorGradingTextureEnabled: boolean;
  94290. /**
  94291. * Are fresnels enabled in the application.
  94292. */
  94293. static FresnelEnabled: boolean;
  94294. }
  94295. }
  94296. declare module BABYLON {
  94297. /**
  94298. * A class extending Texture allowing drawing on a texture
  94299. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94300. */
  94301. export class DynamicTexture extends Texture {
  94302. private _generateMipMaps;
  94303. private _canvas;
  94304. private _context;
  94305. private _engine;
  94306. /**
  94307. * Creates a DynamicTexture
  94308. * @param name defines the name of the texture
  94309. * @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
  94310. * @param scene defines the scene where you want the texture
  94311. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94312. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94313. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94314. */
  94315. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94316. /**
  94317. * Get the current class name of the texture useful for serialization or dynamic coding.
  94318. * @returns "DynamicTexture"
  94319. */
  94320. getClassName(): string;
  94321. /**
  94322. * Gets the current state of canRescale
  94323. */
  94324. readonly canRescale: boolean;
  94325. private _recreate;
  94326. /**
  94327. * Scales the texture
  94328. * @param ratio the scale factor to apply to both width and height
  94329. */
  94330. scale(ratio: number): void;
  94331. /**
  94332. * Resizes the texture
  94333. * @param width the new width
  94334. * @param height the new height
  94335. */
  94336. scaleTo(width: number, height: number): void;
  94337. /**
  94338. * Gets the context of the canvas used by the texture
  94339. * @returns the canvas context of the dynamic texture
  94340. */
  94341. getContext(): CanvasRenderingContext2D;
  94342. /**
  94343. * Clears the texture
  94344. */
  94345. clear(): void;
  94346. /**
  94347. * Updates the texture
  94348. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94349. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94350. */
  94351. update(invertY?: boolean, premulAlpha?: boolean): void;
  94352. /**
  94353. * Draws text onto the texture
  94354. * @param text defines the text to be drawn
  94355. * @param x defines the placement of the text from the left
  94356. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94357. * @param font defines the font to be used with font-style, font-size, font-name
  94358. * @param color defines the color used for the text
  94359. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94360. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94361. * @param update defines whether texture is immediately update (default is true)
  94362. */
  94363. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94364. /**
  94365. * Clones the texture
  94366. * @returns the clone of the texture.
  94367. */
  94368. clone(): DynamicTexture;
  94369. /**
  94370. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94371. * @returns a serialized dynamic texture object
  94372. */
  94373. serialize(): any;
  94374. /** @hidden */
  94375. _rebuild(): void;
  94376. }
  94377. }
  94378. declare module BABYLON {
  94379. /** @hidden */
  94380. export var imageProcessingPixelShader: {
  94381. name: string;
  94382. shader: string;
  94383. };
  94384. }
  94385. declare module BABYLON {
  94386. /**
  94387. * ImageProcessingPostProcess
  94388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94389. */
  94390. export class ImageProcessingPostProcess extends PostProcess {
  94391. /**
  94392. * Default configuration related to image processing available in the PBR Material.
  94393. */
  94394. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94395. /**
  94396. * Gets the image processing configuration used either in this material.
  94397. */
  94398. /**
  94399. * Sets the Default image processing configuration used either in the this material.
  94400. *
  94401. * If sets to null, the scene one is in use.
  94402. */
  94403. imageProcessingConfiguration: ImageProcessingConfiguration;
  94404. /**
  94405. * Keep track of the image processing observer to allow dispose and replace.
  94406. */
  94407. private _imageProcessingObserver;
  94408. /**
  94409. * Attaches a new image processing configuration to the PBR Material.
  94410. * @param configuration
  94411. */
  94412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94413. /**
  94414. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94415. */
  94416. /**
  94417. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94418. */
  94419. colorCurves: Nullable<ColorCurves>;
  94420. /**
  94421. * Gets wether the color curves effect is enabled.
  94422. */
  94423. /**
  94424. * Sets wether the color curves effect is enabled.
  94425. */
  94426. colorCurvesEnabled: boolean;
  94427. /**
  94428. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94429. */
  94430. /**
  94431. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94432. */
  94433. colorGradingTexture: Nullable<BaseTexture>;
  94434. /**
  94435. * Gets wether the color grading effect is enabled.
  94436. */
  94437. /**
  94438. * Gets wether the color grading effect is enabled.
  94439. */
  94440. colorGradingEnabled: boolean;
  94441. /**
  94442. * Gets exposure used in the effect.
  94443. */
  94444. /**
  94445. * Sets exposure used in the effect.
  94446. */
  94447. exposure: number;
  94448. /**
  94449. * Gets wether tonemapping is enabled or not.
  94450. */
  94451. /**
  94452. * Sets wether tonemapping is enabled or not
  94453. */
  94454. toneMappingEnabled: boolean;
  94455. /**
  94456. * Gets contrast used in the effect.
  94457. */
  94458. /**
  94459. * Sets contrast used in the effect.
  94460. */
  94461. contrast: number;
  94462. /**
  94463. * Gets Vignette stretch size.
  94464. */
  94465. /**
  94466. * Sets Vignette stretch size.
  94467. */
  94468. vignetteStretch: number;
  94469. /**
  94470. * Gets Vignette centre X Offset.
  94471. */
  94472. /**
  94473. * Sets Vignette centre X Offset.
  94474. */
  94475. vignetteCentreX: number;
  94476. /**
  94477. * Gets Vignette centre Y Offset.
  94478. */
  94479. /**
  94480. * Sets Vignette centre Y Offset.
  94481. */
  94482. vignetteCentreY: number;
  94483. /**
  94484. * Gets Vignette weight or intensity of the vignette effect.
  94485. */
  94486. /**
  94487. * Sets Vignette weight or intensity of the vignette effect.
  94488. */
  94489. vignetteWeight: number;
  94490. /**
  94491. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94492. * if vignetteEnabled is set to true.
  94493. */
  94494. /**
  94495. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94496. * if vignetteEnabled is set to true.
  94497. */
  94498. vignetteColor: Color4;
  94499. /**
  94500. * Gets Camera field of view used by the Vignette effect.
  94501. */
  94502. /**
  94503. * Sets Camera field of view used by the Vignette effect.
  94504. */
  94505. vignetteCameraFov: number;
  94506. /**
  94507. * Gets the vignette blend mode allowing different kind of effect.
  94508. */
  94509. /**
  94510. * Sets the vignette blend mode allowing different kind of effect.
  94511. */
  94512. vignetteBlendMode: number;
  94513. /**
  94514. * Gets wether the vignette effect is enabled.
  94515. */
  94516. /**
  94517. * Sets wether the vignette effect is enabled.
  94518. */
  94519. vignetteEnabled: boolean;
  94520. private _fromLinearSpace;
  94521. /**
  94522. * Gets wether the input of the processing is in Gamma or Linear Space.
  94523. */
  94524. /**
  94525. * Sets wether the input of the processing is in Gamma or Linear Space.
  94526. */
  94527. fromLinearSpace: boolean;
  94528. /**
  94529. * Defines cache preventing GC.
  94530. */
  94531. private _defines;
  94532. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  94533. /**
  94534. * "ImageProcessingPostProcess"
  94535. * @returns "ImageProcessingPostProcess"
  94536. */
  94537. getClassName(): string;
  94538. protected _updateParameters(): void;
  94539. dispose(camera?: Camera): void;
  94540. }
  94541. }
  94542. declare module BABYLON {
  94543. /**
  94544. * Class containing static functions to help procedurally build meshes
  94545. */
  94546. export class GroundBuilder {
  94547. /**
  94548. * Creates a ground mesh
  94549. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94550. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94552. * @param name defines the name of the mesh
  94553. * @param options defines the options used to create the mesh
  94554. * @param scene defines the hosting scene
  94555. * @returns the ground mesh
  94556. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94557. */
  94558. static CreateGround(name: string, options: {
  94559. width?: number;
  94560. height?: number;
  94561. subdivisions?: number;
  94562. subdivisionsX?: number;
  94563. subdivisionsY?: number;
  94564. updatable?: boolean;
  94565. }, scene: any): Mesh;
  94566. /**
  94567. * Creates a tiled ground mesh
  94568. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94569. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94570. * * 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
  94571. * * 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
  94572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94573. * @param name defines the name of the mesh
  94574. * @param options defines the options used to create the mesh
  94575. * @param scene defines the hosting scene
  94576. * @returns the tiled ground mesh
  94577. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94578. */
  94579. static CreateTiledGround(name: string, options: {
  94580. xmin: number;
  94581. zmin: number;
  94582. xmax: number;
  94583. zmax: number;
  94584. subdivisions?: {
  94585. w: number;
  94586. h: number;
  94587. };
  94588. precision?: {
  94589. w: number;
  94590. h: number;
  94591. };
  94592. updatable?: boolean;
  94593. }, scene: Scene): Mesh;
  94594. /**
  94595. * Creates a ground mesh from a height map
  94596. * * The parameter `url` sets the URL of the height map image resource.
  94597. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94598. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94599. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94600. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94601. * * 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.
  94602. * * 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).
  94603. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94605. * @param name defines the name of the mesh
  94606. * @param url defines the url to the height map
  94607. * @param options defines the options used to create the mesh
  94608. * @param scene defines the hosting scene
  94609. * @returns the ground mesh
  94610. * @see https://doc.babylonjs.com/babylon101/height_map
  94611. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94612. */
  94613. static CreateGroundFromHeightMap(name: string, url: string, options: {
  94614. width?: number;
  94615. height?: number;
  94616. subdivisions?: number;
  94617. minHeight?: number;
  94618. maxHeight?: number;
  94619. colorFilter?: Color3;
  94620. alphaFilter?: number;
  94621. updatable?: boolean;
  94622. onReady?: (mesh: GroundMesh) => void;
  94623. }, scene: Scene): GroundMesh;
  94624. }
  94625. }
  94626. declare module BABYLON {
  94627. /**
  94628. * Class containing static functions to help procedurally build meshes
  94629. */
  94630. export class TorusBuilder {
  94631. /**
  94632. * Creates a torus mesh
  94633. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94634. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94635. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94639. * @param name defines the name of the mesh
  94640. * @param options defines the options used to create the mesh
  94641. * @param scene defines the hosting scene
  94642. * @returns the torus mesh
  94643. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94644. */
  94645. static CreateTorus(name: string, options: {
  94646. diameter?: number;
  94647. thickness?: number;
  94648. tessellation?: number;
  94649. updatable?: boolean;
  94650. sideOrientation?: number;
  94651. frontUVs?: Vector4;
  94652. backUVs?: Vector4;
  94653. }, scene: any): Mesh;
  94654. }
  94655. }
  94656. declare module BABYLON {
  94657. /**
  94658. * Class containing static functions to help procedurally build meshes
  94659. */
  94660. export class CylinderBuilder {
  94661. /**
  94662. * Creates a cylinder or a cone mesh
  94663. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94664. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  94665. * * 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.
  94666. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  94667. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  94668. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  94669. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  94670. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  94671. * * 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).
  94672. * * 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
  94673. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  94674. * * 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
  94675. * * 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.
  94676. * * If `enclose` is false, a ring surface is one element.
  94677. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  94678. * * 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
  94679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94682. * @param name defines the name of the mesh
  94683. * @param options defines the options used to create the mesh
  94684. * @param scene defines the hosting scene
  94685. * @returns the cylinder mesh
  94686. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  94687. */
  94688. static CreateCylinder(name: string, options: {
  94689. height?: number;
  94690. diameterTop?: number;
  94691. diameterBottom?: number;
  94692. diameter?: number;
  94693. tessellation?: number;
  94694. subdivisions?: number;
  94695. arc?: number;
  94696. faceColors?: Color4[];
  94697. faceUV?: Vector4[];
  94698. updatable?: boolean;
  94699. hasRings?: boolean;
  94700. enclose?: boolean;
  94701. sideOrientation?: number;
  94702. frontUVs?: Vector4;
  94703. backUVs?: Vector4;
  94704. }, scene: any): Mesh;
  94705. }
  94706. }
  94707. declare module BABYLON {
  94708. /**
  94709. * Manager for handling gamepads
  94710. */
  94711. export class GamepadManager {
  94712. private _scene?;
  94713. private _babylonGamepads;
  94714. private _oneGamepadConnected;
  94715. /** @hidden */
  94716. _isMonitoring: boolean;
  94717. private _gamepadEventSupported;
  94718. private _gamepadSupport;
  94719. /**
  94720. * observable to be triggered when the gamepad controller has been connected
  94721. */
  94722. onGamepadConnectedObservable: Observable<Gamepad>;
  94723. /**
  94724. * observable to be triggered when the gamepad controller has been disconnected
  94725. */
  94726. onGamepadDisconnectedObservable: Observable<Gamepad>;
  94727. private _onGamepadConnectedEvent;
  94728. private _onGamepadDisconnectedEvent;
  94729. /**
  94730. * Initializes the gamepad manager
  94731. * @param _scene BabylonJS scene
  94732. */
  94733. constructor(_scene?: Scene | undefined);
  94734. /**
  94735. * The gamepads in the game pad manager
  94736. */
  94737. readonly gamepads: Gamepad[];
  94738. /**
  94739. * Get the gamepad controllers based on type
  94740. * @param type The type of gamepad controller
  94741. * @returns Nullable gamepad
  94742. */
  94743. getGamepadByType(type?: number): Nullable<Gamepad>;
  94744. /**
  94745. * Disposes the gamepad manager
  94746. */
  94747. dispose(): void;
  94748. private _addNewGamepad;
  94749. private _startMonitoringGamepads;
  94750. private _stopMonitoringGamepads;
  94751. /** @hidden */
  94752. _checkGamepadsStatus(): void;
  94753. private _updateGamepadObjects;
  94754. }
  94755. }
  94756. declare module BABYLON {
  94757. interface Scene {
  94758. /** @hidden */
  94759. _gamepadManager: Nullable<GamepadManager>;
  94760. /**
  94761. * Gets the gamepad manager associated with the scene
  94762. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  94763. */
  94764. gamepadManager: GamepadManager;
  94765. }
  94766. /**
  94767. * Interface representing a free camera inputs manager
  94768. */
  94769. interface FreeCameraInputsManager {
  94770. /**
  94771. * Adds gamepad input support to the FreeCameraInputsManager.
  94772. * @returns the FreeCameraInputsManager
  94773. */
  94774. addGamepad(): FreeCameraInputsManager;
  94775. }
  94776. /**
  94777. * Interface representing an arc rotate camera inputs manager
  94778. */
  94779. interface ArcRotateCameraInputsManager {
  94780. /**
  94781. * Adds gamepad input support to the ArcRotateCamera InputManager.
  94782. * @returns the camera inputs manager
  94783. */
  94784. addGamepad(): ArcRotateCameraInputsManager;
  94785. }
  94786. /**
  94787. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  94788. */
  94789. export class GamepadSystemSceneComponent implements ISceneComponent {
  94790. /**
  94791. * The component name helpfull to identify the component in the list of scene components.
  94792. */
  94793. readonly name: string;
  94794. /**
  94795. * The scene the component belongs to.
  94796. */
  94797. scene: Scene;
  94798. /**
  94799. * Creates a new instance of the component for the given scene
  94800. * @param scene Defines the scene to register the component in
  94801. */
  94802. constructor(scene: Scene);
  94803. /**
  94804. * Registers the component in a given scene
  94805. */
  94806. register(): void;
  94807. /**
  94808. * Rebuilds the elements related to this component in case of
  94809. * context lost for instance.
  94810. */
  94811. rebuild(): void;
  94812. /**
  94813. * Disposes the component and the associated ressources
  94814. */
  94815. dispose(): void;
  94816. private _beforeCameraUpdate;
  94817. }
  94818. }
  94819. declare module BABYLON {
  94820. /**
  94821. * Options to modify the vr teleportation behavior.
  94822. */
  94823. export interface VRTeleportationOptions {
  94824. /**
  94825. * The name of the mesh which should be used as the teleportation floor. (default: null)
  94826. */
  94827. floorMeshName?: string;
  94828. /**
  94829. * A list of meshes to be used as the teleportation floor. (default: empty)
  94830. */
  94831. floorMeshes?: Mesh[];
  94832. }
  94833. /**
  94834. * Options to modify the vr experience helper's behavior.
  94835. */
  94836. export interface VRExperienceHelperOptions extends WebVROptions {
  94837. /**
  94838. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  94839. */
  94840. createDeviceOrientationCamera?: boolean;
  94841. /**
  94842. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  94843. */
  94844. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  94845. /**
  94846. * Uses the main button on the controller to toggle the laser casted. (default: true)
  94847. */
  94848. laserToggle?: boolean;
  94849. /**
  94850. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  94851. */
  94852. floorMeshes?: Mesh[];
  94853. /**
  94854. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  94855. */
  94856. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  94857. }
  94858. /**
  94859. * Helps to quickly add VR support to an existing scene.
  94860. * See http://doc.babylonjs.com/how_to/webvr_helper
  94861. */
  94862. export class VRExperienceHelper {
  94863. /** Options to modify the vr experience helper's behavior. */
  94864. webVROptions: VRExperienceHelperOptions;
  94865. private _scene;
  94866. private _position;
  94867. private _btnVR;
  94868. private _btnVRDisplayed;
  94869. private _webVRsupported;
  94870. private _webVRready;
  94871. private _webVRrequesting;
  94872. private _webVRpresenting;
  94873. private _hasEnteredVR;
  94874. private _fullscreenVRpresenting;
  94875. private _canvas;
  94876. private _webVRCamera;
  94877. private _vrDeviceOrientationCamera;
  94878. private _deviceOrientationCamera;
  94879. private _existingCamera;
  94880. private _onKeyDown;
  94881. private _onVrDisplayPresentChange;
  94882. private _onVRDisplayChanged;
  94883. private _onVRRequestPresentStart;
  94884. private _onVRRequestPresentComplete;
  94885. /**
  94886. * Observable raised when entering VR.
  94887. */
  94888. onEnteringVRObservable: Observable<VRExperienceHelper>;
  94889. /**
  94890. * Observable raised when exiting VR.
  94891. */
  94892. onExitingVRObservable: Observable<VRExperienceHelper>;
  94893. /**
  94894. * Observable raised when controller mesh is loaded.
  94895. */
  94896. onControllerMeshLoadedObservable: Observable<WebVRController>;
  94897. /** Return this.onEnteringVRObservable
  94898. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  94899. */
  94900. readonly onEnteringVR: Observable<VRExperienceHelper>;
  94901. /** Return this.onExitingVRObservable
  94902. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  94903. */
  94904. readonly onExitingVR: Observable<VRExperienceHelper>;
  94905. /** Return this.onControllerMeshLoadedObservable
  94906. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  94907. */
  94908. readonly onControllerMeshLoaded: Observable<WebVRController>;
  94909. private _rayLength;
  94910. private _useCustomVRButton;
  94911. private _teleportationRequested;
  94912. private _teleportActive;
  94913. private _floorMeshName;
  94914. private _floorMeshesCollection;
  94915. private _rotationAllowed;
  94916. private _teleportBackwardsVector;
  94917. private _teleportationTarget;
  94918. private _isDefaultTeleportationTarget;
  94919. private _postProcessMove;
  94920. private _teleportationFillColor;
  94921. private _teleportationBorderColor;
  94922. private _rotationAngle;
  94923. private _haloCenter;
  94924. private _cameraGazer;
  94925. private _padSensibilityUp;
  94926. private _padSensibilityDown;
  94927. private _leftController;
  94928. private _rightController;
  94929. /**
  94930. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  94931. */
  94932. onNewMeshSelected: Observable<AbstractMesh>;
  94933. /**
  94934. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  94935. */
  94936. onNewMeshPicked: Observable<PickingInfo>;
  94937. private _circleEase;
  94938. /**
  94939. * Observable raised before camera teleportation
  94940. */
  94941. onBeforeCameraTeleport: Observable<Vector3>;
  94942. /**
  94943. * Observable raised after camera teleportation
  94944. */
  94945. onAfterCameraTeleport: Observable<Vector3>;
  94946. /**
  94947. * Observable raised when current selected mesh gets unselected
  94948. */
  94949. onSelectedMeshUnselected: Observable<AbstractMesh>;
  94950. private _raySelectionPredicate;
  94951. /**
  94952. * To be optionaly changed by user to define custom ray selection
  94953. */
  94954. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  94955. /**
  94956. * To be optionaly changed by user to define custom selection logic (after ray selection)
  94957. */
  94958. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  94959. /**
  94960. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  94961. */
  94962. teleportationEnabled: boolean;
  94963. private _defaultHeight;
  94964. private _teleportationInitialized;
  94965. private _interactionsEnabled;
  94966. private _interactionsRequested;
  94967. private _displayGaze;
  94968. private _displayLaserPointer;
  94969. /**
  94970. * The mesh used to display where the user is going to teleport.
  94971. */
  94972. /**
  94973. * Sets the mesh to be used to display where the user is going to teleport.
  94974. */
  94975. teleportationTarget: Mesh;
  94976. /**
  94977. * 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
  94978. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  94979. * See http://doc.babylonjs.com/resources/baking_transformations
  94980. */
  94981. gazeTrackerMesh: Mesh;
  94982. /**
  94983. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  94984. */
  94985. updateGazeTrackerScale: boolean;
  94986. /**
  94987. * If the gaze trackers color should be updated when selecting meshes
  94988. */
  94989. updateGazeTrackerColor: boolean;
  94990. /**
  94991. * The gaze tracking mesh corresponding to the left controller
  94992. */
  94993. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  94994. /**
  94995. * The gaze tracking mesh corresponding to the right controller
  94996. */
  94997. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  94998. /**
  94999. * If the ray of the gaze should be displayed.
  95000. */
  95001. /**
  95002. * Sets if the ray of the gaze should be displayed.
  95003. */
  95004. displayGaze: boolean;
  95005. /**
  95006. * If the ray of the LaserPointer should be displayed.
  95007. */
  95008. /**
  95009. * Sets if the ray of the LaserPointer should be displayed.
  95010. */
  95011. displayLaserPointer: boolean;
  95012. /**
  95013. * The deviceOrientationCamera used as the camera when not in VR.
  95014. */
  95015. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  95016. /**
  95017. * Based on the current WebVR support, returns the current VR camera used.
  95018. */
  95019. readonly currentVRCamera: Nullable<Camera>;
  95020. /**
  95021. * The webVRCamera which is used when in VR.
  95022. */
  95023. readonly webVRCamera: WebVRFreeCamera;
  95024. /**
  95025. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  95026. */
  95027. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  95028. private readonly _teleportationRequestInitiated;
  95029. /**
  95030. * Defines wether or not Pointer lock should be requested when switching to
  95031. * full screen.
  95032. */
  95033. requestPointerLockOnFullScreen: boolean;
  95034. /**
  95035. * Instantiates a VRExperienceHelper.
  95036. * Helps to quickly add VR support to an existing scene.
  95037. * @param scene The scene the VRExperienceHelper belongs to.
  95038. * @param webVROptions Options to modify the vr experience helper's behavior.
  95039. */
  95040. constructor(scene: Scene,
  95041. /** Options to modify the vr experience helper's behavior. */
  95042. webVROptions?: VRExperienceHelperOptions);
  95043. private _onDefaultMeshLoaded;
  95044. private _onResize;
  95045. private _onFullscreenChange;
  95046. /**
  95047. * Gets a value indicating if we are currently in VR mode.
  95048. */
  95049. readonly isInVRMode: boolean;
  95050. private onVrDisplayPresentChange;
  95051. private onVRDisplayChanged;
  95052. private moveButtonToBottomRight;
  95053. private displayVRButton;
  95054. private updateButtonVisibility;
  95055. private _cachedAngularSensibility;
  95056. /**
  95057. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  95058. * Otherwise, will use the fullscreen API.
  95059. */
  95060. enterVR(): void;
  95061. /**
  95062. * Attempt to exit VR, or fullscreen.
  95063. */
  95064. exitVR(): void;
  95065. /**
  95066. * The position of the vr experience helper.
  95067. */
  95068. /**
  95069. * Sets the position of the vr experience helper.
  95070. */
  95071. position: Vector3;
  95072. /**
  95073. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95074. */
  95075. enableInteractions(): void;
  95076. private readonly _noControllerIsActive;
  95077. private beforeRender;
  95078. private _isTeleportationFloor;
  95079. /**
  95080. * Adds a floor mesh to be used for teleportation.
  95081. * @param floorMesh the mesh to be used for teleportation.
  95082. */
  95083. addFloorMesh(floorMesh: Mesh): void;
  95084. /**
  95085. * Removes a floor mesh from being used for teleportation.
  95086. * @param floorMesh the mesh to be removed.
  95087. */
  95088. removeFloorMesh(floorMesh: Mesh): void;
  95089. /**
  95090. * Enables interactions and teleportation using the VR controllers and gaze.
  95091. * @param vrTeleportationOptions options to modify teleportation behavior.
  95092. */
  95093. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95094. private _onNewGamepadConnected;
  95095. private _tryEnableInteractionOnController;
  95096. private _onNewGamepadDisconnected;
  95097. private _enableInteractionOnController;
  95098. private _checkTeleportWithRay;
  95099. private _checkRotate;
  95100. private _checkTeleportBackwards;
  95101. private _enableTeleportationOnController;
  95102. private _createTeleportationCircles;
  95103. private _displayTeleportationTarget;
  95104. private _hideTeleportationTarget;
  95105. private _rotateCamera;
  95106. private _moveTeleportationSelectorTo;
  95107. private _workingVector;
  95108. private _workingQuaternion;
  95109. private _workingMatrix;
  95110. /**
  95111. * Teleports the users feet to the desired location
  95112. * @param location The location where the user's feet should be placed
  95113. */
  95114. teleportCamera(location: Vector3): void;
  95115. private _convertNormalToDirectionOfRay;
  95116. private _castRayAndSelectObject;
  95117. private _notifySelectedMeshUnselected;
  95118. /**
  95119. * Sets the color of the laser ray from the vr controllers.
  95120. * @param color new color for the ray.
  95121. */
  95122. changeLaserColor(color: Color3): void;
  95123. /**
  95124. * Sets the color of the ray from the vr headsets gaze.
  95125. * @param color new color for the ray.
  95126. */
  95127. changeGazeColor(color: Color3): void;
  95128. /**
  95129. * Exits VR and disposes of the vr experience helper
  95130. */
  95131. dispose(): void;
  95132. /**
  95133. * Gets the name of the VRExperienceHelper class
  95134. * @returns "VRExperienceHelper"
  95135. */
  95136. getClassName(): string;
  95137. }
  95138. }
  95139. declare module BABYLON {
  95140. /**
  95141. * Manages an XRSession
  95142. * @see https://doc.babylonjs.com/how_to/webxr
  95143. */
  95144. export class WebXRSessionManager implements IDisposable {
  95145. private scene;
  95146. /**
  95147. * Fires every time a new xrFrame arrives which can be used to update the camera
  95148. */
  95149. onXRFrameObservable: Observable<any>;
  95150. /**
  95151. * Fires when the xr session is ended either by the device or manually done
  95152. */
  95153. onXRSessionEnded: Observable<any>;
  95154. /** @hidden */
  95155. _xrSession: XRSession;
  95156. /** @hidden */
  95157. _frameOfReference: XRFrameOfReference;
  95158. /** @hidden */
  95159. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95160. /** @hidden */
  95161. _currentXRFrame: Nullable<XRFrame>;
  95162. private _xrNavigator;
  95163. private _xrDevice;
  95164. private _tmpMatrix;
  95165. /**
  95166. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95167. * @param scene The scene which the session should be created for
  95168. */
  95169. constructor(scene: Scene);
  95170. /**
  95171. * Initializes the manager
  95172. * After initialization enterXR can be called to start an XR session
  95173. * @returns Promise which resolves after it is initialized
  95174. */
  95175. initializeAsync(): Promise<void>;
  95176. /**
  95177. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95178. * @param sessionCreationOptions xr options to create the session with
  95179. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95180. * @returns Promise which resolves after it enters XR
  95181. */
  95182. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95183. /**
  95184. * Stops the xrSession and restores the renderloop
  95185. * @returns Promise which resolves after it exits XR
  95186. */
  95187. exitXRAsync(): Promise<void>;
  95188. /**
  95189. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95190. * @param ray ray to cast into the environment
  95191. * @returns Promise which resolves with a collision point in the environment if it exists
  95192. */
  95193. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95194. /**
  95195. * Checks if a session would be supported for the creation options specified
  95196. * @param options creation options to check if they are supported
  95197. * @returns true if supported
  95198. */
  95199. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95200. /**
  95201. * @hidden
  95202. * Converts the render layer of xrSession to a render target
  95203. * @param session session to create render target for
  95204. * @param scene scene the new render target should be created for
  95205. */
  95206. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95207. /**
  95208. * Disposes of the session manager
  95209. */
  95210. dispose(): void;
  95211. }
  95212. }
  95213. declare module BABYLON {
  95214. /**
  95215. * WebXR Camera which holds the views for the xrSession
  95216. * @see https://doc.babylonjs.com/how_to/webxr
  95217. */
  95218. export class WebXRCamera extends FreeCamera {
  95219. private static _TmpMatrix;
  95220. /**
  95221. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95222. * @param name the name of the camera
  95223. * @param scene the scene to add the camera to
  95224. */
  95225. constructor(name: string, scene: Scene);
  95226. private _updateNumberOfRigCameras;
  95227. /** @hidden */
  95228. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95229. /**
  95230. * Updates the cameras position from the current pose information of the XR session
  95231. * @param xrSessionManager the session containing pose information
  95232. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95233. */
  95234. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95235. }
  95236. }
  95237. declare module BABYLON {
  95238. /**
  95239. * States of the webXR experience
  95240. */
  95241. export enum WebXRState {
  95242. /**
  95243. * Transitioning to being in XR mode
  95244. */
  95245. ENTERING_XR = 0,
  95246. /**
  95247. * Transitioning to non XR mode
  95248. */
  95249. EXITING_XR = 1,
  95250. /**
  95251. * In XR mode and presenting
  95252. */
  95253. IN_XR = 2,
  95254. /**
  95255. * Not entered XR mode
  95256. */
  95257. NOT_IN_XR = 3
  95258. }
  95259. /**
  95260. * Helper class used to enable XR
  95261. * @see https://doc.babylonjs.com/how_to/webxr
  95262. */
  95263. export class WebXRExperienceHelper implements IDisposable {
  95264. private scene;
  95265. /**
  95266. * 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
  95267. */
  95268. container: AbstractMesh;
  95269. /**
  95270. * Camera used to render xr content
  95271. */
  95272. camera: WebXRCamera;
  95273. /**
  95274. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95275. */
  95276. state: WebXRState;
  95277. private _setState;
  95278. private static _TmpVector;
  95279. /**
  95280. * Fires when the state of the experience helper has changed
  95281. */
  95282. onStateChangedObservable: Observable<WebXRState>;
  95283. /** @hidden */
  95284. _sessionManager: WebXRSessionManager;
  95285. private _nonVRCamera;
  95286. private _originalSceneAutoClear;
  95287. private _supported;
  95288. /**
  95289. * Creates the experience helper
  95290. * @param scene the scene to attach the experience helper to
  95291. * @returns a promise for the experience helper
  95292. */
  95293. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95294. /**
  95295. * Creates a WebXRExperienceHelper
  95296. * @param scene The scene the helper should be created in
  95297. */
  95298. private constructor();
  95299. /**
  95300. * Exits XR mode and returns the scene to its original state
  95301. * @returns promise that resolves after xr mode has exited
  95302. */
  95303. exitXRAsync(): Promise<void>;
  95304. /**
  95305. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95306. * @param sessionCreationOptions options for the XR session
  95307. * @param frameOfReference frame of reference of the XR session
  95308. * @returns promise that resolves after xr mode has entered
  95309. */
  95310. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95311. /**
  95312. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95313. * @param ray ray to cast into the environment
  95314. * @returns Promise which resolves with a collision point in the environment if it exists
  95315. */
  95316. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95317. /**
  95318. * Updates the global position of the camera by moving the camera's container
  95319. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95320. * @param position The desired global position of the camera
  95321. */
  95322. setPositionOfCameraUsingContainer(position: Vector3): void;
  95323. /**
  95324. * Rotates the xr camera by rotating the camera's container around the camera's position
  95325. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95326. * @param rotation the desired quaternion rotation to apply to the camera
  95327. */
  95328. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95329. /**
  95330. * Checks if the creation options are supported by the xr session
  95331. * @param options creation options
  95332. * @returns true if supported
  95333. */
  95334. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95335. /**
  95336. * Disposes of the experience helper
  95337. */
  95338. dispose(): void;
  95339. }
  95340. }
  95341. declare module BABYLON {
  95342. /**
  95343. * Button which can be used to enter a different mode of XR
  95344. */
  95345. export class WebXREnterExitUIButton {
  95346. /** button element */
  95347. element: HTMLElement;
  95348. /** XR initialization options for the button */
  95349. initializationOptions: XRSessionCreationOptions;
  95350. /**
  95351. * Creates a WebXREnterExitUIButton
  95352. * @param element button element
  95353. * @param initializationOptions XR initialization options for the button
  95354. */
  95355. constructor(
  95356. /** button element */
  95357. element: HTMLElement,
  95358. /** XR initialization options for the button */
  95359. initializationOptions: XRSessionCreationOptions);
  95360. /**
  95361. * Overwritable function which can be used to update the button's visuals when the state changes
  95362. * @param activeButton the current active button in the UI
  95363. */
  95364. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95365. }
  95366. /**
  95367. * Options to create the webXR UI
  95368. */
  95369. export class WebXREnterExitUIOptions {
  95370. /**
  95371. * Context to enter xr with
  95372. */
  95373. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95374. /**
  95375. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95376. */
  95377. customButtons?: Array<WebXREnterExitUIButton>;
  95378. }
  95379. /**
  95380. * UI to allow the user to enter/exit XR mode
  95381. */
  95382. export class WebXREnterExitUI implements IDisposable {
  95383. private scene;
  95384. private _overlay;
  95385. private _buttons;
  95386. private _activeButton;
  95387. /**
  95388. * Fired every time the active button is changed.
  95389. *
  95390. * When xr is entered via a button that launches xr that button will be the callback parameter
  95391. *
  95392. * When exiting xr the callback parameter will be null)
  95393. */
  95394. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95395. /**
  95396. * Creates UI to allow the user to enter/exit XR mode
  95397. * @param scene the scene to add the ui to
  95398. * @param helper the xr experience helper to enter/exit xr with
  95399. * @param options options to configure the UI
  95400. * @returns the created ui
  95401. */
  95402. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95403. private constructor();
  95404. private _updateButtons;
  95405. /**
  95406. * Disposes of the object
  95407. */
  95408. dispose(): void;
  95409. }
  95410. }
  95411. declare module BABYLON {
  95412. /**
  95413. * Represents an XR input
  95414. */
  95415. export class WebXRController {
  95416. /**
  95417. * 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
  95418. */
  95419. grip?: AbstractMesh;
  95420. /**
  95421. * Pointer which can be used to select objects or attach a visible laser to
  95422. */
  95423. pointer: AbstractMesh;
  95424. /**
  95425. * Creates the controller
  95426. * @see https://doc.babylonjs.com/how_to/webxr
  95427. * @param scene the scene which the controller should be associated to
  95428. */
  95429. constructor(scene: Scene);
  95430. /**
  95431. * Disposes of the object
  95432. */
  95433. dispose(): void;
  95434. }
  95435. /**
  95436. * XR input used to track XR inputs such as controllers/rays
  95437. */
  95438. export class WebXRInput implements IDisposable {
  95439. private helper;
  95440. /**
  95441. * XR controllers being tracked
  95442. */
  95443. controllers: Array<WebXRController>;
  95444. private _tmpMatrix;
  95445. private _frameObserver;
  95446. /**
  95447. * Initializes the WebXRInput
  95448. * @param helper experience helper which the input should be created for
  95449. */
  95450. constructor(helper: WebXRExperienceHelper);
  95451. /**
  95452. * Disposes of the object
  95453. */
  95454. dispose(): void;
  95455. }
  95456. }
  95457. declare module BABYLON {
  95458. /**
  95459. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95460. */
  95461. export class WebXRManagedOutputCanvas implements IDisposable {
  95462. private _canvas;
  95463. /**
  95464. * xrpresent context of the canvas which can be used to display/mirror xr content
  95465. */
  95466. canvasContext: Nullable<WebGLRenderingContext>;
  95467. /**
  95468. * Initializes the canvas to be added/removed upon entering/exiting xr
  95469. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95470. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95471. */
  95472. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95473. /**
  95474. * Disposes of the object
  95475. */
  95476. dispose(): void;
  95477. private _setManagedOutputCanvas;
  95478. private _addCanvas;
  95479. private _removeCanvas;
  95480. }
  95481. }
  95482. declare module BABYLON {
  95483. /**
  95484. * Contains an array of blocks representing the octree
  95485. */
  95486. export interface IOctreeContainer<T> {
  95487. /**
  95488. * Blocks within the octree
  95489. */
  95490. blocks: Array<OctreeBlock<T>>;
  95491. }
  95492. /**
  95493. * Class used to store a cell in an octree
  95494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95495. */
  95496. export class OctreeBlock<T> {
  95497. /**
  95498. * Gets the content of the current block
  95499. */
  95500. entries: T[];
  95501. /**
  95502. * Gets the list of block children
  95503. */
  95504. blocks: Array<OctreeBlock<T>>;
  95505. private _depth;
  95506. private _maxDepth;
  95507. private _capacity;
  95508. private _minPoint;
  95509. private _maxPoint;
  95510. private _boundingVectors;
  95511. private _creationFunc;
  95512. /**
  95513. * Creates a new block
  95514. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95515. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95516. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95517. * @param depth defines the current depth of this block in the octree
  95518. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95519. * @param creationFunc defines a callback to call when an element is added to the block
  95520. */
  95521. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95522. /**
  95523. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95524. */
  95525. readonly capacity: number;
  95526. /**
  95527. * Gets the minimum vector (in world space) of the block's bounding box
  95528. */
  95529. readonly minPoint: Vector3;
  95530. /**
  95531. * Gets the maximum vector (in world space) of the block's bounding box
  95532. */
  95533. readonly maxPoint: Vector3;
  95534. /**
  95535. * Add a new element to this block
  95536. * @param entry defines the element to add
  95537. */
  95538. addEntry(entry: T): void;
  95539. /**
  95540. * Remove an element from this block
  95541. * @param entry defines the element to remove
  95542. */
  95543. removeEntry(entry: T): void;
  95544. /**
  95545. * Add an array of elements to this block
  95546. * @param entries defines the array of elements to add
  95547. */
  95548. addEntries(entries: T[]): void;
  95549. /**
  95550. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95551. * @param frustumPlanes defines the frustum planes to test
  95552. * @param selection defines the array to store current content if selection is positive
  95553. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95554. */
  95555. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95556. /**
  95557. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95558. * @param sphereCenter defines the bounding sphere center
  95559. * @param sphereRadius defines the bounding sphere radius
  95560. * @param selection defines the array to store current content if selection is positive
  95561. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95562. */
  95563. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95564. /**
  95565. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95566. * @param ray defines the ray to test with
  95567. * @param selection defines the array to store current content if selection is positive
  95568. */
  95569. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95570. /**
  95571. * Subdivide the content into child blocks (this block will then be empty)
  95572. */
  95573. createInnerBlocks(): void;
  95574. /**
  95575. * @hidden
  95576. */
  95577. 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;
  95578. }
  95579. }
  95580. declare module BABYLON {
  95581. /**
  95582. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95583. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95584. */
  95585. export class Octree<T> {
  95586. /** 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.) */
  95587. maxDepth: number;
  95588. /**
  95589. * Blocks within the octree containing objects
  95590. */
  95591. blocks: Array<OctreeBlock<T>>;
  95592. /**
  95593. * Content stored in the octree
  95594. */
  95595. dynamicContent: T[];
  95596. private _maxBlockCapacity;
  95597. private _selectionContent;
  95598. private _creationFunc;
  95599. /**
  95600. * Creates a octree
  95601. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95602. * @param creationFunc function to be used to instatiate the octree
  95603. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95604. * @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.)
  95605. */
  95606. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95607. /** 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.) */
  95608. maxDepth?: number);
  95609. /**
  95610. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95611. * @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);
  95612. * @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);
  95613. * @param entries meshes to be added to the octree blocks
  95614. */
  95615. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95616. /**
  95617. * Adds a mesh to the octree
  95618. * @param entry Mesh to add to the octree
  95619. */
  95620. addMesh(entry: T): void;
  95621. /**
  95622. * Remove an element from the octree
  95623. * @param entry defines the element to remove
  95624. */
  95625. removeMesh(entry: T): void;
  95626. /**
  95627. * Selects an array of meshes within the frustum
  95628. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95629. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95630. * @returns array of meshes within the frustum
  95631. */
  95632. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95633. /**
  95634. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95635. * @param sphereCenter defines the bounding sphere center
  95636. * @param sphereRadius defines the bounding sphere radius
  95637. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95638. * @returns an array of objects that intersect the sphere
  95639. */
  95640. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95641. /**
  95642. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95643. * @param ray defines the ray to test with
  95644. * @returns array of intersected objects
  95645. */
  95646. intersectsRay(ray: Ray): SmartArray<T>;
  95647. /**
  95648. * Adds a mesh into the octree block if it intersects the block
  95649. */
  95650. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95651. /**
  95652. * Adds a submesh into the octree block if it intersects the block
  95653. */
  95654. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95655. }
  95656. }
  95657. declare module BABYLON {
  95658. interface Scene {
  95659. /**
  95660. * @hidden
  95661. * Backing Filed
  95662. */
  95663. _selectionOctree: Octree<AbstractMesh>;
  95664. /**
  95665. * Gets the octree used to boost mesh selection (picking)
  95666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95667. */
  95668. selectionOctree: Octree<AbstractMesh>;
  95669. /**
  95670. * Creates or updates the octree used to boost selection (picking)
  95671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95672. * @param maxCapacity defines the maximum capacity per leaf
  95673. * @param maxDepth defines the maximum depth of the octree
  95674. * @returns an octree of AbstractMesh
  95675. */
  95676. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  95677. }
  95678. interface AbstractMesh {
  95679. /**
  95680. * @hidden
  95681. * Backing Field
  95682. */
  95683. _submeshesOctree: Octree<SubMesh>;
  95684. /**
  95685. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  95686. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95687. * @param maxCapacity defines the maximum size of each block (64 by default)
  95688. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  95689. * @returns the new octree
  95690. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  95691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95692. */
  95693. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  95694. }
  95695. /**
  95696. * Defines the octree scene component responsible to manage any octrees
  95697. * in a given scene.
  95698. */
  95699. export class OctreeSceneComponent {
  95700. /**
  95701. * The component name helpfull to identify the component in the list of scene components.
  95702. */
  95703. readonly name: string;
  95704. /**
  95705. * The scene the component belongs to.
  95706. */
  95707. scene: Scene;
  95708. /**
  95709. * Indicates if the meshes have been checked to make sure they are isEnabled()
  95710. */
  95711. readonly checksIsEnabled: boolean;
  95712. /**
  95713. * Creates a new instance of the component for the given scene
  95714. * @param scene Defines the scene to register the component in
  95715. */
  95716. constructor(scene: Scene);
  95717. /**
  95718. * Registers the component in a given scene
  95719. */
  95720. register(): void;
  95721. /**
  95722. * Return the list of active meshes
  95723. * @returns the list of active meshes
  95724. */
  95725. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95726. /**
  95727. * Return the list of active sub meshes
  95728. * @param mesh The mesh to get the candidates sub meshes from
  95729. * @returns the list of active sub meshes
  95730. */
  95731. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95732. private _tempRay;
  95733. /**
  95734. * Return the list of sub meshes intersecting with a given local ray
  95735. * @param mesh defines the mesh to find the submesh for
  95736. * @param localRay defines the ray in local space
  95737. * @returns the list of intersecting sub meshes
  95738. */
  95739. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  95740. /**
  95741. * Return the list of sub meshes colliding with a collider
  95742. * @param mesh defines the mesh to find the submesh for
  95743. * @param collider defines the collider to evaluate the collision against
  95744. * @returns the list of colliding sub meshes
  95745. */
  95746. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  95747. /**
  95748. * Rebuilds the elements related to this component in case of
  95749. * context lost for instance.
  95750. */
  95751. rebuild(): void;
  95752. /**
  95753. * Disposes the component and the associated ressources.
  95754. */
  95755. dispose(): void;
  95756. }
  95757. }
  95758. declare module BABYLON {
  95759. /**
  95760. * Class containing static functions to help procedurally build meshes
  95761. */
  95762. export class LinesBuilder {
  95763. /**
  95764. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  95765. * * 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
  95766. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  95767. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  95768. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  95769. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  95770. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  95771. * * 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
  95772. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  95773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  95775. * @param name defines the name of the new line system
  95776. * @param options defines the options used to create the line system
  95777. * @param scene defines the hosting scene
  95778. * @returns a new line system mesh
  95779. */
  95780. static CreateLineSystem(name: string, options: {
  95781. lines: Vector3[][];
  95782. updatable?: boolean;
  95783. instance?: Nullable<LinesMesh>;
  95784. colors?: Nullable<Color4[][]>;
  95785. useVertexAlpha?: boolean;
  95786. }, scene: Nullable<Scene>): LinesMesh;
  95787. /**
  95788. * Creates a line mesh
  95789. * 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
  95790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95791. * * The parameter `points` is an array successive Vector3
  95792. * * 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
  95793. * * The optional parameter `colors` is an array of successive Color4, one per line point
  95794. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  95795. * * When updating an instance, remember that only point positions can change, not the number of points
  95796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  95798. * @param name defines the name of the new line system
  95799. * @param options defines the options used to create the line system
  95800. * @param scene defines the hosting scene
  95801. * @returns a new line mesh
  95802. */
  95803. static CreateLines(name: string, options: {
  95804. points: Vector3[];
  95805. updatable?: boolean;
  95806. instance?: Nullable<LinesMesh>;
  95807. colors?: Color4[];
  95808. useVertexAlpha?: boolean;
  95809. }, scene?: Nullable<Scene>): LinesMesh;
  95810. /**
  95811. * Creates a dashed line mesh
  95812. * * 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
  95813. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95814. * * The parameter `points` is an array successive Vector3
  95815. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  95816. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  95817. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95818. * * 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
  95819. * * When updating an instance, remember that only point positions can change, not the number of points
  95820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95821. * @param name defines the name of the mesh
  95822. * @param options defines the options used to create the mesh
  95823. * @param scene defines the hosting scene
  95824. * @returns the dashed line mesh
  95825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  95826. */
  95827. static CreateDashedLines(name: string, options: {
  95828. points: Vector3[];
  95829. dashSize?: number;
  95830. gapSize?: number;
  95831. dashNb?: number;
  95832. updatable?: boolean;
  95833. instance?: LinesMesh;
  95834. }, scene?: Nullable<Scene>): LinesMesh;
  95835. }
  95836. }
  95837. declare module BABYLON {
  95838. /**
  95839. * Renders a layer on top of an existing scene
  95840. */
  95841. export class UtilityLayerRenderer implements IDisposable {
  95842. /** the original scene that will be rendered on top of */
  95843. originalScene: Scene;
  95844. private _pointerCaptures;
  95845. private _lastPointerEvents;
  95846. private static _DefaultUtilityLayer;
  95847. private static _DefaultKeepDepthUtilityLayer;
  95848. /**
  95849. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  95850. */
  95851. pickUtilitySceneFirst: boolean;
  95852. /**
  95853. * 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)
  95854. */
  95855. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  95856. /**
  95857. * 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)
  95858. */
  95859. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  95860. /**
  95861. * The scene that is rendered on top of the original scene
  95862. */
  95863. utilityLayerScene: Scene;
  95864. /**
  95865. * If the utility layer should automatically be rendered on top of existing scene
  95866. */
  95867. shouldRender: boolean;
  95868. /**
  95869. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  95870. */
  95871. onlyCheckPointerDownEvents: boolean;
  95872. /**
  95873. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  95874. */
  95875. processAllEvents: boolean;
  95876. /**
  95877. * Observable raised when the pointer move from the utility layer scene to the main scene
  95878. */
  95879. onPointerOutObservable: Observable<number>;
  95880. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  95881. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  95882. private _afterRenderObserver;
  95883. private _sceneDisposeObserver;
  95884. private _originalPointerObserver;
  95885. /**
  95886. * Instantiates a UtilityLayerRenderer
  95887. * @param originalScene the original scene that will be rendered on top of
  95888. * @param handleEvents boolean indicating if the utility layer should handle events
  95889. */
  95890. constructor(
  95891. /** the original scene that will be rendered on top of */
  95892. originalScene: Scene, handleEvents?: boolean);
  95893. private _notifyObservers;
  95894. /**
  95895. * Renders the utility layers scene on top of the original scene
  95896. */
  95897. render(): void;
  95898. /**
  95899. * Disposes of the renderer
  95900. */
  95901. dispose(): void;
  95902. private _updateCamera;
  95903. }
  95904. }
  95905. declare module BABYLON {
  95906. /**
  95907. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  95908. */
  95909. export class Gizmo implements IDisposable {
  95910. /** The utility layer the gizmo will be added to */
  95911. gizmoLayer: UtilityLayerRenderer;
  95912. /**
  95913. * The root mesh of the gizmo
  95914. */
  95915. _rootMesh: Mesh;
  95916. private _attachedMesh;
  95917. /**
  95918. * Ratio for the scale of the gizmo (Default: 1)
  95919. */
  95920. scaleRatio: number;
  95921. private _tmpMatrix;
  95922. /**
  95923. * If a custom mesh has been set (Default: false)
  95924. */
  95925. protected _customMeshSet: boolean;
  95926. /**
  95927. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  95928. * * When set, interactions will be enabled
  95929. */
  95930. attachedMesh: Nullable<AbstractMesh>;
  95931. /**
  95932. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  95933. * @param mesh The mesh to replace the default mesh of the gizmo
  95934. */
  95935. setCustomMesh(mesh: Mesh): void;
  95936. /**
  95937. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  95938. */
  95939. updateGizmoRotationToMatchAttachedMesh: boolean;
  95940. /**
  95941. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  95942. */
  95943. updateGizmoPositionToMatchAttachedMesh: boolean;
  95944. /**
  95945. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  95946. */
  95947. protected _updateScale: boolean;
  95948. protected _interactionsEnabled: boolean;
  95949. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95950. private _beforeRenderObserver;
  95951. /**
  95952. * Creates a gizmo
  95953. * @param gizmoLayer The utility layer the gizmo will be added to
  95954. */
  95955. constructor(
  95956. /** The utility layer the gizmo will be added to */
  95957. gizmoLayer?: UtilityLayerRenderer);
  95958. private _tempVector;
  95959. /**
  95960. * @hidden
  95961. * Updates the gizmo to match the attached mesh's position/rotation
  95962. */
  95963. protected _update(): void;
  95964. /**
  95965. * Disposes of the gizmo
  95966. */
  95967. dispose(): void;
  95968. }
  95969. }
  95970. declare module BABYLON {
  95971. /**
  95972. * Single axis drag gizmo
  95973. */
  95974. export class AxisDragGizmo extends Gizmo {
  95975. /**
  95976. * Drag behavior responsible for the gizmos dragging interactions
  95977. */
  95978. dragBehavior: PointerDragBehavior;
  95979. private _pointerObserver;
  95980. /**
  95981. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  95982. */
  95983. snapDistance: number;
  95984. /**
  95985. * Event that fires each time the gizmo snaps to a new location.
  95986. * * snapDistance is the the change in distance
  95987. */
  95988. onSnapObservable: Observable<{
  95989. snapDistance: number;
  95990. }>;
  95991. /** @hidden */
  95992. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  95993. /** @hidden */
  95994. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  95995. /**
  95996. * Creates an AxisDragGizmo
  95997. * @param gizmoLayer The utility layer the gizmo will be added to
  95998. * @param dragAxis The axis which the gizmo will be able to drag on
  95999. * @param color The color of the gizmo
  96000. */
  96001. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  96002. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96003. /**
  96004. * Disposes of the gizmo
  96005. */
  96006. dispose(): void;
  96007. }
  96008. }
  96009. declare module BABYLON.Debug {
  96010. /**
  96011. * The Axes viewer will show 3 axes in a specific point in space
  96012. */
  96013. export class AxesViewer {
  96014. private _xAxis;
  96015. private _yAxis;
  96016. private _zAxis;
  96017. private _scaleLinesFactor;
  96018. private _instanced;
  96019. /**
  96020. * Gets the hosting scene
  96021. */
  96022. scene: Scene;
  96023. /**
  96024. * Gets or sets a number used to scale line length
  96025. */
  96026. scaleLines: number;
  96027. /** Gets the node hierarchy used to render x-axis */
  96028. readonly xAxis: TransformNode;
  96029. /** Gets the node hierarchy used to render y-axis */
  96030. readonly yAxis: TransformNode;
  96031. /** Gets the node hierarchy used to render z-axis */
  96032. readonly zAxis: TransformNode;
  96033. /**
  96034. * Creates a new AxesViewer
  96035. * @param scene defines the hosting scene
  96036. * @param scaleLines defines a number used to scale line length (1 by default)
  96037. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  96038. * @param xAxis defines the node hierarchy used to render the x-axis
  96039. * @param yAxis defines the node hierarchy used to render the y-axis
  96040. * @param zAxis defines the node hierarchy used to render the z-axis
  96041. */
  96042. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  96043. /**
  96044. * Force the viewer to update
  96045. * @param position defines the position of the viewer
  96046. * @param xaxis defines the x axis of the viewer
  96047. * @param yaxis defines the y axis of the viewer
  96048. * @param zaxis defines the z axis of the viewer
  96049. */
  96050. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  96051. /**
  96052. * Creates an instance of this axes viewer.
  96053. * @returns a new axes viewer with instanced meshes
  96054. */
  96055. createInstance(): AxesViewer;
  96056. /** Releases resources */
  96057. dispose(): void;
  96058. private static _SetRenderingGroupId;
  96059. }
  96060. }
  96061. declare module BABYLON.Debug {
  96062. /**
  96063. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  96064. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  96065. */
  96066. export class BoneAxesViewer extends AxesViewer {
  96067. /**
  96068. * Gets or sets the target mesh where to display the axes viewer
  96069. */
  96070. mesh: Nullable<Mesh>;
  96071. /**
  96072. * Gets or sets the target bone where to display the axes viewer
  96073. */
  96074. bone: Nullable<Bone>;
  96075. /** Gets current position */
  96076. pos: Vector3;
  96077. /** Gets direction of X axis */
  96078. xaxis: Vector3;
  96079. /** Gets direction of Y axis */
  96080. yaxis: Vector3;
  96081. /** Gets direction of Z axis */
  96082. zaxis: Vector3;
  96083. /**
  96084. * Creates a new BoneAxesViewer
  96085. * @param scene defines the hosting scene
  96086. * @param bone defines the target bone
  96087. * @param mesh defines the target mesh
  96088. * @param scaleLines defines a scaling factor for line length (1 by default)
  96089. */
  96090. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96091. /**
  96092. * Force the viewer to update
  96093. */
  96094. update(): void;
  96095. /** Releases resources */
  96096. dispose(): void;
  96097. }
  96098. }
  96099. declare module BABYLON {
  96100. /**
  96101. * Interface used to define scene explorer extensibility option
  96102. */
  96103. export interface IExplorerExtensibilityOption {
  96104. /**
  96105. * Define the option label
  96106. */
  96107. label: string;
  96108. /**
  96109. * Defines the action to execute on click
  96110. */
  96111. action: (entity: any) => void;
  96112. }
  96113. /**
  96114. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96115. */
  96116. export interface IExplorerExtensibilityGroup {
  96117. /**
  96118. * Defines a predicate to test if a given type mut be extended
  96119. */
  96120. predicate: (entity: any) => boolean;
  96121. /**
  96122. * Gets the list of options added to a type
  96123. */
  96124. entries: IExplorerExtensibilityOption[];
  96125. }
  96126. /**
  96127. * Interface used to define the options to use to create the Inspector
  96128. */
  96129. export interface IInspectorOptions {
  96130. /**
  96131. * Display in overlay mode (default: false)
  96132. */
  96133. overlay?: boolean;
  96134. /**
  96135. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96136. */
  96137. globalRoot?: HTMLElement;
  96138. /**
  96139. * Display the Scene explorer
  96140. */
  96141. showExplorer?: boolean;
  96142. /**
  96143. * Display the property inspector
  96144. */
  96145. showInspector?: boolean;
  96146. /**
  96147. * Display in embed mode (both panes on the right)
  96148. */
  96149. embedMode?: boolean;
  96150. /**
  96151. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96152. */
  96153. handleResize?: boolean;
  96154. /**
  96155. * Allow the panes to popup (default: true)
  96156. */
  96157. enablePopup?: boolean;
  96158. /**
  96159. * Allow the panes to be closed by users (default: true)
  96160. */
  96161. enableClose?: boolean;
  96162. /**
  96163. * Optional list of extensibility entries
  96164. */
  96165. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96166. }
  96167. interface Scene {
  96168. /**
  96169. * @hidden
  96170. * Backing field
  96171. */
  96172. _debugLayer: DebugLayer;
  96173. /**
  96174. * Gets the debug layer (aka Inspector) associated with the scene
  96175. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96176. */
  96177. debugLayer: DebugLayer;
  96178. }
  96179. /**
  96180. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96181. * what is happening in your scene
  96182. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96183. */
  96184. export class DebugLayer {
  96185. /**
  96186. * Define the url to get the inspector script from.
  96187. * By default it uses the babylonjs CDN.
  96188. * @ignoreNaming
  96189. */
  96190. static InspectorURL: string;
  96191. private _scene;
  96192. private BJSINSPECTOR;
  96193. /**
  96194. * Observable triggered when a property is changed through the inspector.
  96195. */
  96196. onPropertyChangedObservable: Observable<{
  96197. object: any;
  96198. property: string;
  96199. value: any;
  96200. initialValue: any;
  96201. }>;
  96202. /**
  96203. * Instantiates a new debug layer.
  96204. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96205. * what is happening in your scene
  96206. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96207. * @param scene Defines the scene to inspect
  96208. */
  96209. constructor(scene: Scene);
  96210. /** Creates the inspector window. */
  96211. private _createInspector;
  96212. /** Get the inspector from bundle or global */
  96213. private _getGlobalInspector;
  96214. /**
  96215. * Get if the inspector is visible or not.
  96216. * @returns true if visible otherwise, false
  96217. */
  96218. isVisible(): boolean;
  96219. /**
  96220. * Hide the inspector and close its window.
  96221. */
  96222. hide(): void;
  96223. /**
  96224. * Launch the debugLayer.
  96225. * @param config Define the configuration of the inspector
  96226. */
  96227. show(config?: IInspectorOptions): void;
  96228. }
  96229. }
  96230. declare module BABYLON {
  96231. /**
  96232. * Class containing static functions to help procedurally build meshes
  96233. */
  96234. export class BoxBuilder {
  96235. /**
  96236. * Creates a box mesh
  96237. * * The parameter `size` sets the size (float) of each box side (default 1)
  96238. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96239. * * 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)
  96240. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96244. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96245. * @param name defines the name of the mesh
  96246. * @param options defines the options used to create the mesh
  96247. * @param scene defines the hosting scene
  96248. * @returns the box mesh
  96249. */
  96250. static CreateBox(name: string, options: {
  96251. size?: number;
  96252. width?: number;
  96253. height?: number;
  96254. depth?: number;
  96255. faceUV?: Vector4[];
  96256. faceColors?: Color4[];
  96257. sideOrientation?: number;
  96258. frontUVs?: Vector4;
  96259. backUVs?: Vector4;
  96260. updatable?: boolean;
  96261. }, scene?: Nullable<Scene>): Mesh;
  96262. }
  96263. }
  96264. declare module BABYLON {
  96265. /**
  96266. * Class containing static functions to help procedurally build meshes
  96267. */
  96268. export class SphereBuilder {
  96269. /**
  96270. * Creates a sphere mesh
  96271. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96272. * * 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`)
  96273. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96274. * * 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
  96275. * * 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)
  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. * @param name defines the name of the mesh
  96280. * @param options defines the options used to create the mesh
  96281. * @param scene defines the hosting scene
  96282. * @returns the sphere mesh
  96283. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96284. */
  96285. static CreateSphere(name: string, options: {
  96286. segments?: number;
  96287. diameter?: number;
  96288. diameterX?: number;
  96289. diameterY?: number;
  96290. diameterZ?: number;
  96291. arc?: number;
  96292. slice?: number;
  96293. sideOrientation?: number;
  96294. frontUVs?: Vector4;
  96295. backUVs?: Vector4;
  96296. updatable?: boolean;
  96297. }, scene: any): Mesh;
  96298. }
  96299. }
  96300. declare module BABYLON.Debug {
  96301. /**
  96302. * Used to show the physics impostor around the specific mesh
  96303. */
  96304. export class PhysicsViewer {
  96305. /** @hidden */
  96306. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96307. /** @hidden */
  96308. protected _meshes: Array<Nullable<AbstractMesh>>;
  96309. /** @hidden */
  96310. protected _scene: Nullable<Scene>;
  96311. /** @hidden */
  96312. protected _numMeshes: number;
  96313. /** @hidden */
  96314. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96315. private _renderFunction;
  96316. private _utilityLayer;
  96317. private _debugBoxMesh;
  96318. private _debugSphereMesh;
  96319. private _debugMaterial;
  96320. /**
  96321. * Creates a new PhysicsViewer
  96322. * @param scene defines the hosting scene
  96323. */
  96324. constructor(scene: Scene);
  96325. /** @hidden */
  96326. protected _updateDebugMeshes(): void;
  96327. /**
  96328. * Renders a specified physic impostor
  96329. * @param impostor defines the impostor to render
  96330. * @returns the new debug mesh used to render the impostor
  96331. */
  96332. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96333. /**
  96334. * Hides a specified physic impostor
  96335. * @param impostor defines the impostor to hide
  96336. */
  96337. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96338. private _getDebugMaterial;
  96339. private _getDebugBoxMesh;
  96340. private _getDebugSphereMesh;
  96341. private _getDebugMesh;
  96342. /** Releases all resources */
  96343. dispose(): void;
  96344. }
  96345. }
  96346. declare module BABYLON {
  96347. /**
  96348. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96349. * in order to better appreciate the issue one might have.
  96350. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96351. */
  96352. export class RayHelper {
  96353. /**
  96354. * Defines the ray we are currently tryin to visualize.
  96355. */
  96356. ray: Nullable<Ray>;
  96357. private _renderPoints;
  96358. private _renderLine;
  96359. private _renderFunction;
  96360. private _scene;
  96361. private _updateToMeshFunction;
  96362. private _attachedToMesh;
  96363. private _meshSpaceDirection;
  96364. private _meshSpaceOrigin;
  96365. /**
  96366. * Helper function to create a colored helper in a scene in one line.
  96367. * @param ray Defines the ray we are currently tryin to visualize
  96368. * @param scene Defines the scene the ray is used in
  96369. * @param color Defines the color we want to see the ray in
  96370. * @returns The newly created ray helper.
  96371. */
  96372. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96373. /**
  96374. * Instantiate a new ray helper.
  96375. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96376. * in order to better appreciate the issue one might have.
  96377. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96378. * @param ray Defines the ray we are currently tryin to visualize
  96379. */
  96380. constructor(ray: Ray);
  96381. /**
  96382. * Shows the ray we are willing to debug.
  96383. * @param scene Defines the scene the ray needs to be rendered in
  96384. * @param color Defines the color the ray needs to be rendered in
  96385. */
  96386. show(scene: Scene, color?: Color3): void;
  96387. /**
  96388. * Hides the ray we are debugging.
  96389. */
  96390. hide(): void;
  96391. private _render;
  96392. /**
  96393. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96394. * @param mesh Defines the mesh we want the helper attached to
  96395. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96396. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96397. * @param length Defines the length of the ray
  96398. */
  96399. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96400. /**
  96401. * Detach the ray helper from the mesh it has previously been attached to.
  96402. */
  96403. detachFromMesh(): void;
  96404. private _updateToMesh;
  96405. /**
  96406. * Dispose the helper and release its associated resources.
  96407. */
  96408. dispose(): void;
  96409. }
  96410. }
  96411. declare module BABYLON.Debug {
  96412. /**
  96413. * Class used to render a debug view of a given skeleton
  96414. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96415. */
  96416. export class SkeletonViewer {
  96417. /** defines the skeleton to render */
  96418. skeleton: Skeleton;
  96419. /** defines the mesh attached to the skeleton */
  96420. mesh: AbstractMesh;
  96421. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96422. autoUpdateBonesMatrices: boolean;
  96423. /** defines the rendering group id to use with the viewer */
  96424. renderingGroupId: number;
  96425. /** Gets or sets the color used to render the skeleton */
  96426. color: Color3;
  96427. private _scene;
  96428. private _debugLines;
  96429. private _debugMesh;
  96430. private _isEnabled;
  96431. private _renderFunction;
  96432. private _utilityLayer;
  96433. /**
  96434. * Returns the mesh used to render the bones
  96435. */
  96436. readonly debugMesh: Nullable<LinesMesh>;
  96437. /**
  96438. * Creates a new SkeletonViewer
  96439. * @param skeleton defines the skeleton to render
  96440. * @param mesh defines the mesh attached to the skeleton
  96441. * @param scene defines the hosting scene
  96442. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96443. * @param renderingGroupId defines the rendering group id to use with the viewer
  96444. */
  96445. constructor(
  96446. /** defines the skeleton to render */
  96447. skeleton: Skeleton,
  96448. /** defines the mesh attached to the skeleton */
  96449. mesh: AbstractMesh, scene: Scene,
  96450. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96451. autoUpdateBonesMatrices?: boolean,
  96452. /** defines the rendering group id to use with the viewer */
  96453. renderingGroupId?: number);
  96454. /** Gets or sets a boolean indicating if the viewer is enabled */
  96455. isEnabled: boolean;
  96456. private _getBonePosition;
  96457. private _getLinesForBonesWithLength;
  96458. private _getLinesForBonesNoLength;
  96459. /** Update the viewer to sync with current skeleton state */
  96460. update(): void;
  96461. /** Release associated resources */
  96462. dispose(): void;
  96463. }
  96464. }
  96465. declare module BABYLON {
  96466. /**
  96467. * Options to create the null engine
  96468. */
  96469. export class NullEngineOptions {
  96470. /**
  96471. * Render width (Default: 512)
  96472. */
  96473. renderWidth: number;
  96474. /**
  96475. * Render height (Default: 256)
  96476. */
  96477. renderHeight: number;
  96478. /**
  96479. * Texture size (Default: 512)
  96480. */
  96481. textureSize: number;
  96482. /**
  96483. * If delta time between frames should be constant
  96484. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96485. */
  96486. deterministicLockstep: boolean;
  96487. /**
  96488. * Maximum about of steps between frames (Default: 4)
  96489. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96490. */
  96491. lockstepMaxSteps: number;
  96492. }
  96493. /**
  96494. * The null engine class provides support for headless version of babylon.js.
  96495. * This can be used in server side scenario or for testing purposes
  96496. */
  96497. export class NullEngine extends Engine {
  96498. private _options;
  96499. /**
  96500. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96501. */
  96502. isDeterministicLockStep(): boolean;
  96503. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96504. getLockstepMaxSteps(): number;
  96505. /**
  96506. * Sets hardware scaling, used to save performance if needed
  96507. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96508. */
  96509. getHardwareScalingLevel(): number;
  96510. constructor(options?: NullEngineOptions);
  96511. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96512. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96513. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96514. getRenderWidth(useScreen?: boolean): number;
  96515. getRenderHeight(useScreen?: boolean): number;
  96516. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96517. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96518. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96519. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96520. bindSamplers(effect: Effect): void;
  96521. enableEffect(effect: Effect): void;
  96522. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96523. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96524. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96525. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96526. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96527. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96528. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96529. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96530. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96531. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96532. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96533. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96534. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96535. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96536. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96537. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96538. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96539. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96540. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96541. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96542. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96543. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96544. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96545. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96546. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96547. bindBuffers(vertexBuffers: {
  96548. [key: string]: VertexBuffer;
  96549. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96550. wipeCaches(bruteForce?: boolean): void;
  96551. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96552. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96553. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96554. /** @hidden */
  96555. _createTexture(): WebGLTexture;
  96556. /** @hidden */
  96557. _releaseTexture(texture: InternalTexture): void;
  96558. 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;
  96559. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96560. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96561. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96562. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96563. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96564. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96565. areAllEffectsReady(): boolean;
  96566. /**
  96567. * @hidden
  96568. * Get the current error code of the webGL context
  96569. * @returns the error code
  96570. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96571. */
  96572. getError(): number;
  96573. /** @hidden */
  96574. _getUnpackAlignement(): number;
  96575. /** @hidden */
  96576. _unpackFlipY(value: boolean): void;
  96577. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96578. /**
  96579. * Updates a dynamic vertex buffer.
  96580. * @param vertexBuffer the vertex buffer to update
  96581. * @param data the data used to update the vertex buffer
  96582. * @param byteOffset the byte offset of the data (optional)
  96583. * @param byteLength the byte length of the data (optional)
  96584. */
  96585. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96586. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96587. /** @hidden */
  96588. _bindTexture(channel: number, texture: InternalTexture): void;
  96589. /** @hidden */
  96590. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96591. releaseEffects(): void;
  96592. displayLoadingUI(): void;
  96593. hideLoadingUI(): void;
  96594. /** @hidden */
  96595. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96596. /** @hidden */
  96597. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96598. /** @hidden */
  96599. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96600. /** @hidden */
  96601. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96602. }
  96603. }
  96604. declare module BABYLON {
  96605. /** @hidden */
  96606. export class _OcclusionDataStorage {
  96607. /** @hidden */
  96608. occlusionInternalRetryCounter: number;
  96609. /** @hidden */
  96610. isOcclusionQueryInProgress: boolean;
  96611. /** @hidden */
  96612. isOccluded: boolean;
  96613. /** @hidden */
  96614. occlusionRetryCount: number;
  96615. /** @hidden */
  96616. occlusionType: number;
  96617. /** @hidden */
  96618. occlusionQueryAlgorithmType: number;
  96619. }
  96620. interface Engine {
  96621. /**
  96622. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96623. * @return the new query
  96624. */
  96625. createQuery(): WebGLQuery;
  96626. /**
  96627. * Delete and release a webGL query
  96628. * @param query defines the query to delete
  96629. * @return the current engine
  96630. */
  96631. deleteQuery(query: WebGLQuery): Engine;
  96632. /**
  96633. * Check if a given query has resolved and got its value
  96634. * @param query defines the query to check
  96635. * @returns true if the query got its value
  96636. */
  96637. isQueryResultAvailable(query: WebGLQuery): boolean;
  96638. /**
  96639. * Gets the value of a given query
  96640. * @param query defines the query to check
  96641. * @returns the value of the query
  96642. */
  96643. getQueryResult(query: WebGLQuery): number;
  96644. /**
  96645. * Initiates an occlusion query
  96646. * @param algorithmType defines the algorithm to use
  96647. * @param query defines the query to use
  96648. * @returns the current engine
  96649. * @see http://doc.babylonjs.com/features/occlusionquery
  96650. */
  96651. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96652. /**
  96653. * Ends an occlusion query
  96654. * @see http://doc.babylonjs.com/features/occlusionquery
  96655. * @param algorithmType defines the algorithm to use
  96656. * @returns the current engine
  96657. */
  96658. endOcclusionQuery(algorithmType: number): Engine;
  96659. /**
  96660. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  96661. * Please note that only one query can be issued at a time
  96662. * @returns a time token used to track the time span
  96663. */
  96664. startTimeQuery(): Nullable<_TimeToken>;
  96665. /**
  96666. * Ends a time query
  96667. * @param token defines the token used to measure the time span
  96668. * @returns the time spent (in ns)
  96669. */
  96670. endTimeQuery(token: _TimeToken): int;
  96671. /** @hidden */
  96672. _currentNonTimestampToken: Nullable<_TimeToken>;
  96673. /** @hidden */
  96674. _createTimeQuery(): WebGLQuery;
  96675. /** @hidden */
  96676. _deleteTimeQuery(query: WebGLQuery): void;
  96677. /** @hidden */
  96678. _getGlAlgorithmType(algorithmType: number): number;
  96679. /** @hidden */
  96680. _getTimeQueryResult(query: WebGLQuery): any;
  96681. /** @hidden */
  96682. _getTimeQueryAvailability(query: WebGLQuery): any;
  96683. }
  96684. interface AbstractMesh {
  96685. /**
  96686. * Backing filed
  96687. * @hidden
  96688. */
  96689. __occlusionDataStorage: _OcclusionDataStorage;
  96690. /**
  96691. * Access property
  96692. * @hidden
  96693. */
  96694. _occlusionDataStorage: _OcclusionDataStorage;
  96695. /**
  96696. * 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.
  96697. * The default value is -1 which means don't break the query and wait till the result
  96698. * @see http://doc.babylonjs.com/features/occlusionquery
  96699. */
  96700. occlusionRetryCount: number;
  96701. /**
  96702. * 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:
  96703. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  96704. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  96705. * * 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.
  96706. * @see http://doc.babylonjs.com/features/occlusionquery
  96707. */
  96708. occlusionType: number;
  96709. /**
  96710. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  96711. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  96712. * * 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.
  96713. * @see http://doc.babylonjs.com/features/occlusionquery
  96714. */
  96715. occlusionQueryAlgorithmType: number;
  96716. /**
  96717. * 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
  96718. * @see http://doc.babylonjs.com/features/occlusionquery
  96719. */
  96720. isOccluded: boolean;
  96721. /**
  96722. * Flag to check the progress status of the query
  96723. * @see http://doc.babylonjs.com/features/occlusionquery
  96724. */
  96725. isOcclusionQueryInProgress: boolean;
  96726. }
  96727. }
  96728. declare module BABYLON {
  96729. /** @hidden */
  96730. export var _forceTransformFeedbackToBundle: boolean;
  96731. interface Engine {
  96732. /**
  96733. * Creates a webGL transform feedback object
  96734. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  96735. * @returns the webGL transform feedback object
  96736. */
  96737. createTransformFeedback(): WebGLTransformFeedback;
  96738. /**
  96739. * Delete a webGL transform feedback object
  96740. * @param value defines the webGL transform feedback object to delete
  96741. */
  96742. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  96743. /**
  96744. * Bind a webGL transform feedback object to the webgl context
  96745. * @param value defines the webGL transform feedback object to bind
  96746. */
  96747. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  96748. /**
  96749. * Begins a transform feedback operation
  96750. * @param usePoints defines if points or triangles must be used
  96751. */
  96752. beginTransformFeedback(usePoints: boolean): void;
  96753. /**
  96754. * Ends a transform feedback operation
  96755. */
  96756. endTransformFeedback(): void;
  96757. /**
  96758. * Specify the varyings to use with transform feedback
  96759. * @param program defines the associated webGL program
  96760. * @param value defines the list of strings representing the varying names
  96761. */
  96762. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  96763. /**
  96764. * Bind a webGL buffer for a transform feedback operation
  96765. * @param value defines the webGL buffer to bind
  96766. */
  96767. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  96768. }
  96769. }
  96770. declare module BABYLON {
  96771. /**
  96772. * Gather the list of clipboard event types as constants.
  96773. */
  96774. export class ClipboardEventTypes {
  96775. /**
  96776. * The clipboard event is fired when a copy command is active (pressed).
  96777. */
  96778. static readonly COPY: number;
  96779. /**
  96780. * The clipboard event is fired when a cut command is active (pressed).
  96781. */
  96782. static readonly CUT: number;
  96783. /**
  96784. * The clipboard event is fired when a paste command is active (pressed).
  96785. */
  96786. static readonly PASTE: number;
  96787. }
  96788. /**
  96789. * This class is used to store clipboard related info for the onClipboardObservable event.
  96790. */
  96791. export class ClipboardInfo {
  96792. /**
  96793. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96794. */
  96795. type: number;
  96796. /**
  96797. * Defines the related dom event
  96798. */
  96799. event: ClipboardEvent;
  96800. /**
  96801. *Creates an instance of ClipboardInfo.
  96802. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  96803. * @param event Defines the related dom event
  96804. */
  96805. constructor(
  96806. /**
  96807. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96808. */
  96809. type: number,
  96810. /**
  96811. * Defines the related dom event
  96812. */
  96813. event: ClipboardEvent);
  96814. /**
  96815. * Get the clipboard event's type from the keycode.
  96816. * @param keyCode Defines the keyCode for the current keyboard event.
  96817. * @return {number}
  96818. */
  96819. static GetTypeFromCharacter(keyCode: number): number;
  96820. }
  96821. }
  96822. declare module BABYLON {
  96823. /**
  96824. * Class used to represent data loading progression
  96825. */
  96826. export class SceneLoaderProgressEvent {
  96827. /** defines if data length to load can be evaluated */
  96828. readonly lengthComputable: boolean;
  96829. /** defines the loaded data length */
  96830. readonly loaded: number;
  96831. /** defines the data length to load */
  96832. readonly total: number;
  96833. /**
  96834. * Create a new progress event
  96835. * @param lengthComputable defines if data length to load can be evaluated
  96836. * @param loaded defines the loaded data length
  96837. * @param total defines the data length to load
  96838. */
  96839. constructor(
  96840. /** defines if data length to load can be evaluated */
  96841. lengthComputable: boolean,
  96842. /** defines the loaded data length */
  96843. loaded: number,
  96844. /** defines the data length to load */
  96845. total: number);
  96846. /**
  96847. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  96848. * @param event defines the source event
  96849. * @returns a new SceneLoaderProgressEvent
  96850. */
  96851. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  96852. }
  96853. /**
  96854. * Interface used by SceneLoader plugins to define supported file extensions
  96855. */
  96856. export interface ISceneLoaderPluginExtensions {
  96857. /**
  96858. * Defines the list of supported extensions
  96859. */
  96860. [extension: string]: {
  96861. isBinary: boolean;
  96862. };
  96863. }
  96864. /**
  96865. * Interface used by SceneLoader plugin factory
  96866. */
  96867. export interface ISceneLoaderPluginFactory {
  96868. /**
  96869. * Defines the name of the factory
  96870. */
  96871. name: string;
  96872. /**
  96873. * Function called to create a new plugin
  96874. * @return the new plugin
  96875. */
  96876. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  96877. /**
  96878. * Boolean indicating if the plugin can direct load specific data
  96879. */
  96880. canDirectLoad?: (data: string) => boolean;
  96881. }
  96882. /**
  96883. * Interface used to define a SceneLoader plugin
  96884. */
  96885. export interface ISceneLoaderPlugin {
  96886. /**
  96887. * The friendly name of this plugin.
  96888. */
  96889. name: string;
  96890. /**
  96891. * The file extensions supported by this plugin.
  96892. */
  96893. extensions: string | ISceneLoaderPluginExtensions;
  96894. /**
  96895. * Import meshes into a scene.
  96896. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96897. * @param scene The scene to import into
  96898. * @param data The data to import
  96899. * @param rootUrl The root url for scene and resources
  96900. * @param meshes The meshes array to import into
  96901. * @param particleSystems The particle systems array to import into
  96902. * @param skeletons The skeletons array to import into
  96903. * @param onError The callback when import fails
  96904. * @returns True if successful or false otherwise
  96905. */
  96906. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  96907. /**
  96908. * Load into a scene.
  96909. * @param scene The scene to load into
  96910. * @param data The data to import
  96911. * @param rootUrl The root url for scene and resources
  96912. * @param onError The callback when import fails
  96913. * @returns true if successful or false otherwise
  96914. */
  96915. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  96916. /**
  96917. * The callback that returns true if the data can be directly loaded.
  96918. */
  96919. canDirectLoad?: (data: string) => boolean;
  96920. /**
  96921. * The callback that allows custom handling of the root url based on the response url.
  96922. */
  96923. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96924. /**
  96925. * Load into an asset container.
  96926. * @param scene The scene to load into
  96927. * @param data The data to import
  96928. * @param rootUrl The root url for scene and resources
  96929. * @param onError The callback when import fails
  96930. * @returns The loaded asset container
  96931. */
  96932. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  96933. }
  96934. /**
  96935. * Interface used to define an async SceneLoader plugin
  96936. */
  96937. export interface ISceneLoaderPluginAsync {
  96938. /**
  96939. * The friendly name of this plugin.
  96940. */
  96941. name: string;
  96942. /**
  96943. * The file extensions supported by this plugin.
  96944. */
  96945. extensions: string | ISceneLoaderPluginExtensions;
  96946. /**
  96947. * Import meshes into a scene.
  96948. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96949. * @param scene The scene to import into
  96950. * @param data The data to import
  96951. * @param rootUrl The root url for scene and resources
  96952. * @param onProgress The callback when the load progresses
  96953. * @param fileName Defines the name of the file to load
  96954. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  96955. */
  96956. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  96957. meshes: AbstractMesh[];
  96958. particleSystems: IParticleSystem[];
  96959. skeletons: Skeleton[];
  96960. animationGroups: AnimationGroup[];
  96961. }>;
  96962. /**
  96963. * Load into a scene.
  96964. * @param scene The scene to load into
  96965. * @param data The data to import
  96966. * @param rootUrl The root url for scene and resources
  96967. * @param onProgress The callback when the load progresses
  96968. * @param fileName Defines the name of the file to load
  96969. * @returns Nothing
  96970. */
  96971. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  96972. /**
  96973. * The callback that returns true if the data can be directly loaded.
  96974. */
  96975. canDirectLoad?: (data: string) => boolean;
  96976. /**
  96977. * The callback that allows custom handling of the root url based on the response url.
  96978. */
  96979. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96980. /**
  96981. * Load into an asset container.
  96982. * @param scene The scene to load into
  96983. * @param data The data to import
  96984. * @param rootUrl The root url for scene and resources
  96985. * @param onProgress The callback when the load progresses
  96986. * @param fileName Defines the name of the file to load
  96987. * @returns The loaded asset container
  96988. */
  96989. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  96990. }
  96991. /**
  96992. * Class used to load scene from various file formats using registered plugins
  96993. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  96994. */
  96995. export class SceneLoader {
  96996. /**
  96997. * No logging while loading
  96998. */
  96999. static readonly NO_LOGGING: number;
  97000. /**
  97001. * Minimal logging while loading
  97002. */
  97003. static readonly MINIMAL_LOGGING: number;
  97004. /**
  97005. * Summary logging while loading
  97006. */
  97007. static readonly SUMMARY_LOGGING: number;
  97008. /**
  97009. * Detailled logging while loading
  97010. */
  97011. static readonly DETAILED_LOGGING: number;
  97012. /**
  97013. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97014. */
  97015. static ForceFullSceneLoadingForIncremental: boolean;
  97016. /**
  97017. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97018. */
  97019. static ShowLoadingScreen: boolean;
  97020. /**
  97021. * Defines the current logging level (while loading the scene)
  97022. * @ignorenaming
  97023. */
  97024. static loggingLevel: number;
  97025. /**
  97026. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97027. */
  97028. static CleanBoneMatrixWeights: boolean;
  97029. /**
  97030. * Event raised when a plugin is used to load a scene
  97031. */
  97032. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  97033. private static _registeredPlugins;
  97034. private static _getDefaultPlugin;
  97035. private static _getPluginForExtension;
  97036. private static _getPluginForDirectLoad;
  97037. private static _getPluginForFilename;
  97038. private static _getDirectLoad;
  97039. private static _loadData;
  97040. private static _getFileInfo;
  97041. /**
  97042. * Gets a plugin that can load the given extension
  97043. * @param extension defines the extension to load
  97044. * @returns a plugin or null if none works
  97045. */
  97046. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  97047. /**
  97048. * Gets a boolean indicating that the given extension can be loaded
  97049. * @param extension defines the extension to load
  97050. * @returns true if the extension is supported
  97051. */
  97052. static IsPluginForExtensionAvailable(extension: string): boolean;
  97053. /**
  97054. * Adds a new plugin to the list of registered plugins
  97055. * @param plugin defines the plugin to add
  97056. */
  97057. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  97058. /**
  97059. * Import meshes into a scene
  97060. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97061. * @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)
  97062. * @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)
  97063. * @param scene the instance of BABYLON.Scene to append to
  97064. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  97065. * @param onProgress a callback with a progress event for each file being loaded
  97066. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97067. * @param pluginExtension the extension used to determine the plugin
  97068. * @returns The loaded plugin
  97069. */
  97070. 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>;
  97071. /**
  97072. * Import meshes into a scene
  97073. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97074. * @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)
  97075. * @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)
  97076. * @param scene the instance of BABYLON.Scene to append to
  97077. * @param onProgress a callback with a progress event for each file being loaded
  97078. * @param pluginExtension the extension used to determine the plugin
  97079. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97080. */
  97081. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97082. meshes: AbstractMesh[];
  97083. particleSystems: IParticleSystem[];
  97084. skeletons: Skeleton[];
  97085. animationGroups: AnimationGroup[];
  97086. }>;
  97087. /**
  97088. * Load a scene
  97089. * @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)
  97090. * @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)
  97091. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97092. * @param onSuccess a callback with the scene when import succeeds
  97093. * @param onProgress a callback with a progress event for each file being loaded
  97094. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97095. * @param pluginExtension the extension used to determine the plugin
  97096. * @returns The loaded plugin
  97097. */
  97098. 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>;
  97099. /**
  97100. * Load a scene
  97101. * @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)
  97102. * @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)
  97103. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97104. * @param onProgress a callback with a progress event for each file being loaded
  97105. * @param pluginExtension the extension used to determine the plugin
  97106. * @returns The loaded scene
  97107. */
  97108. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97109. /**
  97110. * Append a scene
  97111. * @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)
  97112. * @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)
  97113. * @param scene is the instance of BABYLON.Scene to append to
  97114. * @param onSuccess a callback with the scene when import succeeds
  97115. * @param onProgress a callback with a progress event for each file being loaded
  97116. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97117. * @param pluginExtension the extension used to determine the plugin
  97118. * @returns The loaded plugin
  97119. */
  97120. 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>;
  97121. /**
  97122. * Append a scene
  97123. * @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)
  97124. * @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)
  97125. * @param scene is the instance of BABYLON.Scene to append to
  97126. * @param onProgress a callback with a progress event for each file being loaded
  97127. * @param pluginExtension the extension used to determine the plugin
  97128. * @returns The given scene
  97129. */
  97130. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97131. /**
  97132. * Load a scene into an asset container
  97133. * @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)
  97134. * @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)
  97135. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97136. * @param onSuccess a callback with the scene when import succeeds
  97137. * @param onProgress a callback with a progress event for each file being loaded
  97138. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97139. * @param pluginExtension the extension used to determine the plugin
  97140. * @returns The loaded plugin
  97141. */
  97142. 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>;
  97143. /**
  97144. * Load a scene into an asset container
  97145. * @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)
  97146. * @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)
  97147. * @param scene is the instance of Scene to append to
  97148. * @param onProgress a callback with a progress event for each file being loaded
  97149. * @param pluginExtension the extension used to determine the plugin
  97150. * @returns The loaded asset container
  97151. */
  97152. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97153. }
  97154. }
  97155. declare module BABYLON {
  97156. /**
  97157. * Google Daydream controller
  97158. */
  97159. export class DaydreamController extends WebVRController {
  97160. /**
  97161. * Base Url for the controller model.
  97162. */
  97163. static MODEL_BASE_URL: string;
  97164. /**
  97165. * File name for the controller model.
  97166. */
  97167. static MODEL_FILENAME: string;
  97168. /**
  97169. * Gamepad Id prefix used to identify Daydream Controller.
  97170. */
  97171. static readonly GAMEPAD_ID_PREFIX: string;
  97172. /**
  97173. * Creates a new DaydreamController from a gamepad
  97174. * @param vrGamepad the gamepad that the controller should be created from
  97175. */
  97176. constructor(vrGamepad: any);
  97177. /**
  97178. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97179. * @param scene scene in which to add meshes
  97180. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97181. */
  97182. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97183. /**
  97184. * Called once for each button that changed state since the last frame
  97185. * @param buttonIdx Which button index changed
  97186. * @param state New state of the button
  97187. * @param changes Which properties on the state changed since last frame
  97188. */
  97189. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97190. }
  97191. }
  97192. declare module BABYLON {
  97193. /**
  97194. * Gear VR Controller
  97195. */
  97196. export class GearVRController extends WebVRController {
  97197. /**
  97198. * Base Url for the controller model.
  97199. */
  97200. static MODEL_BASE_URL: string;
  97201. /**
  97202. * File name for the controller model.
  97203. */
  97204. static MODEL_FILENAME: string;
  97205. /**
  97206. * Gamepad Id prefix used to identify this controller.
  97207. */
  97208. static readonly GAMEPAD_ID_PREFIX: string;
  97209. private readonly _buttonIndexToObservableNameMap;
  97210. /**
  97211. * Creates a new GearVRController from a gamepad
  97212. * @param vrGamepad the gamepad that the controller should be created from
  97213. */
  97214. constructor(vrGamepad: any);
  97215. /**
  97216. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97217. * @param scene scene in which to add meshes
  97218. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97219. */
  97220. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97221. /**
  97222. * Called once for each button that changed state since the last frame
  97223. * @param buttonIdx Which button index changed
  97224. * @param state New state of the button
  97225. * @param changes Which properties on the state changed since last frame
  97226. */
  97227. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97228. }
  97229. }
  97230. declare module BABYLON {
  97231. /**
  97232. * Generic Controller
  97233. */
  97234. export class GenericController extends WebVRController {
  97235. /**
  97236. * Base Url for the controller model.
  97237. */
  97238. static readonly MODEL_BASE_URL: string;
  97239. /**
  97240. * File name for the controller model.
  97241. */
  97242. static readonly MODEL_FILENAME: string;
  97243. /**
  97244. * Creates a new GenericController from a gamepad
  97245. * @param vrGamepad the gamepad that the controller should be created from
  97246. */
  97247. constructor(vrGamepad: any);
  97248. /**
  97249. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97250. * @param scene scene in which to add meshes
  97251. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97252. */
  97253. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97254. /**
  97255. * Called once for each button that changed state since the last frame
  97256. * @param buttonIdx Which button index changed
  97257. * @param state New state of the button
  97258. * @param changes Which properties on the state changed since last frame
  97259. */
  97260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97261. }
  97262. }
  97263. declare module BABYLON {
  97264. /**
  97265. * Oculus Touch Controller
  97266. */
  97267. export class OculusTouchController extends WebVRController {
  97268. /**
  97269. * Base Url for the controller model.
  97270. */
  97271. static MODEL_BASE_URL: string;
  97272. /**
  97273. * File name for the left controller model.
  97274. */
  97275. static MODEL_LEFT_FILENAME: string;
  97276. /**
  97277. * File name for the right controller model.
  97278. */
  97279. static MODEL_RIGHT_FILENAME: string;
  97280. /**
  97281. * Fired when the secondary trigger on this controller is modified
  97282. */
  97283. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97284. /**
  97285. * Fired when the thumb rest on this controller is modified
  97286. */
  97287. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97288. /**
  97289. * Creates a new OculusTouchController from a gamepad
  97290. * @param vrGamepad the gamepad that the controller should be created from
  97291. */
  97292. constructor(vrGamepad: any);
  97293. /**
  97294. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97295. * @param scene scene in which to add meshes
  97296. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97297. */
  97298. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97299. /**
  97300. * Fired when the A button on this controller is modified
  97301. */
  97302. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97303. /**
  97304. * Fired when the B button on this controller is modified
  97305. */
  97306. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97307. /**
  97308. * Fired when the X button on this controller is modified
  97309. */
  97310. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97311. /**
  97312. * Fired when the Y button on this controller is modified
  97313. */
  97314. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97315. /**
  97316. * Called once for each button that changed state since the last frame
  97317. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97318. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97319. * 2) secondary trigger (same)
  97320. * 3) A (right) X (left), touch, pressed = value
  97321. * 4) B / Y
  97322. * 5) thumb rest
  97323. * @param buttonIdx Which button index changed
  97324. * @param state New state of the button
  97325. * @param changes Which properties on the state changed since last frame
  97326. */
  97327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97328. }
  97329. }
  97330. declare module BABYLON {
  97331. /**
  97332. * Vive Controller
  97333. */
  97334. export class ViveController extends WebVRController {
  97335. /**
  97336. * Base Url for the controller model.
  97337. */
  97338. static MODEL_BASE_URL: string;
  97339. /**
  97340. * File name for the controller model.
  97341. */
  97342. static MODEL_FILENAME: string;
  97343. /**
  97344. * Creates a new ViveController from a gamepad
  97345. * @param vrGamepad the gamepad that the controller should be created from
  97346. */
  97347. constructor(vrGamepad: any);
  97348. /**
  97349. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97350. * @param scene scene in which to add meshes
  97351. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97352. */
  97353. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97354. /**
  97355. * Fired when the left button on this controller is modified
  97356. */
  97357. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97358. /**
  97359. * Fired when the right button on this controller is modified
  97360. */
  97361. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97362. /**
  97363. * Fired when the menu button on this controller is modified
  97364. */
  97365. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97366. /**
  97367. * Called once for each button that changed state since the last frame
  97368. * Vive mapping:
  97369. * 0: touchpad
  97370. * 1: trigger
  97371. * 2: left AND right buttons
  97372. * 3: menu button
  97373. * @param buttonIdx Which button index changed
  97374. * @param state New state of the button
  97375. * @param changes Which properties on the state changed since last frame
  97376. */
  97377. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97378. }
  97379. }
  97380. declare module BABYLON {
  97381. /**
  97382. * Defines the WindowsMotionController object that the state of the windows motion controller
  97383. */
  97384. export class WindowsMotionController extends WebVRController {
  97385. /**
  97386. * The base url used to load the left and right controller models
  97387. */
  97388. static MODEL_BASE_URL: string;
  97389. /**
  97390. * The name of the left controller model file
  97391. */
  97392. static MODEL_LEFT_FILENAME: string;
  97393. /**
  97394. * The name of the right controller model file
  97395. */
  97396. static MODEL_RIGHT_FILENAME: string;
  97397. /**
  97398. * The controller name prefix for this controller type
  97399. */
  97400. static readonly GAMEPAD_ID_PREFIX: string;
  97401. /**
  97402. * The controller id pattern for this controller type
  97403. */
  97404. private static readonly GAMEPAD_ID_PATTERN;
  97405. private _loadedMeshInfo;
  97406. private readonly _mapping;
  97407. /**
  97408. * Fired when the trackpad on this controller is clicked
  97409. */
  97410. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97411. /**
  97412. * Fired when the trackpad on this controller is modified
  97413. */
  97414. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97415. /**
  97416. * The current x and y values of this controller's trackpad
  97417. */
  97418. trackpad: StickValues;
  97419. /**
  97420. * Creates a new WindowsMotionController from a gamepad
  97421. * @param vrGamepad the gamepad that the controller should be created from
  97422. */
  97423. constructor(vrGamepad: any);
  97424. /**
  97425. * Fired when the trigger on this controller is modified
  97426. */
  97427. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97428. /**
  97429. * Fired when the menu button on this controller is modified
  97430. */
  97431. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97432. /**
  97433. * Fired when the grip button on this controller is modified
  97434. */
  97435. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97436. /**
  97437. * Fired when the thumbstick button on this controller is modified
  97438. */
  97439. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97440. /**
  97441. * Fired when the touchpad button on this controller is modified
  97442. */
  97443. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97444. /**
  97445. * Fired when the touchpad values on this controller are modified
  97446. */
  97447. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97448. private _updateTrackpad;
  97449. /**
  97450. * Called once per frame by the engine.
  97451. */
  97452. update(): void;
  97453. /**
  97454. * Called once for each button that changed state since the last frame
  97455. * @param buttonIdx Which button index changed
  97456. * @param state New state of the button
  97457. * @param changes Which properties on the state changed since last frame
  97458. */
  97459. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97460. /**
  97461. * Moves the buttons on the controller mesh based on their current state
  97462. * @param buttonName the name of the button to move
  97463. * @param buttonValue the value of the button which determines the buttons new position
  97464. */
  97465. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97466. /**
  97467. * Moves the axis on the controller mesh based on its current state
  97468. * @param axis the index of the axis
  97469. * @param axisValue the value of the axis which determines the meshes new position
  97470. * @hidden
  97471. */
  97472. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97473. /**
  97474. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97475. * @param scene scene in which to add meshes
  97476. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97477. */
  97478. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97479. /**
  97480. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97481. * can be transformed by button presses and axes values, based on this._mapping.
  97482. *
  97483. * @param scene scene in which the meshes exist
  97484. * @param meshes list of meshes that make up the controller model to process
  97485. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97486. */
  97487. private processModel;
  97488. private createMeshInfo;
  97489. /**
  97490. * Gets the ray of the controller in the direction the controller is pointing
  97491. * @param length the length the resulting ray should be
  97492. * @returns a ray in the direction the controller is pointing
  97493. */
  97494. getForwardRay(length?: number): Ray;
  97495. /**
  97496. * Disposes of the controller
  97497. */
  97498. dispose(): void;
  97499. }
  97500. }
  97501. declare module BABYLON {
  97502. /**
  97503. * Single axis scale gizmo
  97504. */
  97505. export class AxisScaleGizmo extends Gizmo {
  97506. private _coloredMaterial;
  97507. /**
  97508. * Drag behavior responsible for the gizmos dragging interactions
  97509. */
  97510. dragBehavior: PointerDragBehavior;
  97511. private _pointerObserver;
  97512. /**
  97513. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97514. */
  97515. snapDistance: number;
  97516. /**
  97517. * Event that fires each time the gizmo snaps to a new location.
  97518. * * snapDistance is the the change in distance
  97519. */
  97520. onSnapObservable: Observable<{
  97521. snapDistance: number;
  97522. }>;
  97523. /**
  97524. * If the scaling operation should be done on all axis (default: false)
  97525. */
  97526. uniformScaling: boolean;
  97527. /**
  97528. * Creates an AxisScaleGizmo
  97529. * @param gizmoLayer The utility layer the gizmo will be added to
  97530. * @param dragAxis The axis which the gizmo will be able to scale on
  97531. * @param color The color of the gizmo
  97532. */
  97533. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97534. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97535. /**
  97536. * Disposes of the gizmo
  97537. */
  97538. dispose(): void;
  97539. /**
  97540. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97541. * @param mesh The mesh to replace the default mesh of the gizmo
  97542. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97543. */
  97544. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97545. }
  97546. }
  97547. declare module BABYLON {
  97548. /**
  97549. * Bounding box gizmo
  97550. */
  97551. export class BoundingBoxGizmo extends Gizmo {
  97552. private _lineBoundingBox;
  97553. private _rotateSpheresParent;
  97554. private _scaleBoxesParent;
  97555. private _boundingDimensions;
  97556. private _renderObserver;
  97557. private _pointerObserver;
  97558. private _scaleDragSpeed;
  97559. private _tmpQuaternion;
  97560. private _tmpVector;
  97561. private _tmpRotationMatrix;
  97562. /**
  97563. * 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)
  97564. */
  97565. ignoreChildren: boolean;
  97566. /**
  97567. * 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)
  97568. */
  97569. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97570. /**
  97571. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97572. */
  97573. rotationSphereSize: number;
  97574. /**
  97575. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97576. */
  97577. scaleBoxSize: number;
  97578. /**
  97579. * 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)
  97580. */
  97581. fixedDragMeshScreenSize: boolean;
  97582. /**
  97583. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97584. */
  97585. fixedDragMeshScreenSizeDistanceFactor: number;
  97586. /**
  97587. * Fired when a rotation sphere or scale box is dragged
  97588. */
  97589. onDragStartObservable: Observable<{}>;
  97590. /**
  97591. * Fired when a scale box is dragged
  97592. */
  97593. onScaleBoxDragObservable: Observable<{}>;
  97594. /**
  97595. * Fired when a scale box drag is ended
  97596. */
  97597. onScaleBoxDragEndObservable: Observable<{}>;
  97598. /**
  97599. * Fired when a rotation sphere is dragged
  97600. */
  97601. onRotationSphereDragObservable: Observable<{}>;
  97602. /**
  97603. * Fired when a rotation sphere drag is ended
  97604. */
  97605. onRotationSphereDragEndObservable: Observable<{}>;
  97606. /**
  97607. * 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)
  97608. */
  97609. scalePivot: Nullable<Vector3>;
  97610. private _anchorMesh;
  97611. private _existingMeshScale;
  97612. private _dragMesh;
  97613. private pointerDragBehavior;
  97614. /**
  97615. * Creates an BoundingBoxGizmo
  97616. * @param gizmoLayer The utility layer the gizmo will be added to
  97617. * @param color The color of the gizmo
  97618. */
  97619. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97620. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97621. private _selectNode;
  97622. /**
  97623. * Updates the bounding box information for the Gizmo
  97624. */
  97625. updateBoundingBox(): void;
  97626. private _updateRotationSpheres;
  97627. private _updateScaleBoxes;
  97628. /**
  97629. * Enables rotation on the specified axis and disables rotation on the others
  97630. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97631. */
  97632. setEnabledRotationAxis(axis: string): void;
  97633. /**
  97634. * Enables/disables scaling
  97635. * @param enable if scaling should be enabled
  97636. */
  97637. setEnabledScaling(enable: boolean): void;
  97638. private _updateDummy;
  97639. /**
  97640. * Enables a pointer drag behavior on the bounding box of the gizmo
  97641. */
  97642. enableDragBehavior(): void;
  97643. /**
  97644. * Disposes of the gizmo
  97645. */
  97646. dispose(): void;
  97647. /**
  97648. * 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)
  97649. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97650. * @returns the bounding box mesh with the passed in mesh as a child
  97651. */
  97652. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97653. /**
  97654. * CustomMeshes are not supported by this gizmo
  97655. * @param mesh The mesh to replace the default mesh of the gizmo
  97656. */
  97657. setCustomMesh(mesh: Mesh): void;
  97658. }
  97659. }
  97660. declare module BABYLON {
  97661. /**
  97662. * Single plane rotation gizmo
  97663. */
  97664. export class PlaneRotationGizmo extends Gizmo {
  97665. /**
  97666. * Drag behavior responsible for the gizmos dragging interactions
  97667. */
  97668. dragBehavior: PointerDragBehavior;
  97669. private _pointerObserver;
  97670. /**
  97671. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  97672. */
  97673. snapDistance: number;
  97674. /**
  97675. * Event that fires each time the gizmo snaps to a new location.
  97676. * * snapDistance is the the change in distance
  97677. */
  97678. onSnapObservable: Observable<{
  97679. snapDistance: number;
  97680. }>;
  97681. /**
  97682. * Creates a PlaneRotationGizmo
  97683. * @param gizmoLayer The utility layer the gizmo will be added to
  97684. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  97685. * @param color The color of the gizmo
  97686. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97687. */
  97688. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97689. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97690. /**
  97691. * Disposes of the gizmo
  97692. */
  97693. dispose(): void;
  97694. }
  97695. }
  97696. declare module BABYLON {
  97697. /**
  97698. * Gizmo that enables rotating a mesh along 3 axis
  97699. */
  97700. export class RotationGizmo extends Gizmo {
  97701. /**
  97702. * Internal gizmo used for interactions on the x axis
  97703. */
  97704. xGizmo: PlaneRotationGizmo;
  97705. /**
  97706. * Internal gizmo used for interactions on the y axis
  97707. */
  97708. yGizmo: PlaneRotationGizmo;
  97709. /**
  97710. * Internal gizmo used for interactions on the z axis
  97711. */
  97712. zGizmo: PlaneRotationGizmo;
  97713. /** Fires an event when any of it's sub gizmos are dragged */
  97714. onDragStartObservable: Observable<{}>;
  97715. /** Fires an event when any of it's sub gizmos are released from dragging */
  97716. onDragEndObservable: Observable<{}>;
  97717. attachedMesh: Nullable<AbstractMesh>;
  97718. /**
  97719. * Creates a RotationGizmo
  97720. * @param gizmoLayer The utility layer the gizmo will be added to
  97721. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97722. */
  97723. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97724. updateGizmoRotationToMatchAttachedMesh: boolean;
  97725. /**
  97726. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97727. */
  97728. snapDistance: number;
  97729. /**
  97730. * Ratio for the scale of the gizmo (Default: 1)
  97731. */
  97732. scaleRatio: number;
  97733. /**
  97734. * Disposes of the gizmo
  97735. */
  97736. dispose(): void;
  97737. /**
  97738. * CustomMeshes are not supported by this gizmo
  97739. * @param mesh The mesh to replace the default mesh of the gizmo
  97740. */
  97741. setCustomMesh(mesh: Mesh): void;
  97742. }
  97743. }
  97744. declare module BABYLON {
  97745. /**
  97746. * Gizmo that enables dragging a mesh along 3 axis
  97747. */
  97748. export class PositionGizmo extends Gizmo {
  97749. /**
  97750. * Internal gizmo used for interactions on the x axis
  97751. */
  97752. xGizmo: AxisDragGizmo;
  97753. /**
  97754. * Internal gizmo used for interactions on the y axis
  97755. */
  97756. yGizmo: AxisDragGizmo;
  97757. /**
  97758. * Internal gizmo used for interactions on the z axis
  97759. */
  97760. zGizmo: AxisDragGizmo;
  97761. /** Fires an event when any of it's sub gizmos are dragged */
  97762. onDragStartObservable: Observable<{}>;
  97763. /** Fires an event when any of it's sub gizmos are released from dragging */
  97764. onDragEndObservable: Observable<{}>;
  97765. attachedMesh: Nullable<AbstractMesh>;
  97766. /**
  97767. * Creates a PositionGizmo
  97768. * @param gizmoLayer The utility layer the gizmo will be added to
  97769. */
  97770. constructor(gizmoLayer?: UtilityLayerRenderer);
  97771. updateGizmoRotationToMatchAttachedMesh: boolean;
  97772. /**
  97773. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97774. */
  97775. snapDistance: number;
  97776. /**
  97777. * Ratio for the scale of the gizmo (Default: 1)
  97778. */
  97779. scaleRatio: number;
  97780. /**
  97781. * Disposes of the gizmo
  97782. */
  97783. dispose(): void;
  97784. /**
  97785. * CustomMeshes are not supported by this gizmo
  97786. * @param mesh The mesh to replace the default mesh of the gizmo
  97787. */
  97788. setCustomMesh(mesh: Mesh): void;
  97789. }
  97790. }
  97791. declare module BABYLON {
  97792. /**
  97793. * Class containing static functions to help procedurally build meshes
  97794. */
  97795. export class PolyhedronBuilder {
  97796. /**
  97797. * Creates a polyhedron mesh
  97798. * * 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
  97799. * * The parameter `size` (positive float, default 1) sets the polygon size
  97800. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97801. * * 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`
  97802. * * 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
  97803. * * 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)`)
  97804. * * 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
  97805. * * 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
  97806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97809. * @param name defines the name of the mesh
  97810. * @param options defines the options used to create the mesh
  97811. * @param scene defines the hosting scene
  97812. * @returns the polyhedron mesh
  97813. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  97814. */
  97815. static CreatePolyhedron(name: string, options: {
  97816. type?: number;
  97817. size?: number;
  97818. sizeX?: number;
  97819. sizeY?: number;
  97820. sizeZ?: number;
  97821. custom?: any;
  97822. faceUV?: Vector4[];
  97823. faceColors?: Color4[];
  97824. flat?: boolean;
  97825. updatable?: boolean;
  97826. sideOrientation?: number;
  97827. frontUVs?: Vector4;
  97828. backUVs?: Vector4;
  97829. }, scene: Scene): Mesh;
  97830. }
  97831. }
  97832. declare module BABYLON {
  97833. /**
  97834. * Gizmo that enables scaling a mesh along 3 axis
  97835. */
  97836. export class ScaleGizmo extends Gizmo {
  97837. /**
  97838. * Internal gizmo used for interactions on the x axis
  97839. */
  97840. xGizmo: AxisScaleGizmo;
  97841. /**
  97842. * Internal gizmo used for interactions on the y axis
  97843. */
  97844. yGizmo: AxisScaleGizmo;
  97845. /**
  97846. * Internal gizmo used for interactions on the z axis
  97847. */
  97848. zGizmo: AxisScaleGizmo;
  97849. /**
  97850. * Internal gizmo used to scale all axis equally
  97851. */
  97852. uniformScaleGizmo: AxisScaleGizmo;
  97853. /** Fires an event when any of it's sub gizmos are dragged */
  97854. onDragStartObservable: Observable<{}>;
  97855. /** Fires an event when any of it's sub gizmos are released from dragging */
  97856. onDragEndObservable: Observable<{}>;
  97857. attachedMesh: Nullable<AbstractMesh>;
  97858. /**
  97859. * Creates a ScaleGizmo
  97860. * @param gizmoLayer The utility layer the gizmo will be added to
  97861. */
  97862. constructor(gizmoLayer?: UtilityLayerRenderer);
  97863. updateGizmoRotationToMatchAttachedMesh: boolean;
  97864. /**
  97865. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97866. */
  97867. snapDistance: number;
  97868. /**
  97869. * Ratio for the scale of the gizmo (Default: 1)
  97870. */
  97871. scaleRatio: number;
  97872. /**
  97873. * Disposes of the gizmo
  97874. */
  97875. dispose(): void;
  97876. }
  97877. }
  97878. declare module BABYLON {
  97879. /**
  97880. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  97881. */
  97882. export class GizmoManager implements IDisposable {
  97883. private scene;
  97884. /**
  97885. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  97886. */
  97887. gizmos: {
  97888. positionGizmo: Nullable<PositionGizmo>;
  97889. rotationGizmo: Nullable<RotationGizmo>;
  97890. scaleGizmo: Nullable<ScaleGizmo>;
  97891. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  97892. };
  97893. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  97894. clearGizmoOnEmptyPointerEvent: boolean;
  97895. /** Fires an event when the manager is attached to a mesh */
  97896. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  97897. private _gizmosEnabled;
  97898. private _pointerObserver;
  97899. private _attachedMesh;
  97900. private _boundingBoxColor;
  97901. private _defaultUtilityLayer;
  97902. private _defaultKeepDepthUtilityLayer;
  97903. /**
  97904. * When bounding box gizmo is enabled, this can be used to track drag/end events
  97905. */
  97906. boundingBoxDragBehavior: SixDofDragBehavior;
  97907. /**
  97908. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  97909. */
  97910. attachableMeshes: Nullable<Array<AbstractMesh>>;
  97911. /**
  97912. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  97913. */
  97914. usePointerToAttachGizmos: boolean;
  97915. /**
  97916. * Instatiates a gizmo manager
  97917. * @param scene the scene to overlay the gizmos on top of
  97918. */
  97919. constructor(scene: Scene);
  97920. /**
  97921. * Attaches a set of gizmos to the specified mesh
  97922. * @param mesh The mesh the gizmo's should be attached to
  97923. */
  97924. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  97925. /**
  97926. * If the position gizmo is enabled
  97927. */
  97928. positionGizmoEnabled: boolean;
  97929. /**
  97930. * If the rotation gizmo is enabled
  97931. */
  97932. rotationGizmoEnabled: boolean;
  97933. /**
  97934. * If the scale gizmo is enabled
  97935. */
  97936. scaleGizmoEnabled: boolean;
  97937. /**
  97938. * If the boundingBox gizmo is enabled
  97939. */
  97940. boundingBoxGizmoEnabled: boolean;
  97941. /**
  97942. * Disposes of the gizmo manager
  97943. */
  97944. dispose(): void;
  97945. }
  97946. }
  97947. declare module BABYLON {
  97948. /**
  97949. * Gizmo that enables viewing a light
  97950. */
  97951. export class LightGizmo extends Gizmo {
  97952. private _box;
  97953. /**
  97954. * Creates a LightGizmo
  97955. * @param gizmoLayer The utility layer the gizmo will be added to
  97956. */
  97957. constructor(gizmoLayer?: UtilityLayerRenderer);
  97958. private _light;
  97959. /**
  97960. * The light that the gizmo is attached to
  97961. */
  97962. light: Nullable<Light>;
  97963. /**
  97964. * @hidden
  97965. * Updates the gizmo to match the attached mesh's position/rotation
  97966. */
  97967. protected _update(): void;
  97968. }
  97969. }
  97970. declare module BABYLON {
  97971. /** @hidden */
  97972. export var backgroundFragmentDeclaration: {
  97973. name: string;
  97974. shader: string;
  97975. };
  97976. }
  97977. declare module BABYLON {
  97978. /** @hidden */
  97979. export var backgroundUboDeclaration: {
  97980. name: string;
  97981. shader: string;
  97982. };
  97983. }
  97984. declare module BABYLON {
  97985. /** @hidden */
  97986. export var backgroundPixelShader: {
  97987. name: string;
  97988. shader: string;
  97989. };
  97990. }
  97991. declare module BABYLON {
  97992. /** @hidden */
  97993. export var backgroundVertexDeclaration: {
  97994. name: string;
  97995. shader: string;
  97996. };
  97997. }
  97998. declare module BABYLON {
  97999. /** @hidden */
  98000. export var backgroundVertexShader: {
  98001. name: string;
  98002. shader: string;
  98003. };
  98004. }
  98005. declare module BABYLON {
  98006. /**
  98007. * Background material used to create an efficient environement around your scene.
  98008. */
  98009. export class BackgroundMaterial extends PushMaterial {
  98010. /**
  98011. * Standard reflectance value at parallel view angle.
  98012. */
  98013. static StandardReflectance0: number;
  98014. /**
  98015. * Standard reflectance value at grazing angle.
  98016. */
  98017. static StandardReflectance90: number;
  98018. protected _primaryColor: Color3;
  98019. /**
  98020. * Key light Color (multiply against the environement texture)
  98021. */
  98022. primaryColor: Color3;
  98023. protected __perceptualColor: Nullable<Color3>;
  98024. /**
  98025. * Experimental Internal Use Only.
  98026. *
  98027. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  98028. * This acts as a helper to set the primary color to a more "human friendly" value.
  98029. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  98030. * output color as close as possible from the chosen value.
  98031. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  98032. * part of lighting setup.)
  98033. */
  98034. _perceptualColor: Nullable<Color3>;
  98035. protected _primaryColorShadowLevel: float;
  98036. /**
  98037. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  98038. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  98039. */
  98040. primaryColorShadowLevel: float;
  98041. protected _primaryColorHighlightLevel: float;
  98042. /**
  98043. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  98044. * The primary color is used at the level chosen to define what the white area would look.
  98045. */
  98046. primaryColorHighlightLevel: float;
  98047. protected _reflectionTexture: Nullable<BaseTexture>;
  98048. /**
  98049. * Reflection Texture used in the material.
  98050. * Should be author in a specific way for the best result (refer to the documentation).
  98051. */
  98052. reflectionTexture: Nullable<BaseTexture>;
  98053. protected _reflectionBlur: float;
  98054. /**
  98055. * Reflection Texture level of blur.
  98056. *
  98057. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  98058. * texture twice.
  98059. */
  98060. reflectionBlur: float;
  98061. protected _diffuseTexture: Nullable<BaseTexture>;
  98062. /**
  98063. * Diffuse Texture used in the material.
  98064. * Should be author in a specific way for the best result (refer to the documentation).
  98065. */
  98066. diffuseTexture: Nullable<BaseTexture>;
  98067. protected _shadowLights: Nullable<IShadowLight[]>;
  98068. /**
  98069. * Specify the list of lights casting shadow on the material.
  98070. * All scene shadow lights will be included if null.
  98071. */
  98072. shadowLights: Nullable<IShadowLight[]>;
  98073. protected _shadowLevel: float;
  98074. /**
  98075. * Helps adjusting the shadow to a softer level if required.
  98076. * 0 means black shadows and 1 means no shadows.
  98077. */
  98078. shadowLevel: float;
  98079. protected _sceneCenter: Vector3;
  98080. /**
  98081. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  98082. * It is usually zero but might be interesting to modify according to your setup.
  98083. */
  98084. sceneCenter: Vector3;
  98085. protected _opacityFresnel: boolean;
  98086. /**
  98087. * This helps specifying that the material is falling off to the sky box at grazing angle.
  98088. * This helps ensuring a nice transition when the camera goes under the ground.
  98089. */
  98090. opacityFresnel: boolean;
  98091. protected _reflectionFresnel: boolean;
  98092. /**
  98093. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  98094. * This helps adding a mirror texture on the ground.
  98095. */
  98096. reflectionFresnel: boolean;
  98097. protected _reflectionFalloffDistance: number;
  98098. /**
  98099. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98100. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98101. */
  98102. reflectionFalloffDistance: number;
  98103. protected _reflectionAmount: number;
  98104. /**
  98105. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98106. */
  98107. reflectionAmount: number;
  98108. protected _reflectionReflectance0: number;
  98109. /**
  98110. * This specifies the weight of the reflection at grazing angle.
  98111. */
  98112. reflectionReflectance0: number;
  98113. protected _reflectionReflectance90: number;
  98114. /**
  98115. * This specifies the weight of the reflection at a perpendicular point of view.
  98116. */
  98117. reflectionReflectance90: number;
  98118. /**
  98119. * Sets the reflection reflectance fresnel values according to the default standard
  98120. * empirically know to work well :-)
  98121. */
  98122. reflectionStandardFresnelWeight: number;
  98123. protected _useRGBColor: boolean;
  98124. /**
  98125. * Helps to directly use the maps channels instead of their level.
  98126. */
  98127. useRGBColor: boolean;
  98128. protected _enableNoise: boolean;
  98129. /**
  98130. * This helps reducing the banding effect that could occur on the background.
  98131. */
  98132. enableNoise: boolean;
  98133. /**
  98134. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98135. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98136. * Recommended to be keep at 1.0 except for special cases.
  98137. */
  98138. fovMultiplier: number;
  98139. private _fovMultiplier;
  98140. /**
  98141. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98142. */
  98143. useEquirectangularFOV: boolean;
  98144. private _maxSimultaneousLights;
  98145. /**
  98146. * Number of Simultaneous lights allowed on the material.
  98147. */
  98148. maxSimultaneousLights: int;
  98149. /**
  98150. * Default configuration related to image processing available in the Background Material.
  98151. */
  98152. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98153. /**
  98154. * Keep track of the image processing observer to allow dispose and replace.
  98155. */
  98156. private _imageProcessingObserver;
  98157. /**
  98158. * Attaches a new image processing configuration to the PBR Material.
  98159. * @param configuration (if null the scene configuration will be use)
  98160. */
  98161. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98162. /**
  98163. * Gets the image processing configuration used either in this material.
  98164. */
  98165. /**
  98166. * Sets the Default image processing configuration used either in the this material.
  98167. *
  98168. * If sets to null, the scene one is in use.
  98169. */
  98170. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98171. /**
  98172. * Gets wether the color curves effect is enabled.
  98173. */
  98174. /**
  98175. * Sets wether the color curves effect is enabled.
  98176. */
  98177. cameraColorCurvesEnabled: boolean;
  98178. /**
  98179. * Gets wether the color grading effect is enabled.
  98180. */
  98181. /**
  98182. * Gets wether the color grading effect is enabled.
  98183. */
  98184. cameraColorGradingEnabled: boolean;
  98185. /**
  98186. * Gets wether tonemapping is enabled or not.
  98187. */
  98188. /**
  98189. * Sets wether tonemapping is enabled or not
  98190. */
  98191. cameraToneMappingEnabled: boolean;
  98192. /**
  98193. * The camera exposure used on this material.
  98194. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98195. * This corresponds to a photographic exposure.
  98196. */
  98197. /**
  98198. * The camera exposure used on this material.
  98199. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98200. * This corresponds to a photographic exposure.
  98201. */
  98202. cameraExposure: float;
  98203. /**
  98204. * Gets The camera contrast used on this material.
  98205. */
  98206. /**
  98207. * Sets The camera contrast used on this material.
  98208. */
  98209. cameraContrast: float;
  98210. /**
  98211. * Gets the Color Grading 2D Lookup Texture.
  98212. */
  98213. /**
  98214. * Sets the Color Grading 2D Lookup Texture.
  98215. */
  98216. cameraColorGradingTexture: Nullable<BaseTexture>;
  98217. /**
  98218. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98219. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98220. * 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;
  98221. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98222. */
  98223. /**
  98224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98226. * 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;
  98227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98228. */
  98229. cameraColorCurves: Nullable<ColorCurves>;
  98230. /**
  98231. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98232. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98233. */
  98234. switchToBGR: boolean;
  98235. private _renderTargets;
  98236. private _reflectionControls;
  98237. private _white;
  98238. private _primaryShadowColor;
  98239. private _primaryHighlightColor;
  98240. /**
  98241. * Instantiates a Background Material in the given scene
  98242. * @param name The friendly name of the material
  98243. * @param scene The scene to add the material to
  98244. */
  98245. constructor(name: string, scene: Scene);
  98246. /**
  98247. * Gets a boolean indicating that current material needs to register RTT
  98248. */
  98249. readonly hasRenderTargetTextures: boolean;
  98250. /**
  98251. * The entire material has been created in order to prevent overdraw.
  98252. * @returns false
  98253. */
  98254. needAlphaTesting(): boolean;
  98255. /**
  98256. * The entire material has been created in order to prevent overdraw.
  98257. * @returns true if blending is enable
  98258. */
  98259. needAlphaBlending(): boolean;
  98260. /**
  98261. * Checks wether the material is ready to be rendered for a given mesh.
  98262. * @param mesh The mesh to render
  98263. * @param subMesh The submesh to check against
  98264. * @param useInstances Specify wether or not the material is used with instances
  98265. * @returns true if all the dependencies are ready (Textures, Effects...)
  98266. */
  98267. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98268. /**
  98269. * Compute the primary color according to the chosen perceptual color.
  98270. */
  98271. private _computePrimaryColorFromPerceptualColor;
  98272. /**
  98273. * Compute the highlights and shadow colors according to their chosen levels.
  98274. */
  98275. private _computePrimaryColors;
  98276. /**
  98277. * Build the uniform buffer used in the material.
  98278. */
  98279. buildUniformLayout(): void;
  98280. /**
  98281. * Unbind the material.
  98282. */
  98283. unbind(): void;
  98284. /**
  98285. * Bind only the world matrix to the material.
  98286. * @param world The world matrix to bind.
  98287. */
  98288. bindOnlyWorldMatrix(world: Matrix): void;
  98289. /**
  98290. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98291. * @param world The world matrix to bind.
  98292. * @param subMesh The submesh to bind for.
  98293. */
  98294. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98295. /**
  98296. * Dispose the material.
  98297. * @param forceDisposeEffect Force disposal of the associated effect.
  98298. * @param forceDisposeTextures Force disposal of the associated textures.
  98299. */
  98300. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98301. /**
  98302. * Clones the material.
  98303. * @param name The cloned name.
  98304. * @returns The cloned material.
  98305. */
  98306. clone(name: string): BackgroundMaterial;
  98307. /**
  98308. * Serializes the current material to its JSON representation.
  98309. * @returns The JSON representation.
  98310. */
  98311. serialize(): any;
  98312. /**
  98313. * Gets the class name of the material
  98314. * @returns "BackgroundMaterial"
  98315. */
  98316. getClassName(): string;
  98317. /**
  98318. * Parse a JSON input to create back a background material.
  98319. * @param source The JSON data to parse
  98320. * @param scene The scene to create the parsed material in
  98321. * @param rootUrl The root url of the assets the material depends upon
  98322. * @returns the instantiated BackgroundMaterial.
  98323. */
  98324. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98325. }
  98326. }
  98327. declare module BABYLON {
  98328. /**
  98329. * Represents the different options available during the creation of
  98330. * a Environment helper.
  98331. *
  98332. * This can control the default ground, skybox and image processing setup of your scene.
  98333. */
  98334. export interface IEnvironmentHelperOptions {
  98335. /**
  98336. * Specifies wether or not to create a ground.
  98337. * True by default.
  98338. */
  98339. createGround: boolean;
  98340. /**
  98341. * Specifies the ground size.
  98342. * 15 by default.
  98343. */
  98344. groundSize: number;
  98345. /**
  98346. * The texture used on the ground for the main color.
  98347. * Comes from the BabylonJS CDN by default.
  98348. *
  98349. * Remarks: Can be either a texture or a url.
  98350. */
  98351. groundTexture: string | BaseTexture;
  98352. /**
  98353. * The color mixed in the ground texture by default.
  98354. * BabylonJS clearColor by default.
  98355. */
  98356. groundColor: Color3;
  98357. /**
  98358. * Specifies the ground opacity.
  98359. * 1 by default.
  98360. */
  98361. groundOpacity: number;
  98362. /**
  98363. * Enables the ground to receive shadows.
  98364. * True by default.
  98365. */
  98366. enableGroundShadow: boolean;
  98367. /**
  98368. * Helps preventing the shadow to be fully black on the ground.
  98369. * 0.5 by default.
  98370. */
  98371. groundShadowLevel: number;
  98372. /**
  98373. * Creates a mirror texture attach to the ground.
  98374. * false by default.
  98375. */
  98376. enableGroundMirror: boolean;
  98377. /**
  98378. * Specifies the ground mirror size ratio.
  98379. * 0.3 by default as the default kernel is 64.
  98380. */
  98381. groundMirrorSizeRatio: number;
  98382. /**
  98383. * Specifies the ground mirror blur kernel size.
  98384. * 64 by default.
  98385. */
  98386. groundMirrorBlurKernel: number;
  98387. /**
  98388. * Specifies the ground mirror visibility amount.
  98389. * 1 by default
  98390. */
  98391. groundMirrorAmount: number;
  98392. /**
  98393. * Specifies the ground mirror reflectance weight.
  98394. * This uses the standard weight of the background material to setup the fresnel effect
  98395. * of the mirror.
  98396. * 1 by default.
  98397. */
  98398. groundMirrorFresnelWeight: number;
  98399. /**
  98400. * Specifies the ground mirror Falloff distance.
  98401. * This can helps reducing the size of the reflection.
  98402. * 0 by Default.
  98403. */
  98404. groundMirrorFallOffDistance: number;
  98405. /**
  98406. * Specifies the ground mirror texture type.
  98407. * Unsigned Int by Default.
  98408. */
  98409. groundMirrorTextureType: number;
  98410. /**
  98411. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98412. * the shown objects.
  98413. */
  98414. groundYBias: number;
  98415. /**
  98416. * Specifies wether or not to create a skybox.
  98417. * True by default.
  98418. */
  98419. createSkybox: boolean;
  98420. /**
  98421. * Specifies the skybox size.
  98422. * 20 by default.
  98423. */
  98424. skyboxSize: number;
  98425. /**
  98426. * The texture used on the skybox for the main color.
  98427. * Comes from the BabylonJS CDN by default.
  98428. *
  98429. * Remarks: Can be either a texture or a url.
  98430. */
  98431. skyboxTexture: string | BaseTexture;
  98432. /**
  98433. * The color mixed in the skybox texture by default.
  98434. * BabylonJS clearColor by default.
  98435. */
  98436. skyboxColor: Color3;
  98437. /**
  98438. * The background rotation around the Y axis of the scene.
  98439. * This helps aligning the key lights of your scene with the background.
  98440. * 0 by default.
  98441. */
  98442. backgroundYRotation: number;
  98443. /**
  98444. * Compute automatically the size of the elements to best fit with the scene.
  98445. */
  98446. sizeAuto: boolean;
  98447. /**
  98448. * Default position of the rootMesh if autoSize is not true.
  98449. */
  98450. rootPosition: Vector3;
  98451. /**
  98452. * Sets up the image processing in the scene.
  98453. * true by default.
  98454. */
  98455. setupImageProcessing: boolean;
  98456. /**
  98457. * The texture used as your environment texture in the scene.
  98458. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98459. *
  98460. * Remarks: Can be either a texture or a url.
  98461. */
  98462. environmentTexture: string | BaseTexture;
  98463. /**
  98464. * The value of the exposure to apply to the scene.
  98465. * 0.6 by default if setupImageProcessing is true.
  98466. */
  98467. cameraExposure: number;
  98468. /**
  98469. * The value of the contrast to apply to the scene.
  98470. * 1.6 by default if setupImageProcessing is true.
  98471. */
  98472. cameraContrast: number;
  98473. /**
  98474. * Specifies wether or not tonemapping should be enabled in the scene.
  98475. * true by default if setupImageProcessing is true.
  98476. */
  98477. toneMappingEnabled: boolean;
  98478. }
  98479. /**
  98480. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98481. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98482. * It also helps with the default setup of your imageProcessing configuration.
  98483. */
  98484. export class EnvironmentHelper {
  98485. /**
  98486. * Default ground texture URL.
  98487. */
  98488. private static _groundTextureCDNUrl;
  98489. /**
  98490. * Default skybox texture URL.
  98491. */
  98492. private static _skyboxTextureCDNUrl;
  98493. /**
  98494. * Default environment texture URL.
  98495. */
  98496. private static _environmentTextureCDNUrl;
  98497. /**
  98498. * Creates the default options for the helper.
  98499. */
  98500. private static _getDefaultOptions;
  98501. private _rootMesh;
  98502. /**
  98503. * Gets the root mesh created by the helper.
  98504. */
  98505. readonly rootMesh: Mesh;
  98506. private _skybox;
  98507. /**
  98508. * Gets the skybox created by the helper.
  98509. */
  98510. readonly skybox: Nullable<Mesh>;
  98511. private _skyboxTexture;
  98512. /**
  98513. * Gets the skybox texture created by the helper.
  98514. */
  98515. readonly skyboxTexture: Nullable<BaseTexture>;
  98516. private _skyboxMaterial;
  98517. /**
  98518. * Gets the skybox material created by the helper.
  98519. */
  98520. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98521. private _ground;
  98522. /**
  98523. * Gets the ground mesh created by the helper.
  98524. */
  98525. readonly ground: Nullable<Mesh>;
  98526. private _groundTexture;
  98527. /**
  98528. * Gets the ground texture created by the helper.
  98529. */
  98530. readonly groundTexture: Nullable<BaseTexture>;
  98531. private _groundMirror;
  98532. /**
  98533. * Gets the ground mirror created by the helper.
  98534. */
  98535. readonly groundMirror: Nullable<MirrorTexture>;
  98536. /**
  98537. * Gets the ground mirror render list to helps pushing the meshes
  98538. * you wish in the ground reflection.
  98539. */
  98540. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98541. private _groundMaterial;
  98542. /**
  98543. * Gets the ground material created by the helper.
  98544. */
  98545. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98546. /**
  98547. * Stores the creation options.
  98548. */
  98549. private readonly _scene;
  98550. private _options;
  98551. /**
  98552. * This observable will be notified with any error during the creation of the environment,
  98553. * mainly texture creation errors.
  98554. */
  98555. onErrorObservable: Observable<{
  98556. message?: string;
  98557. exception?: any;
  98558. }>;
  98559. /**
  98560. * constructor
  98561. * @param options Defines the options we want to customize the helper
  98562. * @param scene The scene to add the material to
  98563. */
  98564. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98565. /**
  98566. * Updates the background according to the new options
  98567. * @param options
  98568. */
  98569. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98570. /**
  98571. * Sets the primary color of all the available elements.
  98572. * @param color the main color to affect to the ground and the background
  98573. */
  98574. setMainColor(color: Color3): void;
  98575. /**
  98576. * Setup the image processing according to the specified options.
  98577. */
  98578. private _setupImageProcessing;
  98579. /**
  98580. * Setup the environment texture according to the specified options.
  98581. */
  98582. private _setupEnvironmentTexture;
  98583. /**
  98584. * Setup the background according to the specified options.
  98585. */
  98586. private _setupBackground;
  98587. /**
  98588. * Get the scene sizes according to the setup.
  98589. */
  98590. private _getSceneSize;
  98591. /**
  98592. * Setup the ground according to the specified options.
  98593. */
  98594. private _setupGround;
  98595. /**
  98596. * Setup the ground material according to the specified options.
  98597. */
  98598. private _setupGroundMaterial;
  98599. /**
  98600. * Setup the ground diffuse texture according to the specified options.
  98601. */
  98602. private _setupGroundDiffuseTexture;
  98603. /**
  98604. * Setup the ground mirror texture according to the specified options.
  98605. */
  98606. private _setupGroundMirrorTexture;
  98607. /**
  98608. * Setup the ground to receive the mirror texture.
  98609. */
  98610. private _setupMirrorInGroundMaterial;
  98611. /**
  98612. * Setup the skybox according to the specified options.
  98613. */
  98614. private _setupSkybox;
  98615. /**
  98616. * Setup the skybox material according to the specified options.
  98617. */
  98618. private _setupSkyboxMaterial;
  98619. /**
  98620. * Setup the skybox reflection texture according to the specified options.
  98621. */
  98622. private _setupSkyboxReflectionTexture;
  98623. private _errorHandler;
  98624. /**
  98625. * Dispose all the elements created by the Helper.
  98626. */
  98627. dispose(): void;
  98628. }
  98629. }
  98630. declare module BABYLON {
  98631. /**
  98632. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98633. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98634. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98635. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98636. */
  98637. export class PhotoDome extends TransformNode {
  98638. private _useDirectMapping;
  98639. /**
  98640. * The texture being displayed on the sphere
  98641. */
  98642. protected _photoTexture: Texture;
  98643. /**
  98644. * Gets or sets the texture being displayed on the sphere
  98645. */
  98646. photoTexture: Texture;
  98647. /**
  98648. * Observable raised when an error occured while loading the 360 image
  98649. */
  98650. onLoadErrorObservable: Observable<string>;
  98651. /**
  98652. * The skybox material
  98653. */
  98654. protected _material: BackgroundMaterial;
  98655. /**
  98656. * The surface used for the skybox
  98657. */
  98658. protected _mesh: Mesh;
  98659. /**
  98660. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98661. * Also see the options.resolution property.
  98662. */
  98663. fovMultiplier: number;
  98664. /**
  98665. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  98666. * @param name Element's name, child elements will append suffixes for their own names.
  98667. * @param urlsOfPhoto defines the url of the photo to display
  98668. * @param options defines an object containing optional or exposed sub element properties
  98669. * @param onError defines a callback called when an error occured while loading the texture
  98670. */
  98671. constructor(name: string, urlOfPhoto: string, options: {
  98672. resolution?: number;
  98673. size?: number;
  98674. useDirectMapping?: boolean;
  98675. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  98676. /**
  98677. * Releases resources associated with this node.
  98678. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98679. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98680. */
  98681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98682. }
  98683. }
  98684. declare module BABYLON {
  98685. /**
  98686. * Class used to host texture specific utilities
  98687. */
  98688. export class TextureTools {
  98689. /**
  98690. * Uses the GPU to create a copy texture rescaled at a given size
  98691. * @param texture Texture to copy from
  98692. * @param width defines the desired width
  98693. * @param height defines the desired height
  98694. * @param useBilinearMode defines if bilinear mode has to be used
  98695. * @return the generated texture
  98696. */
  98697. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  98698. /**
  98699. * Gets an environment BRDF texture for a given scene
  98700. * @param scene defines the hosting scene
  98701. * @returns the environment BRDF texture
  98702. */
  98703. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  98704. private static _environmentBRDFBase64Texture;
  98705. }
  98706. }
  98707. declare module BABYLON {
  98708. /** @hidden */
  98709. export var pbrFragmentDeclaration: {
  98710. name: string;
  98711. shader: string;
  98712. };
  98713. }
  98714. declare module BABYLON {
  98715. /** @hidden */
  98716. export var pbrUboDeclaration: {
  98717. name: string;
  98718. shader: string;
  98719. };
  98720. }
  98721. declare module BABYLON {
  98722. /** @hidden */
  98723. export var pbrFunctions: {
  98724. name: string;
  98725. shader: string;
  98726. };
  98727. }
  98728. declare module BABYLON {
  98729. /** @hidden */
  98730. export var harmonicsFunctions: {
  98731. name: string;
  98732. shader: string;
  98733. };
  98734. }
  98735. declare module BABYLON {
  98736. /** @hidden */
  98737. export var pbrLightFunctions: {
  98738. name: string;
  98739. shader: string;
  98740. };
  98741. }
  98742. declare module BABYLON {
  98743. /** @hidden */
  98744. export var pbrPixelShader: {
  98745. name: string;
  98746. shader: string;
  98747. };
  98748. }
  98749. declare module BABYLON {
  98750. /** @hidden */
  98751. export var pbrVertexDeclaration: {
  98752. name: string;
  98753. shader: string;
  98754. };
  98755. }
  98756. declare module BABYLON {
  98757. /** @hidden */
  98758. export var pbrVertexShader: {
  98759. name: string;
  98760. shader: string;
  98761. };
  98762. }
  98763. declare module BABYLON {
  98764. /**
  98765. * The Physically based material base class of BJS.
  98766. *
  98767. * This offers the main features of a standard PBR material.
  98768. * For more information, please refer to the documentation :
  98769. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  98770. */
  98771. export abstract class PBRBaseMaterial extends PushMaterial {
  98772. /**
  98773. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  98774. */
  98775. static readonly PBRMATERIAL_OPAQUE: number;
  98776. /**
  98777. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  98778. */
  98779. static readonly PBRMATERIAL_ALPHATEST: number;
  98780. /**
  98781. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98782. */
  98783. static readonly PBRMATERIAL_ALPHABLEND: number;
  98784. /**
  98785. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98786. * They are also discarded below the alpha cutoff threshold to improve performances.
  98787. */
  98788. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  98789. /**
  98790. * Defines the default value of how much AO map is occluding the analytical lights
  98791. * (point spot...).
  98792. */
  98793. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  98794. /**
  98795. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  98796. */
  98797. static readonly LIGHTFALLOFF_PHYSICAL: number;
  98798. /**
  98799. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  98800. * to enhance interoperability with other engines.
  98801. */
  98802. static readonly LIGHTFALLOFF_GLTF: number;
  98803. /**
  98804. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  98805. * to enhance interoperability with other materials.
  98806. */
  98807. static readonly LIGHTFALLOFF_STANDARD: number;
  98808. /**
  98809. * Intensity of the direct lights e.g. the four lights available in your scene.
  98810. * This impacts both the direct diffuse and specular highlights.
  98811. */
  98812. protected _directIntensity: number;
  98813. /**
  98814. * Intensity of the emissive part of the material.
  98815. * This helps controlling the emissive effect without modifying the emissive color.
  98816. */
  98817. protected _emissiveIntensity: number;
  98818. /**
  98819. * Intensity of the environment e.g. how much the environment will light the object
  98820. * either through harmonics for rough material or through the refelction for shiny ones.
  98821. */
  98822. protected _environmentIntensity: number;
  98823. /**
  98824. * This is a special control allowing the reduction of the specular highlights coming from the
  98825. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  98826. */
  98827. protected _specularIntensity: number;
  98828. /**
  98829. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  98830. */
  98831. private _lightingInfos;
  98832. /**
  98833. * Debug Control allowing disabling the bump map on this material.
  98834. */
  98835. protected _disableBumpMap: boolean;
  98836. /**
  98837. * AKA Diffuse Texture in standard nomenclature.
  98838. */
  98839. protected _albedoTexture: BaseTexture;
  98840. /**
  98841. * AKA Occlusion Texture in other nomenclature.
  98842. */
  98843. protected _ambientTexture: BaseTexture;
  98844. /**
  98845. * AKA Occlusion Texture Intensity in other nomenclature.
  98846. */
  98847. protected _ambientTextureStrength: number;
  98848. /**
  98849. * Defines how much the AO map is occluding the analytical lights (point spot...).
  98850. * 1 means it completely occludes it
  98851. * 0 mean it has no impact
  98852. */
  98853. protected _ambientTextureImpactOnAnalyticalLights: number;
  98854. /**
  98855. * Stores the alpha values in a texture.
  98856. */
  98857. protected _opacityTexture: BaseTexture;
  98858. /**
  98859. * Stores the reflection values in a texture.
  98860. */
  98861. protected _reflectionTexture: BaseTexture;
  98862. /**
  98863. * Stores the refraction values in a texture.
  98864. */
  98865. protected _refractionTexture: BaseTexture;
  98866. /**
  98867. * Stores the emissive values in a texture.
  98868. */
  98869. protected _emissiveTexture: BaseTexture;
  98870. /**
  98871. * AKA Specular texture in other nomenclature.
  98872. */
  98873. protected _reflectivityTexture: BaseTexture;
  98874. /**
  98875. * Used to switch from specular/glossiness to metallic/roughness workflow.
  98876. */
  98877. protected _metallicTexture: BaseTexture;
  98878. /**
  98879. * Specifies the metallic scalar of the metallic/roughness workflow.
  98880. * Can also be used to scale the metalness values of the metallic texture.
  98881. */
  98882. protected _metallic: Nullable<number>;
  98883. /**
  98884. * Specifies the roughness scalar of the metallic/roughness workflow.
  98885. * Can also be used to scale the roughness values of the metallic texture.
  98886. */
  98887. protected _roughness: Nullable<number>;
  98888. /**
  98889. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  98890. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  98891. */
  98892. protected _microSurfaceTexture: BaseTexture;
  98893. /**
  98894. * Stores surface normal data used to displace a mesh in a texture.
  98895. */
  98896. protected _bumpTexture: BaseTexture;
  98897. /**
  98898. * Stores the pre-calculated light information of a mesh in a texture.
  98899. */
  98900. protected _lightmapTexture: BaseTexture;
  98901. /**
  98902. * The color of a material in ambient lighting.
  98903. */
  98904. protected _ambientColor: Color3;
  98905. /**
  98906. * AKA Diffuse Color in other nomenclature.
  98907. */
  98908. protected _albedoColor: Color3;
  98909. /**
  98910. * AKA Specular Color in other nomenclature.
  98911. */
  98912. protected _reflectivityColor: Color3;
  98913. /**
  98914. * The color applied when light is reflected from a material.
  98915. */
  98916. protected _reflectionColor: Color3;
  98917. /**
  98918. * The color applied when light is emitted from a material.
  98919. */
  98920. protected _emissiveColor: Color3;
  98921. /**
  98922. * AKA Glossiness in other nomenclature.
  98923. */
  98924. protected _microSurface: number;
  98925. /**
  98926. * source material index of refraction (IOR)' / 'destination material IOR.
  98927. */
  98928. protected _indexOfRefraction: number;
  98929. /**
  98930. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98931. */
  98932. protected _invertRefractionY: boolean;
  98933. /**
  98934. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98935. * Materials half opaque for instance using refraction could benefit from this control.
  98936. */
  98937. protected _linkRefractionWithTransparency: boolean;
  98938. /**
  98939. * Specifies that the material will use the light map as a show map.
  98940. */
  98941. protected _useLightmapAsShadowmap: boolean;
  98942. /**
  98943. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  98944. * makes the reflect vector face the model (under horizon).
  98945. */
  98946. protected _useHorizonOcclusion: boolean;
  98947. /**
  98948. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  98949. * too much the area relying on ambient texture to define their ambient occlusion.
  98950. */
  98951. protected _useRadianceOcclusion: boolean;
  98952. /**
  98953. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  98954. */
  98955. protected _useAlphaFromAlbedoTexture: boolean;
  98956. /**
  98957. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  98958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98959. */
  98960. protected _useSpecularOverAlpha: boolean;
  98961. /**
  98962. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  98963. */
  98964. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  98965. /**
  98966. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  98967. */
  98968. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  98969. /**
  98970. * Specifies if the metallic texture contains the roughness information in its green channel.
  98971. */
  98972. protected _useRoughnessFromMetallicTextureGreen: boolean;
  98973. /**
  98974. * Specifies if the metallic texture contains the metallness information in its blue channel.
  98975. */
  98976. protected _useMetallnessFromMetallicTextureBlue: boolean;
  98977. /**
  98978. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  98979. */
  98980. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  98981. /**
  98982. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  98983. */
  98984. protected _useAmbientInGrayScale: boolean;
  98985. /**
  98986. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  98987. * The material will try to infer what glossiness each pixel should be.
  98988. */
  98989. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  98990. /**
  98991. * Defines the falloff type used in this material.
  98992. * It by default is Physical.
  98993. */
  98994. protected _lightFalloff: number;
  98995. /**
  98996. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98997. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98998. */
  98999. protected _useRadianceOverAlpha: boolean;
  99000. /**
  99001. * Allows using an object space normal map (instead of tangent space).
  99002. */
  99003. protected _useObjectSpaceNormalMap: boolean;
  99004. /**
  99005. * Allows using the bump map in parallax mode.
  99006. */
  99007. protected _useParallax: boolean;
  99008. /**
  99009. * Allows using the bump map in parallax occlusion mode.
  99010. */
  99011. protected _useParallaxOcclusion: boolean;
  99012. /**
  99013. * Controls the scale bias of the parallax mode.
  99014. */
  99015. protected _parallaxScaleBias: number;
  99016. /**
  99017. * If sets to true, disables all the lights affecting the material.
  99018. */
  99019. protected _disableLighting: boolean;
  99020. /**
  99021. * Number of Simultaneous lights allowed on the material.
  99022. */
  99023. protected _maxSimultaneousLights: number;
  99024. /**
  99025. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99026. */
  99027. protected _invertNormalMapX: boolean;
  99028. /**
  99029. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99030. */
  99031. protected _invertNormalMapY: boolean;
  99032. /**
  99033. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99034. */
  99035. protected _twoSidedLighting: boolean;
  99036. /**
  99037. * Defines the alpha limits in alpha test mode.
  99038. */
  99039. protected _alphaCutOff: number;
  99040. /**
  99041. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99042. */
  99043. protected _forceAlphaTest: boolean;
  99044. /**
  99045. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99046. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99047. */
  99048. protected _useAlphaFresnel: boolean;
  99049. /**
  99050. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99051. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99052. */
  99053. protected _useLinearAlphaFresnel: boolean;
  99054. /**
  99055. * The transparency mode of the material.
  99056. */
  99057. protected _transparencyMode: Nullable<number>;
  99058. /**
  99059. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  99060. * from cos thetav and roughness:
  99061. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  99062. */
  99063. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  99064. /**
  99065. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99066. */
  99067. protected _forceIrradianceInFragment: boolean;
  99068. /**
  99069. * Force normal to face away from face.
  99070. */
  99071. protected _forceNormalForward: boolean;
  99072. /**
  99073. * Enables specular anti aliasing in the PBR shader.
  99074. * It will both interacts on the Geometry for analytical and IBL lighting.
  99075. * It also prefilter the roughness map based on the bump values.
  99076. */
  99077. protected _enableSpecularAntiAliasing: boolean;
  99078. /**
  99079. * Default configuration related to image processing available in the PBR Material.
  99080. */
  99081. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99082. /**
  99083. * Keep track of the image processing observer to allow dispose and replace.
  99084. */
  99085. private _imageProcessingObserver;
  99086. /**
  99087. * Attaches a new image processing configuration to the PBR Material.
  99088. * @param configuration
  99089. */
  99090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99091. /**
  99092. * Stores the available render targets.
  99093. */
  99094. private _renderTargets;
  99095. /**
  99096. * Sets the global ambient color for the material used in lighting calculations.
  99097. */
  99098. private _globalAmbientColor;
  99099. /**
  99100. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99101. */
  99102. private _useLogarithmicDepth;
  99103. /**
  99104. * If set to true, no lighting calculations will be applied.
  99105. */
  99106. private _unlit;
  99107. /**
  99108. * Instantiates a new PBRMaterial instance.
  99109. *
  99110. * @param name The material name
  99111. * @param scene The scene the material will be use in.
  99112. */
  99113. constructor(name: string, scene: Scene);
  99114. /**
  99115. * Gets a boolean indicating that current material needs to register RTT
  99116. */
  99117. readonly hasRenderTargetTextures: boolean;
  99118. /**
  99119. * Gets the name of the material class.
  99120. */
  99121. getClassName(): string;
  99122. /**
  99123. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99124. */
  99125. /**
  99126. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99127. */
  99128. useLogarithmicDepth: boolean;
  99129. /**
  99130. * Gets the current transparency mode.
  99131. */
  99132. /**
  99133. * Sets the transparency mode of the material.
  99134. *
  99135. * | Value | Type | Description |
  99136. * | ----- | ----------------------------------- | ----------- |
  99137. * | 0 | OPAQUE | |
  99138. * | 1 | ALPHATEST | |
  99139. * | 2 | ALPHABLEND | |
  99140. * | 3 | ALPHATESTANDBLEND | |
  99141. *
  99142. */
  99143. transparencyMode: Nullable<number>;
  99144. /**
  99145. * Returns true if alpha blending should be disabled.
  99146. */
  99147. private readonly _disableAlphaBlending;
  99148. /**
  99149. * Specifies whether or not this material should be rendered in alpha blend mode.
  99150. */
  99151. needAlphaBlending(): boolean;
  99152. /**
  99153. * Specifies if the mesh will require alpha blending.
  99154. * @param mesh - BJS mesh.
  99155. */
  99156. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99157. /**
  99158. * Specifies whether or not this material should be rendered in alpha test mode.
  99159. */
  99160. needAlphaTesting(): boolean;
  99161. /**
  99162. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99163. */
  99164. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99165. /**
  99166. * Gets the texture used for the alpha test.
  99167. */
  99168. getAlphaTestTexture(): BaseTexture;
  99169. /**
  99170. * Specifies that the submesh is ready to be used.
  99171. * @param mesh - BJS mesh.
  99172. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99173. * @param useInstances - Specifies that instances should be used.
  99174. * @returns - boolean indicating that the submesh is ready or not.
  99175. */
  99176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99177. /**
  99178. * Specifies if the material uses metallic roughness workflow.
  99179. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99180. */
  99181. isMetallicWorkflow(): boolean;
  99182. private _prepareEffect;
  99183. private _prepareDefines;
  99184. /**
  99185. * Force shader compilation
  99186. */
  99187. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99188. clipPlane: boolean;
  99189. }>): void;
  99190. /**
  99191. * Initializes the uniform buffer layout for the shader.
  99192. */
  99193. buildUniformLayout(): void;
  99194. /**
  99195. * Unbinds the textures.
  99196. */
  99197. unbind(): void;
  99198. /**
  99199. * Binds the submesh data.
  99200. * @param world - The world matrix.
  99201. * @param mesh - The BJS mesh.
  99202. * @param subMesh - A submesh of the BJS mesh.
  99203. */
  99204. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99205. /**
  99206. * Returns the animatable textures.
  99207. * @returns - Array of animatable textures.
  99208. */
  99209. getAnimatables(): IAnimatable[];
  99210. /**
  99211. * Returns the texture used for reflections.
  99212. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99213. */
  99214. private _getReflectionTexture;
  99215. /**
  99216. * Returns the texture used for refraction or null if none is used.
  99217. * @returns - Refection texture if present. If no refraction texture and refraction
  99218. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99219. */
  99220. private _getRefractionTexture;
  99221. /**
  99222. * Disposes the resources of the material.
  99223. * @param forceDisposeEffect - Forces the disposal of effects.
  99224. * @param forceDisposeTextures - Forces the disposal of all textures.
  99225. */
  99226. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99227. }
  99228. }
  99229. declare module BABYLON {
  99230. /**
  99231. * The Physically based material of BJS.
  99232. *
  99233. * This offers the main features of a standard PBR material.
  99234. * For more information, please refer to the documentation :
  99235. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99236. */
  99237. export class PBRMaterial extends PBRBaseMaterial {
  99238. /**
  99239. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99240. */
  99241. static readonly PBRMATERIAL_OPAQUE: number;
  99242. /**
  99243. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99244. */
  99245. static readonly PBRMATERIAL_ALPHATEST: number;
  99246. /**
  99247. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99248. */
  99249. static readonly PBRMATERIAL_ALPHABLEND: number;
  99250. /**
  99251. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99252. * They are also discarded below the alpha cutoff threshold to improve performances.
  99253. */
  99254. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99255. /**
  99256. * Defines the default value of how much AO map is occluding the analytical lights
  99257. * (point spot...).
  99258. */
  99259. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99260. /**
  99261. * Intensity of the direct lights e.g. the four lights available in your scene.
  99262. * This impacts both the direct diffuse and specular highlights.
  99263. */
  99264. directIntensity: number;
  99265. /**
  99266. * Intensity of the emissive part of the material.
  99267. * This helps controlling the emissive effect without modifying the emissive color.
  99268. */
  99269. emissiveIntensity: number;
  99270. /**
  99271. * Intensity of the environment e.g. how much the environment will light the object
  99272. * either through harmonics for rough material or through the refelction for shiny ones.
  99273. */
  99274. environmentIntensity: number;
  99275. /**
  99276. * This is a special control allowing the reduction of the specular highlights coming from the
  99277. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99278. */
  99279. specularIntensity: number;
  99280. /**
  99281. * Debug Control allowing disabling the bump map on this material.
  99282. */
  99283. disableBumpMap: boolean;
  99284. /**
  99285. * AKA Diffuse Texture in standard nomenclature.
  99286. */
  99287. albedoTexture: BaseTexture;
  99288. /**
  99289. * AKA Occlusion Texture in other nomenclature.
  99290. */
  99291. ambientTexture: BaseTexture;
  99292. /**
  99293. * AKA Occlusion Texture Intensity in other nomenclature.
  99294. */
  99295. ambientTextureStrength: number;
  99296. /**
  99297. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99298. * 1 means it completely occludes it
  99299. * 0 mean it has no impact
  99300. */
  99301. ambientTextureImpactOnAnalyticalLights: number;
  99302. /**
  99303. * Stores the alpha values in a texture.
  99304. */
  99305. opacityTexture: BaseTexture;
  99306. /**
  99307. * Stores the reflection values in a texture.
  99308. */
  99309. reflectionTexture: Nullable<BaseTexture>;
  99310. /**
  99311. * Stores the emissive values in a texture.
  99312. */
  99313. emissiveTexture: BaseTexture;
  99314. /**
  99315. * AKA Specular texture in other nomenclature.
  99316. */
  99317. reflectivityTexture: BaseTexture;
  99318. /**
  99319. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99320. */
  99321. metallicTexture: BaseTexture;
  99322. /**
  99323. * Specifies the metallic scalar of the metallic/roughness workflow.
  99324. * Can also be used to scale the metalness values of the metallic texture.
  99325. */
  99326. metallic: Nullable<number>;
  99327. /**
  99328. * Specifies the roughness scalar of the metallic/roughness workflow.
  99329. * Can also be used to scale the roughness values of the metallic texture.
  99330. */
  99331. roughness: Nullable<number>;
  99332. /**
  99333. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99334. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99335. */
  99336. microSurfaceTexture: BaseTexture;
  99337. /**
  99338. * Stores surface normal data used to displace a mesh in a texture.
  99339. */
  99340. bumpTexture: BaseTexture;
  99341. /**
  99342. * Stores the pre-calculated light information of a mesh in a texture.
  99343. */
  99344. lightmapTexture: BaseTexture;
  99345. /**
  99346. * Stores the refracted light information in a texture.
  99347. */
  99348. refractionTexture: BaseTexture;
  99349. /**
  99350. * The color of a material in ambient lighting.
  99351. */
  99352. ambientColor: Color3;
  99353. /**
  99354. * AKA Diffuse Color in other nomenclature.
  99355. */
  99356. albedoColor: Color3;
  99357. /**
  99358. * AKA Specular Color in other nomenclature.
  99359. */
  99360. reflectivityColor: Color3;
  99361. /**
  99362. * The color reflected from the material.
  99363. */
  99364. reflectionColor: Color3;
  99365. /**
  99366. * The color emitted from the material.
  99367. */
  99368. emissiveColor: Color3;
  99369. /**
  99370. * AKA Glossiness in other nomenclature.
  99371. */
  99372. microSurface: number;
  99373. /**
  99374. * source material index of refraction (IOR)' / 'destination material IOR.
  99375. */
  99376. indexOfRefraction: number;
  99377. /**
  99378. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99379. */
  99380. invertRefractionY: boolean;
  99381. /**
  99382. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99383. * Materials half opaque for instance using refraction could benefit from this control.
  99384. */
  99385. linkRefractionWithTransparency: boolean;
  99386. /**
  99387. * If true, the light map contains occlusion information instead of lighting info.
  99388. */
  99389. useLightmapAsShadowmap: boolean;
  99390. /**
  99391. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99392. */
  99393. useAlphaFromAlbedoTexture: boolean;
  99394. /**
  99395. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99396. */
  99397. forceAlphaTest: boolean;
  99398. /**
  99399. * Defines the alpha limits in alpha test mode.
  99400. */
  99401. alphaCutOff: number;
  99402. /**
  99403. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99404. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99405. */
  99406. useSpecularOverAlpha: boolean;
  99407. /**
  99408. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99409. */
  99410. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99411. /**
  99412. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99413. */
  99414. useRoughnessFromMetallicTextureAlpha: boolean;
  99415. /**
  99416. * Specifies if the metallic texture contains the roughness information in its green channel.
  99417. */
  99418. useRoughnessFromMetallicTextureGreen: boolean;
  99419. /**
  99420. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99421. */
  99422. useMetallnessFromMetallicTextureBlue: boolean;
  99423. /**
  99424. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99425. */
  99426. useAmbientOcclusionFromMetallicTextureRed: boolean;
  99427. /**
  99428. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99429. */
  99430. useAmbientInGrayScale: boolean;
  99431. /**
  99432. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99433. * The material will try to infer what glossiness each pixel should be.
  99434. */
  99435. useAutoMicroSurfaceFromReflectivityMap: boolean;
  99436. /**
  99437. * BJS is using an harcoded light falloff based on a manually sets up range.
  99438. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99439. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99440. */
  99441. /**
  99442. * BJS is using an harcoded light falloff based on a manually sets up range.
  99443. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99444. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99445. */
  99446. usePhysicalLightFalloff: boolean;
  99447. /**
  99448. * In order to support the falloff compatibility with gltf, a special mode has been added
  99449. * to reproduce the gltf light falloff.
  99450. */
  99451. /**
  99452. * In order to support the falloff compatibility with gltf, a special mode has been added
  99453. * to reproduce the gltf light falloff.
  99454. */
  99455. useGLTFLightFalloff: boolean;
  99456. /**
  99457. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99458. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99459. */
  99460. useRadianceOverAlpha: boolean;
  99461. /**
  99462. * Allows using an object space normal map (instead of tangent space).
  99463. */
  99464. useObjectSpaceNormalMap: boolean;
  99465. /**
  99466. * Allows using the bump map in parallax mode.
  99467. */
  99468. useParallax: boolean;
  99469. /**
  99470. * Allows using the bump map in parallax occlusion mode.
  99471. */
  99472. useParallaxOcclusion: boolean;
  99473. /**
  99474. * Controls the scale bias of the parallax mode.
  99475. */
  99476. parallaxScaleBias: number;
  99477. /**
  99478. * If sets to true, disables all the lights affecting the material.
  99479. */
  99480. disableLighting: boolean;
  99481. /**
  99482. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99483. */
  99484. forceIrradianceInFragment: boolean;
  99485. /**
  99486. * Number of Simultaneous lights allowed on the material.
  99487. */
  99488. maxSimultaneousLights: number;
  99489. /**
  99490. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99491. */
  99492. invertNormalMapX: boolean;
  99493. /**
  99494. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99495. */
  99496. invertNormalMapY: boolean;
  99497. /**
  99498. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99499. */
  99500. twoSidedLighting: boolean;
  99501. /**
  99502. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99503. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99504. */
  99505. useAlphaFresnel: boolean;
  99506. /**
  99507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99508. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99509. */
  99510. useLinearAlphaFresnel: boolean;
  99511. /**
  99512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99513. * And/Or occlude the blended part.
  99514. */
  99515. environmentBRDFTexture: Nullable<BaseTexture>;
  99516. /**
  99517. * Force normal to face away from face.
  99518. */
  99519. forceNormalForward: boolean;
  99520. /**
  99521. * Enables specular anti aliasing in the PBR shader.
  99522. * It will both interacts on the Geometry for analytical and IBL lighting.
  99523. * It also prefilter the roughness map based on the bump values.
  99524. */
  99525. enableSpecularAntiAliasing: boolean;
  99526. /**
  99527. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99528. * makes the reflect vector face the model (under horizon).
  99529. */
  99530. useHorizonOcclusion: boolean;
  99531. /**
  99532. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99533. * too much the area relying on ambient texture to define their ambient occlusion.
  99534. */
  99535. useRadianceOcclusion: boolean;
  99536. /**
  99537. * If set to true, no lighting calculations will be applied.
  99538. */
  99539. unlit: boolean;
  99540. /**
  99541. * Gets the image processing configuration used either in this material.
  99542. */
  99543. /**
  99544. * Sets the Default image processing configuration used either in the this material.
  99545. *
  99546. * If sets to null, the scene one is in use.
  99547. */
  99548. imageProcessingConfiguration: ImageProcessingConfiguration;
  99549. /**
  99550. * Gets wether the color curves effect is enabled.
  99551. */
  99552. /**
  99553. * Sets wether the color curves effect is enabled.
  99554. */
  99555. cameraColorCurvesEnabled: boolean;
  99556. /**
  99557. * Gets wether the color grading effect is enabled.
  99558. */
  99559. /**
  99560. * Gets wether the color grading effect is enabled.
  99561. */
  99562. cameraColorGradingEnabled: boolean;
  99563. /**
  99564. * Gets wether tonemapping is enabled or not.
  99565. */
  99566. /**
  99567. * Sets wether tonemapping is enabled or not
  99568. */
  99569. cameraToneMappingEnabled: boolean;
  99570. /**
  99571. * The camera exposure used on this material.
  99572. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99573. * This corresponds to a photographic exposure.
  99574. */
  99575. /**
  99576. * The camera exposure used on this material.
  99577. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99578. * This corresponds to a photographic exposure.
  99579. */
  99580. cameraExposure: number;
  99581. /**
  99582. * Gets The camera contrast used on this material.
  99583. */
  99584. /**
  99585. * Sets The camera contrast used on this material.
  99586. */
  99587. cameraContrast: number;
  99588. /**
  99589. * Gets the Color Grading 2D Lookup Texture.
  99590. */
  99591. /**
  99592. * Sets the Color Grading 2D Lookup Texture.
  99593. */
  99594. cameraColorGradingTexture: Nullable<BaseTexture>;
  99595. /**
  99596. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99597. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99598. * 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;
  99599. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99600. */
  99601. /**
  99602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99604. * 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;
  99605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99606. */
  99607. cameraColorCurves: Nullable<ColorCurves>;
  99608. /**
  99609. * Instantiates a new PBRMaterial instance.
  99610. *
  99611. * @param name The material name
  99612. * @param scene The scene the material will be use in.
  99613. */
  99614. constructor(name: string, scene: Scene);
  99615. /**
  99616. * Returns the name of this material class.
  99617. */
  99618. getClassName(): string;
  99619. /**
  99620. * Returns an array of the actively used textures.
  99621. * @returns - Array of BaseTextures
  99622. */
  99623. getActiveTextures(): BaseTexture[];
  99624. /**
  99625. * Checks to see if a texture is used in the material.
  99626. * @param texture - Base texture to use.
  99627. * @returns - Boolean specifying if a texture is used in the material.
  99628. */
  99629. hasTexture(texture: BaseTexture): boolean;
  99630. /**
  99631. * Makes a duplicate of the current material.
  99632. * @param name - name to use for the new material.
  99633. */
  99634. clone(name: string): PBRMaterial;
  99635. /**
  99636. * Serializes this PBR Material.
  99637. * @returns - An object with the serialized material.
  99638. */
  99639. serialize(): any;
  99640. /**
  99641. * Parses a PBR Material from a serialized object.
  99642. * @param source - Serialized object.
  99643. * @param scene - BJS scene instance.
  99644. * @param rootUrl - url for the scene object
  99645. * @returns - PBRMaterial
  99646. */
  99647. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  99648. }
  99649. }
  99650. declare module BABYLON {
  99651. /** @hidden */
  99652. export var _forceSceneHelpersToBundle: boolean;
  99653. interface Scene {
  99654. /**
  99655. * Creates a default light for the scene.
  99656. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  99657. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  99658. */
  99659. createDefaultLight(replace?: boolean): void;
  99660. /**
  99661. * Creates a default camera for the scene.
  99662. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  99663. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99664. * @param replace has default false, when true replaces the active camera in the scene
  99665. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  99666. */
  99667. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99668. /**
  99669. * Creates a default camera and a default light.
  99670. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  99671. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99672. * @param replace has the default false, when true replaces the active camera/light in the scene
  99673. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  99674. */
  99675. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99676. /**
  99677. * Creates a new sky box
  99678. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  99679. * @param environmentTexture defines the texture to use as environment texture
  99680. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  99681. * @param scale defines the overall scale of the skybox
  99682. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  99683. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  99684. * @returns a new mesh holding the sky box
  99685. */
  99686. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  99687. /**
  99688. * Creates a new environment
  99689. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  99690. * @param options defines the options you can use to configure the environment
  99691. * @returns the new EnvironmentHelper
  99692. */
  99693. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  99694. /**
  99695. * Creates a new VREXperienceHelper
  99696. * @see http://doc.babylonjs.com/how_to/webvr_helper
  99697. * @param webVROptions defines the options used to create the new VREXperienceHelper
  99698. * @returns a new VREXperienceHelper
  99699. */
  99700. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  99701. /**
  99702. * Creates a new XREXperienceHelper
  99703. * @see http://doc.babylonjs.com/how_to/webxr
  99704. * @returns a promise for a new XREXperienceHelper
  99705. */
  99706. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  99707. }
  99708. }
  99709. declare module BABYLON {
  99710. /**
  99711. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  99712. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  99713. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  99714. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99715. */
  99716. export class VideoDome extends TransformNode {
  99717. private _useDirectMapping;
  99718. /**
  99719. * The video texture being displayed on the sphere
  99720. */
  99721. protected _videoTexture: VideoTexture;
  99722. /**
  99723. * Gets the video texture being displayed on the sphere
  99724. */
  99725. readonly videoTexture: VideoTexture;
  99726. /**
  99727. * The skybox material
  99728. */
  99729. protected _material: BackgroundMaterial;
  99730. /**
  99731. * The surface used for the skybox
  99732. */
  99733. protected _mesh: Mesh;
  99734. /**
  99735. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99736. * Also see the options.resolution property.
  99737. */
  99738. fovMultiplier: number;
  99739. /**
  99740. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  99741. * @param name Element's name, child elements will append suffixes for their own names.
  99742. * @param urlsOrVideo defines the url(s) or the video element to use
  99743. * @param options An object containing optional or exposed sub element properties
  99744. */
  99745. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  99746. resolution?: number;
  99747. clickToPlay?: boolean;
  99748. autoPlay?: boolean;
  99749. loop?: boolean;
  99750. size?: number;
  99751. poster?: string;
  99752. useDirectMapping?: boolean;
  99753. }, scene: Scene);
  99754. /**
  99755. * Releases resources associated with this node.
  99756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99758. */
  99759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99760. }
  99761. }
  99762. declare module BABYLON {
  99763. /**
  99764. * This class can be used to get instrumentation data from a Babylon engine
  99765. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99766. */
  99767. export class EngineInstrumentation implements IDisposable {
  99768. /**
  99769. * Define the instrumented engine.
  99770. */
  99771. engine: Engine;
  99772. private _captureGPUFrameTime;
  99773. private _gpuFrameTimeToken;
  99774. private _gpuFrameTime;
  99775. private _captureShaderCompilationTime;
  99776. private _shaderCompilationTime;
  99777. private _onBeginFrameObserver;
  99778. private _onEndFrameObserver;
  99779. private _onBeforeShaderCompilationObserver;
  99780. private _onAfterShaderCompilationObserver;
  99781. /**
  99782. * Gets the perf counter used for GPU frame time
  99783. */
  99784. readonly gpuFrameTimeCounter: PerfCounter;
  99785. /**
  99786. * Gets the GPU frame time capture status
  99787. */
  99788. /**
  99789. * Enable or disable the GPU frame time capture
  99790. */
  99791. captureGPUFrameTime: boolean;
  99792. /**
  99793. * Gets the perf counter used for shader compilation time
  99794. */
  99795. readonly shaderCompilationTimeCounter: PerfCounter;
  99796. /**
  99797. * Gets the shader compilation time capture status
  99798. */
  99799. /**
  99800. * Enable or disable the shader compilation time capture
  99801. */
  99802. captureShaderCompilationTime: boolean;
  99803. /**
  99804. * Instantiates a new engine instrumentation.
  99805. * This class can be used to get instrumentation data from a Babylon engine
  99806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99807. * @param engine Defines the engine to instrument
  99808. */
  99809. constructor(
  99810. /**
  99811. * Define the instrumented engine.
  99812. */
  99813. engine: Engine);
  99814. /**
  99815. * Dispose and release associated resources.
  99816. */
  99817. dispose(): void;
  99818. }
  99819. }
  99820. declare module BABYLON {
  99821. /**
  99822. * This class can be used to get instrumentation data from a Babylon engine
  99823. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99824. */
  99825. export class SceneInstrumentation implements IDisposable {
  99826. /**
  99827. * Defines the scene to instrument
  99828. */
  99829. scene: Scene;
  99830. private _captureActiveMeshesEvaluationTime;
  99831. private _activeMeshesEvaluationTime;
  99832. private _captureRenderTargetsRenderTime;
  99833. private _renderTargetsRenderTime;
  99834. private _captureFrameTime;
  99835. private _frameTime;
  99836. private _captureRenderTime;
  99837. private _renderTime;
  99838. private _captureInterFrameTime;
  99839. private _interFrameTime;
  99840. private _captureParticlesRenderTime;
  99841. private _particlesRenderTime;
  99842. private _captureSpritesRenderTime;
  99843. private _spritesRenderTime;
  99844. private _capturePhysicsTime;
  99845. private _physicsTime;
  99846. private _captureAnimationsTime;
  99847. private _animationsTime;
  99848. private _captureCameraRenderTime;
  99849. private _cameraRenderTime;
  99850. private _onBeforeActiveMeshesEvaluationObserver;
  99851. private _onAfterActiveMeshesEvaluationObserver;
  99852. private _onBeforeRenderTargetsRenderObserver;
  99853. private _onAfterRenderTargetsRenderObserver;
  99854. private _onAfterRenderObserver;
  99855. private _onBeforeDrawPhaseObserver;
  99856. private _onAfterDrawPhaseObserver;
  99857. private _onBeforeAnimationsObserver;
  99858. private _onBeforeParticlesRenderingObserver;
  99859. private _onAfterParticlesRenderingObserver;
  99860. private _onBeforeSpritesRenderingObserver;
  99861. private _onAfterSpritesRenderingObserver;
  99862. private _onBeforePhysicsObserver;
  99863. private _onAfterPhysicsObserver;
  99864. private _onAfterAnimationsObserver;
  99865. private _onBeforeCameraRenderObserver;
  99866. private _onAfterCameraRenderObserver;
  99867. /**
  99868. * Gets the perf counter used for active meshes evaluation time
  99869. */
  99870. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  99871. /**
  99872. * Gets the active meshes evaluation time capture status
  99873. */
  99874. /**
  99875. * Enable or disable the active meshes evaluation time capture
  99876. */
  99877. captureActiveMeshesEvaluationTime: boolean;
  99878. /**
  99879. * Gets the perf counter used for render targets render time
  99880. */
  99881. readonly renderTargetsRenderTimeCounter: PerfCounter;
  99882. /**
  99883. * Gets the render targets render time capture status
  99884. */
  99885. /**
  99886. * Enable or disable the render targets render time capture
  99887. */
  99888. captureRenderTargetsRenderTime: boolean;
  99889. /**
  99890. * Gets the perf counter used for particles render time
  99891. */
  99892. readonly particlesRenderTimeCounter: PerfCounter;
  99893. /**
  99894. * Gets the particles render time capture status
  99895. */
  99896. /**
  99897. * Enable or disable the particles render time capture
  99898. */
  99899. captureParticlesRenderTime: boolean;
  99900. /**
  99901. * Gets the perf counter used for sprites render time
  99902. */
  99903. readonly spritesRenderTimeCounter: PerfCounter;
  99904. /**
  99905. * Gets the sprites render time capture status
  99906. */
  99907. /**
  99908. * Enable or disable the sprites render time capture
  99909. */
  99910. captureSpritesRenderTime: boolean;
  99911. /**
  99912. * Gets the perf counter used for physics time
  99913. */
  99914. readonly physicsTimeCounter: PerfCounter;
  99915. /**
  99916. * Gets the physics time capture status
  99917. */
  99918. /**
  99919. * Enable or disable the physics time capture
  99920. */
  99921. capturePhysicsTime: boolean;
  99922. /**
  99923. * Gets the perf counter used for animations time
  99924. */
  99925. readonly animationsTimeCounter: PerfCounter;
  99926. /**
  99927. * Gets the animations time capture status
  99928. */
  99929. /**
  99930. * Enable or disable the animations time capture
  99931. */
  99932. captureAnimationsTime: boolean;
  99933. /**
  99934. * Gets the perf counter used for frame time capture
  99935. */
  99936. readonly frameTimeCounter: PerfCounter;
  99937. /**
  99938. * Gets the frame time capture status
  99939. */
  99940. /**
  99941. * Enable or disable the frame time capture
  99942. */
  99943. captureFrameTime: boolean;
  99944. /**
  99945. * Gets the perf counter used for inter-frames time capture
  99946. */
  99947. readonly interFrameTimeCounter: PerfCounter;
  99948. /**
  99949. * Gets the inter-frames time capture status
  99950. */
  99951. /**
  99952. * Enable or disable the inter-frames time capture
  99953. */
  99954. captureInterFrameTime: boolean;
  99955. /**
  99956. * Gets the perf counter used for render time capture
  99957. */
  99958. readonly renderTimeCounter: PerfCounter;
  99959. /**
  99960. * Gets the render time capture status
  99961. */
  99962. /**
  99963. * Enable or disable the render time capture
  99964. */
  99965. captureRenderTime: boolean;
  99966. /**
  99967. * Gets the perf counter used for camera render time capture
  99968. */
  99969. readonly cameraRenderTimeCounter: PerfCounter;
  99970. /**
  99971. * Gets the camera render time capture status
  99972. */
  99973. /**
  99974. * Enable or disable the camera render time capture
  99975. */
  99976. captureCameraRenderTime: boolean;
  99977. /**
  99978. * Gets the perf counter used for draw calls
  99979. */
  99980. readonly drawCallsCounter: PerfCounter;
  99981. /**
  99982. * Gets the perf counter used for texture collisions
  99983. */
  99984. readonly textureCollisionsCounter: PerfCounter;
  99985. /**
  99986. * Instantiates a new scene instrumentation.
  99987. * This class can be used to get instrumentation data from a Babylon engine
  99988. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99989. * @param scene Defines the scene to instrument
  99990. */
  99991. constructor(
  99992. /**
  99993. * Defines the scene to instrument
  99994. */
  99995. scene: Scene);
  99996. /**
  99997. * Dispose and release associated resources.
  99998. */
  99999. dispose(): void;
  100000. }
  100001. }
  100002. declare module BABYLON {
  100003. /** @hidden */
  100004. export var glowMapGenerationPixelShader: {
  100005. name: string;
  100006. shader: string;
  100007. };
  100008. }
  100009. declare module BABYLON {
  100010. /** @hidden */
  100011. export var glowMapGenerationVertexShader: {
  100012. name: string;
  100013. shader: string;
  100014. };
  100015. }
  100016. declare module BABYLON {
  100017. /**
  100018. * Effect layer options. This helps customizing the behaviour
  100019. * of the effect layer.
  100020. */
  100021. export interface IEffectLayerOptions {
  100022. /**
  100023. * Multiplication factor apply to the canvas size to compute the render target size
  100024. * used to generated the objects (the smaller the faster).
  100025. */
  100026. mainTextureRatio: number;
  100027. /**
  100028. * Enforces a fixed size texture to ensure effect stability across devices.
  100029. */
  100030. mainTextureFixedSize?: number;
  100031. /**
  100032. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  100033. */
  100034. alphaBlendingMode: number;
  100035. /**
  100036. * The camera attached to the layer.
  100037. */
  100038. camera: Nullable<Camera>;
  100039. /**
  100040. * The rendering group to draw the layer in.
  100041. */
  100042. renderingGroupId: number;
  100043. }
  100044. /**
  100045. * The effect layer Helps adding post process effect blended with the main pass.
  100046. *
  100047. * This can be for instance use to generate glow or higlight effects on the scene.
  100048. *
  100049. * The effect layer class can not be used directly and is intented to inherited from to be
  100050. * customized per effects.
  100051. */
  100052. export abstract class EffectLayer {
  100053. private _vertexBuffers;
  100054. private _indexBuffer;
  100055. private _cachedDefines;
  100056. private _effectLayerMapGenerationEffect;
  100057. private _effectLayerOptions;
  100058. private _mergeEffect;
  100059. protected _scene: Scene;
  100060. protected _engine: Engine;
  100061. protected _maxSize: number;
  100062. protected _mainTextureDesiredSize: ISize;
  100063. protected _mainTexture: RenderTargetTexture;
  100064. protected _shouldRender: boolean;
  100065. protected _postProcesses: PostProcess[];
  100066. protected _textures: BaseTexture[];
  100067. protected _emissiveTextureAndColor: {
  100068. texture: Nullable<BaseTexture>;
  100069. color: Color4;
  100070. };
  100071. /**
  100072. * The name of the layer
  100073. */
  100074. name: string;
  100075. /**
  100076. * The clear color of the texture used to generate the glow map.
  100077. */
  100078. neutralColor: Color4;
  100079. /**
  100080. * Specifies wether the highlight layer is enabled or not.
  100081. */
  100082. isEnabled: boolean;
  100083. /**
  100084. * Gets the camera attached to the layer.
  100085. */
  100086. readonly camera: Nullable<Camera>;
  100087. /**
  100088. * Gets the rendering group id the layer should render in.
  100089. */
  100090. readonly renderingGroupId: number;
  100091. /**
  100092. * An event triggered when the effect layer has been disposed.
  100093. */
  100094. onDisposeObservable: Observable<EffectLayer>;
  100095. /**
  100096. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100097. */
  100098. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100099. /**
  100100. * An event triggered when the generated texture is being merged in the scene.
  100101. */
  100102. onBeforeComposeObservable: Observable<EffectLayer>;
  100103. /**
  100104. * An event triggered when the generated texture has been merged in the scene.
  100105. */
  100106. onAfterComposeObservable: Observable<EffectLayer>;
  100107. /**
  100108. * An event triggered when the efffect layer changes its size.
  100109. */
  100110. onSizeChangedObservable: Observable<EffectLayer>;
  100111. /** @hidden */
  100112. static _SceneComponentInitialization: (scene: Scene) => void;
  100113. /**
  100114. * Instantiates a new effect Layer and references it in the scene.
  100115. * @param name The name of the layer
  100116. * @param scene The scene to use the layer in
  100117. */
  100118. constructor(
  100119. /** The Friendly of the effect in the scene */
  100120. name: string, scene: Scene);
  100121. /**
  100122. * Get the effect name of the layer.
  100123. * @return The effect name
  100124. */
  100125. abstract getEffectName(): string;
  100126. /**
  100127. * Checks for the readiness of the element composing the layer.
  100128. * @param subMesh the mesh to check for
  100129. * @param useInstances specify wether or not to use instances to render the mesh
  100130. * @return true if ready otherwise, false
  100131. */
  100132. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100133. /**
  100134. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100135. * @returns true if the effect requires stencil during the main canvas render pass.
  100136. */
  100137. abstract needStencil(): boolean;
  100138. /**
  100139. * Create the merge effect. This is the shader use to blit the information back
  100140. * to the main canvas at the end of the scene rendering.
  100141. * @returns The effect containing the shader used to merge the effect on the main canvas
  100142. */
  100143. protected abstract _createMergeEffect(): Effect;
  100144. /**
  100145. * Creates the render target textures and post processes used in the effect layer.
  100146. */
  100147. protected abstract _createTextureAndPostProcesses(): void;
  100148. /**
  100149. * Implementation specific of rendering the generating effect on the main canvas.
  100150. * @param effect The effect used to render through
  100151. */
  100152. protected abstract _internalRender(effect: Effect): void;
  100153. /**
  100154. * Sets the required values for both the emissive texture and and the main color.
  100155. */
  100156. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100157. /**
  100158. * Free any resources and references associated to a mesh.
  100159. * Internal use
  100160. * @param mesh The mesh to free.
  100161. */
  100162. abstract _disposeMesh(mesh: Mesh): void;
  100163. /**
  100164. * Serializes this layer (Glow or Highlight for example)
  100165. * @returns a serialized layer object
  100166. */
  100167. abstract serialize?(): any;
  100168. /**
  100169. * Initializes the effect layer with the required options.
  100170. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100171. */
  100172. protected _init(options: Partial<IEffectLayerOptions>): void;
  100173. /**
  100174. * Generates the index buffer of the full screen quad blending to the main canvas.
  100175. */
  100176. private _generateIndexBuffer;
  100177. /**
  100178. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100179. */
  100180. private _genrateVertexBuffer;
  100181. /**
  100182. * Sets the main texture desired size which is the closest power of two
  100183. * of the engine canvas size.
  100184. */
  100185. private _setMainTextureSize;
  100186. /**
  100187. * Creates the main texture for the effect layer.
  100188. */
  100189. protected _createMainTexture(): void;
  100190. /**
  100191. * Adds specific effects defines.
  100192. * @param defines The defines to add specifics to.
  100193. */
  100194. protected _addCustomEffectDefines(defines: string[]): void;
  100195. /**
  100196. * Checks for the readiness of the element composing the layer.
  100197. * @param subMesh the mesh to check for
  100198. * @param useInstances specify wether or not to use instances to render the mesh
  100199. * @param emissiveTexture the associated emissive texture used to generate the glow
  100200. * @return true if ready otherwise, false
  100201. */
  100202. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100203. /**
  100204. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100205. */
  100206. render(): void;
  100207. /**
  100208. * Determine if a given mesh will be used in the current effect.
  100209. * @param mesh mesh to test
  100210. * @returns true if the mesh will be used
  100211. */
  100212. hasMesh(mesh: AbstractMesh): boolean;
  100213. /**
  100214. * Returns true if the layer contains information to display, otherwise false.
  100215. * @returns true if the glow layer should be rendered
  100216. */
  100217. shouldRender(): boolean;
  100218. /**
  100219. * Returns true if the mesh should render, otherwise false.
  100220. * @param mesh The mesh to render
  100221. * @returns true if it should render otherwise false
  100222. */
  100223. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100224. /**
  100225. * Returns true if the mesh can be rendered, otherwise false.
  100226. * @param mesh The mesh to render
  100227. * @param material The material used on the mesh
  100228. * @returns true if it can be rendered otherwise false
  100229. */
  100230. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100231. /**
  100232. * Returns true if the mesh should render, otherwise false.
  100233. * @param mesh The mesh to render
  100234. * @returns true if it should render otherwise false
  100235. */
  100236. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100237. /**
  100238. * Renders the submesh passed in parameter to the generation map.
  100239. */
  100240. protected _renderSubMesh(subMesh: SubMesh): void;
  100241. /**
  100242. * Rebuild the required buffers.
  100243. * @hidden Internal use only.
  100244. */
  100245. _rebuild(): void;
  100246. /**
  100247. * Dispose only the render target textures and post process.
  100248. */
  100249. private _disposeTextureAndPostProcesses;
  100250. /**
  100251. * Dispose the highlight layer and free resources.
  100252. */
  100253. dispose(): void;
  100254. /**
  100255. * Gets the class name of the effect layer
  100256. * @returns the string with the class name of the effect layer
  100257. */
  100258. getClassName(): string;
  100259. /**
  100260. * Creates an effect layer from parsed effect layer data
  100261. * @param parsedEffectLayer defines effect layer data
  100262. * @param scene defines the current scene
  100263. * @param rootUrl defines the root URL containing the effect layer information
  100264. * @returns a parsed effect Layer
  100265. */
  100266. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100267. }
  100268. }
  100269. declare module BABYLON {
  100270. interface AbstractScene {
  100271. /**
  100272. * The list of effect layers (highlights/glow) added to the scene
  100273. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100274. * @see http://doc.babylonjs.com/how_to/glow_layer
  100275. */
  100276. effectLayers: Array<EffectLayer>;
  100277. /**
  100278. * Removes the given effect layer from this scene.
  100279. * @param toRemove defines the effect layer to remove
  100280. * @returns the index of the removed effect layer
  100281. */
  100282. removeEffectLayer(toRemove: EffectLayer): number;
  100283. /**
  100284. * Adds the given effect layer to this scene
  100285. * @param newEffectLayer defines the effect layer to add
  100286. */
  100287. addEffectLayer(newEffectLayer: EffectLayer): void;
  100288. }
  100289. /**
  100290. * Defines the layer scene component responsible to manage any effect layers
  100291. * in a given scene.
  100292. */
  100293. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100294. /**
  100295. * The component name helpfull to identify the component in the list of scene components.
  100296. */
  100297. readonly name: string;
  100298. /**
  100299. * The scene the component belongs to.
  100300. */
  100301. scene: Scene;
  100302. private _engine;
  100303. private _renderEffects;
  100304. private _needStencil;
  100305. private _previousStencilState;
  100306. /**
  100307. * Creates a new instance of the component for the given scene
  100308. * @param scene Defines the scene to register the component in
  100309. */
  100310. constructor(scene: Scene);
  100311. /**
  100312. * Registers the component in a given scene
  100313. */
  100314. register(): void;
  100315. /**
  100316. * Rebuilds the elements related to this component in case of
  100317. * context lost for instance.
  100318. */
  100319. rebuild(): void;
  100320. /**
  100321. * Serializes the component data to the specified json object
  100322. * @param serializationObject The object to serialize to
  100323. */
  100324. serialize(serializationObject: any): void;
  100325. /**
  100326. * Adds all the element from the container to the scene
  100327. * @param container the container holding the elements
  100328. */
  100329. addFromContainer(container: AbstractScene): void;
  100330. /**
  100331. * Removes all the elements in the container from the scene
  100332. * @param container contains the elements to remove
  100333. */
  100334. removeFromContainer(container: AbstractScene): void;
  100335. /**
  100336. * Disposes the component and the associated ressources.
  100337. */
  100338. dispose(): void;
  100339. private _isReadyForMesh;
  100340. private _renderMainTexture;
  100341. private _setStencil;
  100342. private _setStencilBack;
  100343. private _draw;
  100344. private _drawCamera;
  100345. private _drawRenderingGroup;
  100346. }
  100347. }
  100348. declare module BABYLON {
  100349. /** @hidden */
  100350. export var glowMapMergePixelShader: {
  100351. name: string;
  100352. shader: string;
  100353. };
  100354. }
  100355. declare module BABYLON {
  100356. /** @hidden */
  100357. export var glowMapMergeVertexShader: {
  100358. name: string;
  100359. shader: string;
  100360. };
  100361. }
  100362. declare module BABYLON {
  100363. interface AbstractScene {
  100364. /**
  100365. * Return a the first highlight layer of the scene with a given name.
  100366. * @param name The name of the highlight layer to look for.
  100367. * @return The highlight layer if found otherwise null.
  100368. */
  100369. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100370. }
  100371. /**
  100372. * Glow layer options. This helps customizing the behaviour
  100373. * of the glow layer.
  100374. */
  100375. export interface IGlowLayerOptions {
  100376. /**
  100377. * Multiplication factor apply to the canvas size to compute the render target size
  100378. * used to generated the glowing objects (the smaller the faster).
  100379. */
  100380. mainTextureRatio: number;
  100381. /**
  100382. * Enforces a fixed size texture to ensure resize independant blur.
  100383. */
  100384. mainTextureFixedSize?: number;
  100385. /**
  100386. * How big is the kernel of the blur texture.
  100387. */
  100388. blurKernelSize: number;
  100389. /**
  100390. * The camera attached to the layer.
  100391. */
  100392. camera: Nullable<Camera>;
  100393. /**
  100394. * Enable MSAA by chosing the number of samples.
  100395. */
  100396. mainTextureSamples?: number;
  100397. /**
  100398. * The rendering group to draw the layer in.
  100399. */
  100400. renderingGroupId: number;
  100401. }
  100402. /**
  100403. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100404. *
  100405. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100406. * glowy meshes to your scene.
  100407. *
  100408. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  100409. */
  100410. export class GlowLayer extends EffectLayer {
  100411. /**
  100412. * Effect Name of the layer.
  100413. */
  100414. static readonly EffectName: string;
  100415. /**
  100416. * The default blur kernel size used for the glow.
  100417. */
  100418. static DefaultBlurKernelSize: number;
  100419. /**
  100420. * The default texture size ratio used for the glow.
  100421. */
  100422. static DefaultTextureRatio: number;
  100423. /**
  100424. * Sets the kernel size of the blur.
  100425. */
  100426. /**
  100427. * Gets the kernel size of the blur.
  100428. */
  100429. blurKernelSize: number;
  100430. /**
  100431. * Sets the glow intensity.
  100432. */
  100433. /**
  100434. * Gets the glow intensity.
  100435. */
  100436. intensity: number;
  100437. private _options;
  100438. private _intensity;
  100439. private _horizontalBlurPostprocess1;
  100440. private _verticalBlurPostprocess1;
  100441. private _horizontalBlurPostprocess2;
  100442. private _verticalBlurPostprocess2;
  100443. private _blurTexture1;
  100444. private _blurTexture2;
  100445. private _postProcesses1;
  100446. private _postProcesses2;
  100447. private _includedOnlyMeshes;
  100448. private _excludedMeshes;
  100449. /**
  100450. * Callback used to let the user override the color selection on a per mesh basis
  100451. */
  100452. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  100453. /**
  100454. * Callback used to let the user override the texture selection on a per mesh basis
  100455. */
  100456. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  100457. /**
  100458. * Instantiates a new glow Layer and references it to the scene.
  100459. * @param name The name of the layer
  100460. * @param scene The scene to use the layer in
  100461. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  100462. */
  100463. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  100464. /**
  100465. * Get the effect name of the layer.
  100466. * @return The effect name
  100467. */
  100468. getEffectName(): string;
  100469. /**
  100470. * Create the merge effect. This is the shader use to blit the information back
  100471. * to the main canvas at the end of the scene rendering.
  100472. */
  100473. protected _createMergeEffect(): Effect;
  100474. /**
  100475. * Creates the render target textures and post processes used in the glow layer.
  100476. */
  100477. protected _createTextureAndPostProcesses(): void;
  100478. /**
  100479. * Checks for the readiness of the element composing the layer.
  100480. * @param subMesh the mesh to check for
  100481. * @param useInstances specify wether or not to use instances to render the mesh
  100482. * @param emissiveTexture the associated emissive texture used to generate the glow
  100483. * @return true if ready otherwise, false
  100484. */
  100485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100486. /**
  100487. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100488. */
  100489. needStencil(): boolean;
  100490. /**
  100491. * Returns true if the mesh can be rendered, otherwise false.
  100492. * @param mesh The mesh to render
  100493. * @param material The material used on the mesh
  100494. * @returns true if it can be rendered otherwise false
  100495. */
  100496. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100497. /**
  100498. * Implementation specific of rendering the generating effect on the main canvas.
  100499. * @param effect The effect used to render through
  100500. */
  100501. protected _internalRender(effect: Effect): void;
  100502. /**
  100503. * Sets the required values for both the emissive texture and and the main color.
  100504. */
  100505. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100506. /**
  100507. * Returns true if the mesh should render, otherwise false.
  100508. * @param mesh The mesh to render
  100509. * @returns true if it should render otherwise false
  100510. */
  100511. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100512. /**
  100513. * Adds specific effects defines.
  100514. * @param defines The defines to add specifics to.
  100515. */
  100516. protected _addCustomEffectDefines(defines: string[]): void;
  100517. /**
  100518. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  100519. * @param mesh The mesh to exclude from the glow layer
  100520. */
  100521. addExcludedMesh(mesh: Mesh): void;
  100522. /**
  100523. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  100524. * @param mesh The mesh to remove
  100525. */
  100526. removeExcludedMesh(mesh: Mesh): void;
  100527. /**
  100528. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  100529. * @param mesh The mesh to include in the glow layer
  100530. */
  100531. addIncludedOnlyMesh(mesh: Mesh): void;
  100532. /**
  100533. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  100534. * @param mesh The mesh to remove
  100535. */
  100536. removeIncludedOnlyMesh(mesh: Mesh): void;
  100537. /**
  100538. * Determine if a given mesh will be used in the glow layer
  100539. * @param mesh The mesh to test
  100540. * @returns true if the mesh will be highlighted by the current glow layer
  100541. */
  100542. hasMesh(mesh: AbstractMesh): boolean;
  100543. /**
  100544. * Free any resources and references associated to a mesh.
  100545. * Internal use
  100546. * @param mesh The mesh to free.
  100547. * @hidden
  100548. */
  100549. _disposeMesh(mesh: Mesh): void;
  100550. /**
  100551. * Gets the class name of the effect layer
  100552. * @returns the string with the class name of the effect layer
  100553. */
  100554. getClassName(): string;
  100555. /**
  100556. * Serializes this glow layer
  100557. * @returns a serialized glow layer object
  100558. */
  100559. serialize(): any;
  100560. /**
  100561. * Creates a Glow Layer from parsed glow layer data
  100562. * @param parsedGlowLayer defines glow layer data
  100563. * @param scene defines the current scene
  100564. * @param rootUrl defines the root URL containing the glow layer information
  100565. * @returns a parsed Glow Layer
  100566. */
  100567. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  100568. }
  100569. }
  100570. declare module BABYLON {
  100571. /** @hidden */
  100572. export var glowBlurPostProcessPixelShader: {
  100573. name: string;
  100574. shader: string;
  100575. };
  100576. }
  100577. declare module BABYLON {
  100578. interface AbstractScene {
  100579. /**
  100580. * Return a the first highlight layer of the scene with a given name.
  100581. * @param name The name of the highlight layer to look for.
  100582. * @return The highlight layer if found otherwise null.
  100583. */
  100584. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  100585. }
  100586. /**
  100587. * Highlight layer options. This helps customizing the behaviour
  100588. * of the highlight layer.
  100589. */
  100590. export interface IHighlightLayerOptions {
  100591. /**
  100592. * Multiplication factor apply to the canvas size to compute the render target size
  100593. * used to generated the glowing objects (the smaller the faster).
  100594. */
  100595. mainTextureRatio: number;
  100596. /**
  100597. * Enforces a fixed size texture to ensure resize independant blur.
  100598. */
  100599. mainTextureFixedSize?: number;
  100600. /**
  100601. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  100602. * of the picture to blur (the smaller the faster).
  100603. */
  100604. blurTextureSizeRatio: number;
  100605. /**
  100606. * How big in texel of the blur texture is the vertical blur.
  100607. */
  100608. blurVerticalSize: number;
  100609. /**
  100610. * How big in texel of the blur texture is the horizontal blur.
  100611. */
  100612. blurHorizontalSize: number;
  100613. /**
  100614. * Alpha blending mode used to apply the blur. Default is combine.
  100615. */
  100616. alphaBlendingMode: number;
  100617. /**
  100618. * The camera attached to the layer.
  100619. */
  100620. camera: Nullable<Camera>;
  100621. /**
  100622. * Should we display highlight as a solid stroke?
  100623. */
  100624. isStroke?: boolean;
  100625. /**
  100626. * The rendering group to draw the layer in.
  100627. */
  100628. renderingGroupId: number;
  100629. }
  100630. /**
  100631. * The highlight layer Helps adding a glow effect around a mesh.
  100632. *
  100633. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100634. * glowy meshes to your scene.
  100635. *
  100636. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  100637. */
  100638. export class HighlightLayer extends EffectLayer {
  100639. name: string;
  100640. /**
  100641. * Effect Name of the highlight layer.
  100642. */
  100643. static readonly EffectName: string;
  100644. /**
  100645. * The neutral color used during the preparation of the glow effect.
  100646. * This is black by default as the blend operation is a blend operation.
  100647. */
  100648. static NeutralColor: Color4;
  100649. /**
  100650. * Stencil value used for glowing meshes.
  100651. */
  100652. static GlowingMeshStencilReference: number;
  100653. /**
  100654. * Stencil value used for the other meshes in the scene.
  100655. */
  100656. static NormalMeshStencilReference: number;
  100657. /**
  100658. * Specifies whether or not the inner glow is ACTIVE in the layer.
  100659. */
  100660. innerGlow: boolean;
  100661. /**
  100662. * Specifies whether or not the outer glow is ACTIVE in the layer.
  100663. */
  100664. outerGlow: boolean;
  100665. /**
  100666. * Specifies the horizontal size of the blur.
  100667. */
  100668. /**
  100669. * Gets the horizontal size of the blur.
  100670. */
  100671. blurHorizontalSize: number;
  100672. /**
  100673. * Specifies the vertical size of the blur.
  100674. */
  100675. /**
  100676. * Gets the vertical size of the blur.
  100677. */
  100678. blurVerticalSize: number;
  100679. /**
  100680. * An event triggered when the highlight layer is being blurred.
  100681. */
  100682. onBeforeBlurObservable: Observable<HighlightLayer>;
  100683. /**
  100684. * An event triggered when the highlight layer has been blurred.
  100685. */
  100686. onAfterBlurObservable: Observable<HighlightLayer>;
  100687. private _instanceGlowingMeshStencilReference;
  100688. private _options;
  100689. private _downSamplePostprocess;
  100690. private _horizontalBlurPostprocess;
  100691. private _verticalBlurPostprocess;
  100692. private _blurTexture;
  100693. private _meshes;
  100694. private _excludedMeshes;
  100695. /**
  100696. * Instantiates a new highlight Layer and references it to the scene..
  100697. * @param name The name of the layer
  100698. * @param scene The scene to use the layer in
  100699. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  100700. */
  100701. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  100702. /**
  100703. * Get the effect name of the layer.
  100704. * @return The effect name
  100705. */
  100706. getEffectName(): string;
  100707. /**
  100708. * Create the merge effect. This is the shader use to blit the information back
  100709. * to the main canvas at the end of the scene rendering.
  100710. */
  100711. protected _createMergeEffect(): Effect;
  100712. /**
  100713. * Creates the render target textures and post processes used in the highlight layer.
  100714. */
  100715. protected _createTextureAndPostProcesses(): void;
  100716. /**
  100717. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100718. */
  100719. needStencil(): boolean;
  100720. /**
  100721. * Checks for the readiness of the element composing the layer.
  100722. * @param subMesh the mesh to check for
  100723. * @param useInstances specify wether or not to use instances to render the mesh
  100724. * @param emissiveTexture the associated emissive texture used to generate the glow
  100725. * @return true if ready otherwise, false
  100726. */
  100727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100728. /**
  100729. * Implementation specific of rendering the generating effect on the main canvas.
  100730. * @param effect The effect used to render through
  100731. */
  100732. protected _internalRender(effect: Effect): void;
  100733. /**
  100734. * Returns true if the layer contains information to display, otherwise false.
  100735. */
  100736. shouldRender(): boolean;
  100737. /**
  100738. * Returns true if the mesh should render, otherwise false.
  100739. * @param mesh The mesh to render
  100740. * @returns true if it should render otherwise false
  100741. */
  100742. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100743. /**
  100744. * Sets the required values for both the emissive texture and and the main color.
  100745. */
  100746. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100747. /**
  100748. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  100749. * @param mesh The mesh to exclude from the highlight layer
  100750. */
  100751. addExcludedMesh(mesh: Mesh): void;
  100752. /**
  100753. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  100754. * @param mesh The mesh to highlight
  100755. */
  100756. removeExcludedMesh(mesh: Mesh): void;
  100757. /**
  100758. * Determine if a given mesh will be highlighted by the current HighlightLayer
  100759. * @param mesh mesh to test
  100760. * @returns true if the mesh will be highlighted by the current HighlightLayer
  100761. */
  100762. hasMesh(mesh: AbstractMesh): boolean;
  100763. /**
  100764. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  100765. * @param mesh The mesh to highlight
  100766. * @param color The color of the highlight
  100767. * @param glowEmissiveOnly Extract the glow from the emissive texture
  100768. */
  100769. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  100770. /**
  100771. * Remove a mesh from the highlight layer in order to make it stop glowing.
  100772. * @param mesh The mesh to highlight
  100773. */
  100774. removeMesh(mesh: Mesh): void;
  100775. /**
  100776. * Force the stencil to the normal expected value for none glowing parts
  100777. */
  100778. private _defaultStencilReference;
  100779. /**
  100780. * Free any resources and references associated to a mesh.
  100781. * Internal use
  100782. * @param mesh The mesh to free.
  100783. * @hidden
  100784. */
  100785. _disposeMesh(mesh: Mesh): void;
  100786. /**
  100787. * Dispose the highlight layer and free resources.
  100788. */
  100789. dispose(): void;
  100790. /**
  100791. * Gets the class name of the effect layer
  100792. * @returns the string with the class name of the effect layer
  100793. */
  100794. getClassName(): string;
  100795. /**
  100796. * Serializes this Highlight layer
  100797. * @returns a serialized Highlight layer object
  100798. */
  100799. serialize(): any;
  100800. /**
  100801. * Creates a Highlight layer from parsed Highlight layer data
  100802. * @param parsedHightlightLayer defines the Highlight layer data
  100803. * @param scene defines the current scene
  100804. * @param rootUrl defines the root URL containing the Highlight layer information
  100805. * @returns a parsed Highlight layer
  100806. */
  100807. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  100808. }
  100809. }
  100810. declare module BABYLON {
  100811. /** @hidden */
  100812. export var lensFlarePixelShader: {
  100813. name: string;
  100814. shader: string;
  100815. };
  100816. }
  100817. declare module BABYLON {
  100818. /** @hidden */
  100819. export var lensFlareVertexShader: {
  100820. name: string;
  100821. shader: string;
  100822. };
  100823. }
  100824. declare module BABYLON {
  100825. /**
  100826. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100827. * It is usually composed of several `lensFlare`.
  100828. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100829. */
  100830. export class LensFlareSystem {
  100831. /**
  100832. * Define the name of the lens flare system
  100833. */
  100834. name: string;
  100835. /**
  100836. * List of lens flares used in this system.
  100837. */
  100838. lensFlares: LensFlare[];
  100839. /**
  100840. * Define a limit from the border the lens flare can be visible.
  100841. */
  100842. borderLimit: number;
  100843. /**
  100844. * Define a viewport border we do not want to see the lens flare in.
  100845. */
  100846. viewportBorder: number;
  100847. /**
  100848. * Define a predicate which could limit the list of meshes able to occlude the effect.
  100849. */
  100850. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  100851. /**
  100852. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  100853. */
  100854. layerMask: number;
  100855. /**
  100856. * Define the id of the lens flare system in the scene.
  100857. * (equal to name by default)
  100858. */
  100859. id: string;
  100860. private _scene;
  100861. private _emitter;
  100862. private _vertexBuffers;
  100863. private _indexBuffer;
  100864. private _effect;
  100865. private _positionX;
  100866. private _positionY;
  100867. private _isEnabled;
  100868. /** @hidden */
  100869. static _SceneComponentInitialization: (scene: Scene) => void;
  100870. /**
  100871. * Instantiates a lens flare system.
  100872. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100873. * It is usually composed of several `lensFlare`.
  100874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100875. * @param name Define the name of the lens flare system in the scene
  100876. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  100877. * @param scene Define the scene the lens flare system belongs to
  100878. */
  100879. constructor(
  100880. /**
  100881. * Define the name of the lens flare system
  100882. */
  100883. name: string, emitter: any, scene: Scene);
  100884. /**
  100885. * Define if the lens flare system is enabled.
  100886. */
  100887. isEnabled: boolean;
  100888. /**
  100889. * Get the scene the effects belongs to.
  100890. * @returns the scene holding the lens flare system
  100891. */
  100892. getScene(): Scene;
  100893. /**
  100894. * Get the emitter of the lens flare system.
  100895. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100896. * @returns the emitter of the lens flare system
  100897. */
  100898. getEmitter(): any;
  100899. /**
  100900. * Set the emitter of the lens flare system.
  100901. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100902. * @param newEmitter Define the new emitter of the system
  100903. */
  100904. setEmitter(newEmitter: any): void;
  100905. /**
  100906. * Get the lens flare system emitter position.
  100907. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  100908. * @returns the position
  100909. */
  100910. getEmitterPosition(): Vector3;
  100911. /**
  100912. * @hidden
  100913. */
  100914. computeEffectivePosition(globalViewport: Viewport): boolean;
  100915. /** @hidden */
  100916. _isVisible(): boolean;
  100917. /**
  100918. * @hidden
  100919. */
  100920. render(): boolean;
  100921. /**
  100922. * Dispose and release the lens flare with its associated resources.
  100923. */
  100924. dispose(): void;
  100925. /**
  100926. * Parse a lens flare system from a JSON repressentation
  100927. * @param parsedLensFlareSystem Define the JSON to parse
  100928. * @param scene Define the scene the parsed system should be instantiated in
  100929. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  100930. * @returns the parsed system
  100931. */
  100932. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  100933. /**
  100934. * Serialize the current Lens Flare System into a JSON representation.
  100935. * @returns the serialized JSON
  100936. */
  100937. serialize(): any;
  100938. }
  100939. }
  100940. declare module BABYLON {
  100941. /**
  100942. * This represents one of the lens effect in a `lensFlareSystem`.
  100943. * It controls one of the indiviual texture used in the effect.
  100944. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100945. */
  100946. export class LensFlare {
  100947. /**
  100948. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100949. */
  100950. size: number;
  100951. /**
  100952. * 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.
  100953. */
  100954. position: number;
  100955. /**
  100956. * Define the lens color.
  100957. */
  100958. color: Color3;
  100959. /**
  100960. * Define the lens texture.
  100961. */
  100962. texture: Nullable<Texture>;
  100963. /**
  100964. * Define the alpha mode to render this particular lens.
  100965. */
  100966. alphaMode: number;
  100967. private _system;
  100968. /**
  100969. * Creates a new Lens Flare.
  100970. * This represents one of the lens effect in a `lensFlareSystem`.
  100971. * It controls one of the indiviual texture used in the effect.
  100972. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100973. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  100974. * @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.
  100975. * @param color Define the lens color
  100976. * @param imgUrl Define the lens texture url
  100977. * @param system Define the `lensFlareSystem` this flare is part of
  100978. * @returns The newly created Lens Flare
  100979. */
  100980. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  100981. /**
  100982. * Instantiates a new Lens Flare.
  100983. * This represents one of the lens effect in a `lensFlareSystem`.
  100984. * It controls one of the indiviual texture used in the effect.
  100985. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100986. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  100987. * @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.
  100988. * @param color Define the lens color
  100989. * @param imgUrl Define the lens texture url
  100990. * @param system Define the `lensFlareSystem` this flare is part of
  100991. */
  100992. constructor(
  100993. /**
  100994. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100995. */
  100996. size: number,
  100997. /**
  100998. * 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.
  100999. */
  101000. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  101001. /**
  101002. * Dispose and release the lens flare with its associated resources.
  101003. */
  101004. dispose(): void;
  101005. }
  101006. }
  101007. declare module BABYLON {
  101008. interface AbstractScene {
  101009. /**
  101010. * The list of lens flare system added to the scene
  101011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101012. */
  101013. lensFlareSystems: Array<LensFlareSystem>;
  101014. /**
  101015. * Removes the given lens flare system from this scene.
  101016. * @param toRemove The lens flare system to remove
  101017. * @returns The index of the removed lens flare system
  101018. */
  101019. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  101020. /**
  101021. * Adds the given lens flare system to this scene
  101022. * @param newLensFlareSystem The lens flare system to add
  101023. */
  101024. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  101025. /**
  101026. * Gets a lens flare system using its name
  101027. * @param name defines the name to look for
  101028. * @returns the lens flare system or null if not found
  101029. */
  101030. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  101031. /**
  101032. * Gets a lens flare system using its id
  101033. * @param id defines the id to look for
  101034. * @returns the lens flare system or null if not found
  101035. */
  101036. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  101037. }
  101038. /**
  101039. * Defines the lens flare scene component responsible to manage any lens flares
  101040. * in a given scene.
  101041. */
  101042. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  101043. /**
  101044. * The component name helpfull to identify the component in the list of scene components.
  101045. */
  101046. readonly name: string;
  101047. /**
  101048. * The scene the component belongs to.
  101049. */
  101050. scene: Scene;
  101051. /**
  101052. * Creates a new instance of the component for the given scene
  101053. * @param scene Defines the scene to register the component in
  101054. */
  101055. constructor(scene: Scene);
  101056. /**
  101057. * Registers the component in a given scene
  101058. */
  101059. register(): void;
  101060. /**
  101061. * Rebuilds the elements related to this component in case of
  101062. * context lost for instance.
  101063. */
  101064. rebuild(): void;
  101065. /**
  101066. * Adds all the element from the container to the scene
  101067. * @param container the container holding the elements
  101068. */
  101069. addFromContainer(container: AbstractScene): void;
  101070. /**
  101071. * Removes all the elements in the container from the scene
  101072. * @param container contains the elements to remove
  101073. */
  101074. removeFromContainer(container: AbstractScene): void;
  101075. /**
  101076. * Serializes the component data to the specified json object
  101077. * @param serializationObject The object to serialize to
  101078. */
  101079. serialize(serializationObject: any): void;
  101080. /**
  101081. * Disposes the component and the associated ressources.
  101082. */
  101083. dispose(): void;
  101084. private _draw;
  101085. }
  101086. }
  101087. declare module BABYLON {
  101088. /**
  101089. * Defines the shadow generator component responsible to manage any shadow generators
  101090. * in a given scene.
  101091. */
  101092. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  101093. /**
  101094. * The component name helpfull to identify the component in the list of scene components.
  101095. */
  101096. readonly name: string;
  101097. /**
  101098. * The scene the component belongs to.
  101099. */
  101100. scene: Scene;
  101101. /**
  101102. * Creates a new instance of the component for the given scene
  101103. * @param scene Defines the scene to register the component in
  101104. */
  101105. constructor(scene: Scene);
  101106. /**
  101107. * Registers the component in a given scene
  101108. */
  101109. register(): void;
  101110. /**
  101111. * Rebuilds the elements related to this component in case of
  101112. * context lost for instance.
  101113. */
  101114. rebuild(): void;
  101115. /**
  101116. * Serializes the component data to the specified json object
  101117. * @param serializationObject The object to serialize to
  101118. */
  101119. serialize(serializationObject: any): void;
  101120. /**
  101121. * Adds all the element from the container to the scene
  101122. * @param container the container holding the elements
  101123. */
  101124. addFromContainer(container: AbstractScene): void;
  101125. /**
  101126. * Removes all the elements in the container from the scene
  101127. * @param container contains the elements to remove
  101128. */
  101129. removeFromContainer(container: AbstractScene): void;
  101130. /**
  101131. * Rebuilds the elements related to this component in case of
  101132. * context lost for instance.
  101133. */
  101134. dispose(): void;
  101135. private _gatherRenderTargets;
  101136. }
  101137. }
  101138. declare module BABYLON {
  101139. /**
  101140. * A directional light is defined by a direction (what a surprise!).
  101141. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101142. * 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.
  101143. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101144. */
  101145. export class DirectionalLight extends ShadowLight {
  101146. private _shadowFrustumSize;
  101147. /**
  101148. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101149. */
  101150. /**
  101151. * Specifies a fix frustum size for the shadow generation.
  101152. */
  101153. shadowFrustumSize: number;
  101154. private _shadowOrthoScale;
  101155. /**
  101156. * Gets the shadow projection scale against the optimal computed one.
  101157. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101158. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101159. */
  101160. /**
  101161. * Sets the shadow projection scale against the optimal computed one.
  101162. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101163. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101164. */
  101165. shadowOrthoScale: number;
  101166. /**
  101167. * Automatically compute the projection matrix to best fit (including all the casters)
  101168. * on each frame.
  101169. */
  101170. autoUpdateExtends: boolean;
  101171. private _orthoLeft;
  101172. private _orthoRight;
  101173. private _orthoTop;
  101174. private _orthoBottom;
  101175. /**
  101176. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101177. * The directional light is emitted from everywhere in the given direction.
  101178. * It can cast shadows.
  101179. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101180. * @param name The friendly name of the light
  101181. * @param direction The direction of the light
  101182. * @param scene The scene the light belongs to
  101183. */
  101184. constructor(name: string, direction: Vector3, scene: Scene);
  101185. /**
  101186. * Returns the string "DirectionalLight".
  101187. * @return The class name
  101188. */
  101189. getClassName(): string;
  101190. /**
  101191. * Returns the integer 1.
  101192. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101193. */
  101194. getTypeID(): number;
  101195. /**
  101196. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101197. * Returns the DirectionalLight Shadow projection matrix.
  101198. */
  101199. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101200. /**
  101201. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101202. * Returns the DirectionalLight Shadow projection matrix.
  101203. */
  101204. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101205. /**
  101206. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101207. * Returns the DirectionalLight Shadow projection matrix.
  101208. */
  101209. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101210. protected _buildUniformLayout(): void;
  101211. /**
  101212. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101213. * @param effect The effect to update
  101214. * @param lightIndex The index of the light in the effect to update
  101215. * @returns The directional light
  101216. */
  101217. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101218. /**
  101219. * Gets the minZ used for shadow according to both the scene and the light.
  101220. *
  101221. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101222. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101223. * @param activeCamera The camera we are returning the min for
  101224. * @returns the depth min z
  101225. */
  101226. getDepthMinZ(activeCamera: Camera): number;
  101227. /**
  101228. * Gets the maxZ used for shadow according to both the scene and the light.
  101229. *
  101230. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101231. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101232. * @param activeCamera The camera we are returning the max for
  101233. * @returns the depth max z
  101234. */
  101235. getDepthMaxZ(activeCamera: Camera): number;
  101236. /**
  101237. * Prepares the list of defines specific to the light type.
  101238. * @param defines the list of defines
  101239. * @param lightIndex defines the index of the light for the effect
  101240. */
  101241. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101242. }
  101243. }
  101244. declare module BABYLON {
  101245. /**
  101246. * A point light is a light defined by an unique point in world space.
  101247. * The light is emitted in every direction from this point.
  101248. * A good example of a point light is a standard light bulb.
  101249. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101250. */
  101251. export class PointLight extends ShadowLight {
  101252. private _shadowAngle;
  101253. /**
  101254. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101255. * This specifies what angle the shadow will use to be created.
  101256. *
  101257. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101258. */
  101259. /**
  101260. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101261. * This specifies what angle the shadow will use to be created.
  101262. *
  101263. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101264. */
  101265. shadowAngle: number;
  101266. /**
  101267. * Gets the direction if it has been set.
  101268. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101269. */
  101270. /**
  101271. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101272. */
  101273. direction: Vector3;
  101274. /**
  101275. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101276. * A PointLight emits the light in every direction.
  101277. * It can cast shadows.
  101278. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101279. * ```javascript
  101280. * var pointLight = new PointLight("pl", camera.position, scene);
  101281. * ```
  101282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101283. * @param name The light friendly name
  101284. * @param position The position of the point light in the scene
  101285. * @param scene The scene the lights belongs to
  101286. */
  101287. constructor(name: string, position: Vector3, scene: Scene);
  101288. /**
  101289. * Returns the string "PointLight"
  101290. * @returns the class name
  101291. */
  101292. getClassName(): string;
  101293. /**
  101294. * Returns the integer 0.
  101295. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101296. */
  101297. getTypeID(): number;
  101298. /**
  101299. * Specifies wether or not the shadowmap should be a cube texture.
  101300. * @returns true if the shadowmap needs to be a cube texture.
  101301. */
  101302. needCube(): boolean;
  101303. /**
  101304. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101305. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101306. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101307. */
  101308. getShadowDirection(faceIndex?: number): Vector3;
  101309. /**
  101310. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101311. * - fov = PI / 2
  101312. * - aspect ratio : 1.0
  101313. * - z-near and far equal to the active camera minZ and maxZ.
  101314. * Returns the PointLight.
  101315. */
  101316. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101317. protected _buildUniformLayout(): void;
  101318. /**
  101319. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101320. * @param effect The effect to update
  101321. * @param lightIndex The index of the light in the effect to update
  101322. * @returns The point light
  101323. */
  101324. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101325. /**
  101326. * Prepares the list of defines specific to the light type.
  101327. * @param defines the list of defines
  101328. * @param lightIndex defines the index of the light for the effect
  101329. */
  101330. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101331. }
  101332. }
  101333. declare module BABYLON {
  101334. /**
  101335. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101336. * These values define a cone of light starting from the position, emitting toward the direction.
  101337. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101338. * and the exponent defines the speed of the decay of the light with distance (reach).
  101339. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101340. */
  101341. export class SpotLight extends ShadowLight {
  101342. private _angle;
  101343. private _innerAngle;
  101344. private _cosHalfAngle;
  101345. private _lightAngleScale;
  101346. private _lightAngleOffset;
  101347. /**
  101348. * Gets the cone angle of the spot light in Radians.
  101349. */
  101350. /**
  101351. * Sets the cone angle of the spot light in Radians.
  101352. */
  101353. angle: number;
  101354. /**
  101355. * Only used in gltf falloff mode, this defines the angle where
  101356. * the directional falloff will start before cutting at angle which could be seen
  101357. * as outer angle.
  101358. */
  101359. /**
  101360. * Only used in gltf falloff mode, this defines the angle where
  101361. * the directional falloff will start before cutting at angle which could be seen
  101362. * as outer angle.
  101363. */
  101364. innerAngle: number;
  101365. private _shadowAngleScale;
  101366. /**
  101367. * Allows scaling the angle of the light for shadow generation only.
  101368. */
  101369. /**
  101370. * Allows scaling the angle of the light for shadow generation only.
  101371. */
  101372. shadowAngleScale: number;
  101373. /**
  101374. * The light decay speed with the distance from the emission spot.
  101375. */
  101376. exponent: number;
  101377. private _projectionTextureMatrix;
  101378. /**
  101379. * Allows reading the projecton texture
  101380. */
  101381. readonly projectionTextureMatrix: Matrix;
  101382. protected _projectionTextureLightNear: number;
  101383. /**
  101384. * Gets the near clip of the Spotlight for texture projection.
  101385. */
  101386. /**
  101387. * Sets the near clip of the Spotlight for texture projection.
  101388. */
  101389. projectionTextureLightNear: number;
  101390. protected _projectionTextureLightFar: number;
  101391. /**
  101392. * Gets the far clip of the Spotlight for texture projection.
  101393. */
  101394. /**
  101395. * Sets the far clip of the Spotlight for texture projection.
  101396. */
  101397. projectionTextureLightFar: number;
  101398. protected _projectionTextureUpDirection: Vector3;
  101399. /**
  101400. * Gets the Up vector of the Spotlight for texture projection.
  101401. */
  101402. /**
  101403. * Sets the Up vector of the Spotlight for texture projection.
  101404. */
  101405. projectionTextureUpDirection: Vector3;
  101406. private _projectionTexture;
  101407. /**
  101408. * Gets the projection texture of the light.
  101409. */
  101410. /**
  101411. * Sets the projection texture of the light.
  101412. */
  101413. projectionTexture: Nullable<BaseTexture>;
  101414. private _projectionTextureViewLightDirty;
  101415. private _projectionTextureProjectionLightDirty;
  101416. private _projectionTextureDirty;
  101417. private _projectionTextureViewTargetVector;
  101418. private _projectionTextureViewLightMatrix;
  101419. private _projectionTextureProjectionLightMatrix;
  101420. private _projectionTextureScalingMatrix;
  101421. /**
  101422. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101423. * It can cast shadows.
  101424. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101425. * @param name The light friendly name
  101426. * @param position The position of the spot light in the scene
  101427. * @param direction The direction of the light in the scene
  101428. * @param angle The cone angle of the light in Radians
  101429. * @param exponent The light decay speed with the distance from the emission spot
  101430. * @param scene The scene the lights belongs to
  101431. */
  101432. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101433. /**
  101434. * Returns the string "SpotLight".
  101435. * @returns the class name
  101436. */
  101437. getClassName(): string;
  101438. /**
  101439. * Returns the integer 2.
  101440. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101441. */
  101442. getTypeID(): number;
  101443. /**
  101444. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101445. */
  101446. protected _setDirection(value: Vector3): void;
  101447. /**
  101448. * Overrides the position setter to recompute the projection texture view light Matrix.
  101449. */
  101450. protected _setPosition(value: Vector3): void;
  101451. /**
  101452. * 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.
  101453. * Returns the SpotLight.
  101454. */
  101455. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101456. protected _computeProjectionTextureViewLightMatrix(): void;
  101457. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101458. /**
  101459. * Main function for light texture projection matrix computing.
  101460. */
  101461. protected _computeProjectionTextureMatrix(): void;
  101462. protected _buildUniformLayout(): void;
  101463. private _computeAngleValues;
  101464. /**
  101465. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101466. * @param effect The effect to update
  101467. * @param lightIndex The index of the light in the effect to update
  101468. * @returns The spot light
  101469. */
  101470. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101471. /**
  101472. * Disposes the light and the associated resources.
  101473. */
  101474. dispose(): void;
  101475. /**
  101476. * Prepares the list of defines specific to the light type.
  101477. * @param defines the list of defines
  101478. * @param lightIndex defines the index of the light for the effect
  101479. */
  101480. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101481. }
  101482. }
  101483. declare module BABYLON {
  101484. /**
  101485. * Header information of HDR texture files.
  101486. */
  101487. export interface HDRInfo {
  101488. /**
  101489. * The height of the texture in pixels.
  101490. */
  101491. height: number;
  101492. /**
  101493. * The width of the texture in pixels.
  101494. */
  101495. width: number;
  101496. /**
  101497. * The index of the beginning of the data in the binary file.
  101498. */
  101499. dataPosition: number;
  101500. }
  101501. /**
  101502. * This groups tools to convert HDR texture to native colors array.
  101503. */
  101504. export class HDRTools {
  101505. private static Ldexp;
  101506. private static Rgbe2float;
  101507. private static readStringLine;
  101508. /**
  101509. * Reads header information from an RGBE texture stored in a native array.
  101510. * More information on this format are available here:
  101511. * https://en.wikipedia.org/wiki/RGBE_image_format
  101512. *
  101513. * @param uint8array The binary file stored in native array.
  101514. * @return The header information.
  101515. */
  101516. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  101517. /**
  101518. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  101519. * This RGBE texture needs to store the information as a panorama.
  101520. *
  101521. * More information on this format are available here:
  101522. * https://en.wikipedia.org/wiki/RGBE_image_format
  101523. *
  101524. * @param buffer The binary file stored in an array buffer.
  101525. * @param size The expected size of the extracted cubemap.
  101526. * @return The Cube Map information.
  101527. */
  101528. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  101529. /**
  101530. * Returns the pixels data extracted from an RGBE texture.
  101531. * This pixels will be stored left to right up to down in the R G B order in one array.
  101532. *
  101533. * More information on this format are available here:
  101534. * https://en.wikipedia.org/wiki/RGBE_image_format
  101535. *
  101536. * @param uint8array The binary file stored in an array buffer.
  101537. * @param hdrInfo The header information of the file.
  101538. * @return The pixels data in RGB right to left up to down order.
  101539. */
  101540. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  101541. private static RGBE_ReadPixels_RLE;
  101542. }
  101543. }
  101544. declare module BABYLON {
  101545. /**
  101546. * This represents a texture coming from an HDR input.
  101547. *
  101548. * The only supported format is currently panorama picture stored in RGBE format.
  101549. * Example of such files can be found on HDRLib: http://hdrlib.com/
  101550. */
  101551. export class HDRCubeTexture extends BaseTexture {
  101552. private static _facesMapping;
  101553. private _generateHarmonics;
  101554. private _noMipmap;
  101555. private _textureMatrix;
  101556. private _size;
  101557. private _onLoad;
  101558. private _onError;
  101559. /**
  101560. * The texture URL.
  101561. */
  101562. url: string;
  101563. /**
  101564. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  101565. */
  101566. coordinatesMode: number;
  101567. protected _isBlocking: boolean;
  101568. /**
  101569. * Sets wether or not the texture is blocking during loading.
  101570. */
  101571. /**
  101572. * Gets wether or not the texture is blocking during loading.
  101573. */
  101574. isBlocking: boolean;
  101575. protected _rotationY: number;
  101576. /**
  101577. * Sets texture matrix rotation angle around Y axis in radians.
  101578. */
  101579. /**
  101580. * Gets texture matrix rotation angle around Y axis radians.
  101581. */
  101582. rotationY: number;
  101583. /**
  101584. * Gets or sets the center of the bounding box associated with the cube texture
  101585. * It must define where the camera used to render the texture was set
  101586. */
  101587. boundingBoxPosition: Vector3;
  101588. private _boundingBoxSize;
  101589. /**
  101590. * Gets or sets the size of the bounding box associated with the cube texture
  101591. * When defined, the cubemap will switch to local mode
  101592. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101593. * @example https://www.babylonjs-playground.com/#RNASML
  101594. */
  101595. boundingBoxSize: Vector3;
  101596. /**
  101597. * Instantiates an HDRTexture from the following parameters.
  101598. *
  101599. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  101600. * @param scene The scene the texture will be used in
  101601. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  101602. * @param noMipmap Forces to not generate the mipmap if true
  101603. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  101604. * @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)
  101605. * @param reserved Reserved flag for internal use.
  101606. */
  101607. 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>);
  101608. /**
  101609. * Get the current class name of the texture useful for serialization or dynamic coding.
  101610. * @returns "HDRCubeTexture"
  101611. */
  101612. getClassName(): string;
  101613. /**
  101614. * Occurs when the file is raw .hdr file.
  101615. */
  101616. private loadTexture;
  101617. clone(): HDRCubeTexture;
  101618. delayLoad(): void;
  101619. /**
  101620. * Get the texture reflection matrix used to rotate/transform the reflection.
  101621. * @returns the reflection matrix
  101622. */
  101623. getReflectionTextureMatrix(): Matrix;
  101624. /**
  101625. * Set the texture reflection matrix used to rotate/transform the reflection.
  101626. * @param value Define the reflection matrix to set
  101627. */
  101628. setReflectionTextureMatrix(value: Matrix): void;
  101629. /**
  101630. * Parses a JSON representation of an HDR Texture in order to create the texture
  101631. * @param parsedTexture Define the JSON representation
  101632. * @param scene Define the scene the texture should be created in
  101633. * @param rootUrl Define the root url in case we need to load relative dependencies
  101634. * @returns the newly created texture after parsing
  101635. */
  101636. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  101637. serialize(): any;
  101638. }
  101639. }
  101640. declare module BABYLON {
  101641. /**
  101642. * Class used to control physics engine
  101643. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  101644. */
  101645. export class PhysicsEngine implements IPhysicsEngine {
  101646. private _physicsPlugin;
  101647. /**
  101648. * Global value used to control the smallest number supported by the simulation
  101649. */
  101650. static Epsilon: number;
  101651. private _impostors;
  101652. private _joints;
  101653. /**
  101654. * Gets the gravity vector used by the simulation
  101655. */
  101656. gravity: Vector3;
  101657. /**
  101658. * Factory used to create the default physics plugin.
  101659. * @returns The default physics plugin
  101660. */
  101661. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  101662. /**
  101663. * Creates a new Physics Engine
  101664. * @param gravity defines the gravity vector used by the simulation
  101665. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  101666. */
  101667. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  101668. /**
  101669. * Sets the gravity vector used by the simulation
  101670. * @param gravity defines the gravity vector to use
  101671. */
  101672. setGravity(gravity: Vector3): void;
  101673. /**
  101674. * Set the time step of the physics engine.
  101675. * Default is 1/60.
  101676. * To slow it down, enter 1/600 for example.
  101677. * To speed it up, 1/30
  101678. * @param newTimeStep defines the new timestep to apply to this world.
  101679. */
  101680. setTimeStep(newTimeStep?: number): void;
  101681. /**
  101682. * Get the time step of the physics engine.
  101683. * @returns the current time step
  101684. */
  101685. getTimeStep(): number;
  101686. /**
  101687. * Release all resources
  101688. */
  101689. dispose(): void;
  101690. /**
  101691. * Gets the name of the current physics plugin
  101692. * @returns the name of the plugin
  101693. */
  101694. getPhysicsPluginName(): string;
  101695. /**
  101696. * Adding a new impostor for the impostor tracking.
  101697. * This will be done by the impostor itself.
  101698. * @param impostor the impostor to add
  101699. */
  101700. addImpostor(impostor: PhysicsImpostor): void;
  101701. /**
  101702. * Remove an impostor from the engine.
  101703. * This impostor and its mesh will not longer be updated by the physics engine.
  101704. * @param impostor the impostor to remove
  101705. */
  101706. removeImpostor(impostor: PhysicsImpostor): void;
  101707. /**
  101708. * Add a joint to the physics engine
  101709. * @param mainImpostor defines the main impostor to which the joint is added.
  101710. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  101711. * @param joint defines the joint that will connect both impostors.
  101712. */
  101713. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101714. /**
  101715. * Removes a joint from the simulation
  101716. * @param mainImpostor defines the impostor used with the joint
  101717. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  101718. * @param joint defines the joint to remove
  101719. */
  101720. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101721. /**
  101722. * Called by the scene. No need to call it.
  101723. * @param delta defines the timespam between frames
  101724. */
  101725. _step(delta: number): void;
  101726. /**
  101727. * Gets the current plugin used to run the simulation
  101728. * @returns current plugin
  101729. */
  101730. getPhysicsPlugin(): IPhysicsEnginePlugin;
  101731. /**
  101732. * Gets the list of physic impostors
  101733. * @returns an array of PhysicsImpostor
  101734. */
  101735. getImpostors(): Array<PhysicsImpostor>;
  101736. /**
  101737. * Gets the impostor for a physics enabled object
  101738. * @param object defines the object impersonated by the impostor
  101739. * @returns the PhysicsImpostor or null if not found
  101740. */
  101741. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  101742. /**
  101743. * Gets the impostor for a physics body object
  101744. * @param body defines physics body used by the impostor
  101745. * @returns the PhysicsImpostor or null if not found
  101746. */
  101747. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  101748. }
  101749. }
  101750. declare module BABYLON {
  101751. /** @hidden */
  101752. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  101753. private _useDeltaForWorldStep;
  101754. world: any;
  101755. name: string;
  101756. private _physicsMaterials;
  101757. private _fixedTimeStep;
  101758. BJSCANNON: any;
  101759. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  101760. setGravity(gravity: Vector3): void;
  101761. setTimeStep(timeStep: number): void;
  101762. getTimeStep(): number;
  101763. executeStep(delta: number): void;
  101764. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101765. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101766. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101767. private _processChildMeshes;
  101768. removePhysicsBody(impostor: PhysicsImpostor): void;
  101769. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101770. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101771. private _addMaterial;
  101772. private _checkWithEpsilon;
  101773. private _createShape;
  101774. private _createHeightmap;
  101775. private _minus90X;
  101776. private _plus90X;
  101777. private _tmpPosition;
  101778. private _tmpDeltaPosition;
  101779. private _tmpUnityRotation;
  101780. private _updatePhysicsBodyTransformation;
  101781. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101782. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101783. isSupported(): boolean;
  101784. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101785. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101786. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101787. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101788. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101789. getBodyMass(impostor: PhysicsImpostor): number;
  101790. getBodyFriction(impostor: PhysicsImpostor): number;
  101791. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101792. getBodyRestitution(impostor: PhysicsImpostor): number;
  101793. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101794. sleepBody(impostor: PhysicsImpostor): void;
  101795. wakeUpBody(impostor: PhysicsImpostor): void;
  101796. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  101797. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  101798. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  101799. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101800. getRadius(impostor: PhysicsImpostor): number;
  101801. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101802. dispose(): void;
  101803. private _extendNamespace;
  101804. }
  101805. }
  101806. declare module BABYLON {
  101807. /** @hidden */
  101808. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  101809. world: any;
  101810. name: string;
  101811. BJSOIMO: any;
  101812. constructor(iterations?: number, oimoInjection?: any);
  101813. setGravity(gravity: Vector3): void;
  101814. setTimeStep(timeStep: number): void;
  101815. getTimeStep(): number;
  101816. private _tmpImpostorsArray;
  101817. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  101818. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101819. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101820. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101821. private _tmpPositionVector;
  101822. removePhysicsBody(impostor: PhysicsImpostor): void;
  101823. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101824. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101825. isSupported(): boolean;
  101826. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101827. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101828. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101829. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101830. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101831. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101832. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101833. getBodyMass(impostor: PhysicsImpostor): number;
  101834. getBodyFriction(impostor: PhysicsImpostor): number;
  101835. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101836. getBodyRestitution(impostor: PhysicsImpostor): number;
  101837. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101838. sleepBody(impostor: PhysicsImpostor): void;
  101839. wakeUpBody(impostor: PhysicsImpostor): void;
  101840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  101841. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  101842. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  101843. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101844. getRadius(impostor: PhysicsImpostor): number;
  101845. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101846. dispose(): void;
  101847. }
  101848. }
  101849. declare module BABYLON {
  101850. interface AbstractScene {
  101851. /**
  101852. * The list of reflection probes added to the scene
  101853. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101854. */
  101855. reflectionProbes: Array<ReflectionProbe>;
  101856. /**
  101857. * Removes the given reflection probe from this scene.
  101858. * @param toRemove The reflection probe to remove
  101859. * @returns The index of the removed reflection probe
  101860. */
  101861. removeReflectionProbe(toRemove: ReflectionProbe): number;
  101862. /**
  101863. * Adds the given reflection probe to this scene.
  101864. * @param newReflectionProbe The reflection probe to add
  101865. */
  101866. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  101867. }
  101868. /**
  101869. * Class used to generate realtime reflection / refraction cube textures
  101870. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101871. */
  101872. export class ReflectionProbe {
  101873. /** defines the name of the probe */
  101874. name: string;
  101875. private _scene;
  101876. private _renderTargetTexture;
  101877. private _projectionMatrix;
  101878. private _viewMatrix;
  101879. private _target;
  101880. private _add;
  101881. private _attachedMesh;
  101882. private _invertYAxis;
  101883. /** Gets or sets probe position (center of the cube map) */
  101884. position: Vector3;
  101885. /**
  101886. * Creates a new reflection probe
  101887. * @param name defines the name of the probe
  101888. * @param size defines the texture resolution (for each face)
  101889. * @param scene defines the hosting scene
  101890. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  101891. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  101892. */
  101893. constructor(
  101894. /** defines the name of the probe */
  101895. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  101896. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  101897. samples: number;
  101898. /** Gets or sets the refresh rate to use (on every frame by default) */
  101899. refreshRate: number;
  101900. /**
  101901. * Gets the hosting scene
  101902. * @returns a Scene
  101903. */
  101904. getScene(): Scene;
  101905. /** Gets the internal CubeTexture used to render to */
  101906. readonly cubeTexture: RenderTargetTexture;
  101907. /** Gets the list of meshes to render */
  101908. readonly renderList: Nullable<AbstractMesh[]>;
  101909. /**
  101910. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  101911. * @param mesh defines the mesh to attach to
  101912. */
  101913. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101914. /**
  101915. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  101916. * @param renderingGroupId The rendering group id corresponding to its index
  101917. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101918. */
  101919. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101920. /**
  101921. * Clean all associated resources
  101922. */
  101923. dispose(): void;
  101924. /**
  101925. * Converts the reflection probe information to a readable string for debug purpose.
  101926. * @param fullDetails Supports for multiple levels of logging within scene loading
  101927. * @returns the human readable reflection probe info
  101928. */
  101929. toString(fullDetails?: boolean): string;
  101930. /**
  101931. * Get the class name of the relfection probe.
  101932. * @returns "ReflectionProbe"
  101933. */
  101934. getClassName(): string;
  101935. /**
  101936. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  101937. * @returns The JSON representation of the texture
  101938. */
  101939. serialize(): any;
  101940. /**
  101941. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  101942. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  101943. * @param scene Define the scene the parsed reflection probe should be instantiated in
  101944. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101945. * @returns The parsed reflection probe if successful
  101946. */
  101947. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  101948. }
  101949. }
  101950. declare module BABYLON {
  101951. /** @hidden */
  101952. export var _BabylonLoaderRegistered: boolean;
  101953. }
  101954. declare module BABYLON {
  101955. /**
  101956. * The Physically based simple base material of BJS.
  101957. *
  101958. * This enables better naming and convention enforcements on top of the pbrMaterial.
  101959. * It is used as the base class for both the specGloss and metalRough conventions.
  101960. */
  101961. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  101962. /**
  101963. * Number of Simultaneous lights allowed on the material.
  101964. */
  101965. maxSimultaneousLights: number;
  101966. /**
  101967. * If sets to true, disables all the lights affecting the material.
  101968. */
  101969. disableLighting: boolean;
  101970. /**
  101971. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  101972. */
  101973. environmentTexture: BaseTexture;
  101974. /**
  101975. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101976. */
  101977. invertNormalMapX: boolean;
  101978. /**
  101979. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101980. */
  101981. invertNormalMapY: boolean;
  101982. /**
  101983. * Normal map used in the model.
  101984. */
  101985. normalTexture: BaseTexture;
  101986. /**
  101987. * Emissivie color used to self-illuminate the model.
  101988. */
  101989. emissiveColor: Color3;
  101990. /**
  101991. * Emissivie texture used to self-illuminate the model.
  101992. */
  101993. emissiveTexture: BaseTexture;
  101994. /**
  101995. * Occlusion Channel Strenght.
  101996. */
  101997. occlusionStrength: number;
  101998. /**
  101999. * Occlusion Texture of the material (adding extra occlusion effects).
  102000. */
  102001. occlusionTexture: BaseTexture;
  102002. /**
  102003. * Defines the alpha limits in alpha test mode.
  102004. */
  102005. alphaCutOff: number;
  102006. /**
  102007. * Gets the current double sided mode.
  102008. */
  102009. /**
  102010. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102011. */
  102012. doubleSided: boolean;
  102013. /**
  102014. * Stores the pre-calculated light information of a mesh in a texture.
  102015. */
  102016. lightmapTexture: BaseTexture;
  102017. /**
  102018. * If true, the light map contains occlusion information instead of lighting info.
  102019. */
  102020. useLightmapAsShadowmap: boolean;
  102021. /**
  102022. * Return the active textures of the material.
  102023. */
  102024. getActiveTextures(): BaseTexture[];
  102025. hasTexture(texture: BaseTexture): boolean;
  102026. /**
  102027. * Instantiates a new PBRMaterial instance.
  102028. *
  102029. * @param name The material name
  102030. * @param scene The scene the material will be use in.
  102031. */
  102032. constructor(name: string, scene: Scene);
  102033. getClassName(): string;
  102034. }
  102035. }
  102036. declare module BABYLON {
  102037. /**
  102038. * The PBR material of BJS following the metal roughness convention.
  102039. *
  102040. * This fits to the PBR convention in the GLTF definition:
  102041. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  102042. */
  102043. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  102044. /**
  102045. * The base color has two different interpretations depending on the value of metalness.
  102046. * When the material is a metal, the base color is the specific measured reflectance value
  102047. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  102048. * of the material.
  102049. */
  102050. baseColor: Color3;
  102051. /**
  102052. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  102053. * well as opacity information in the alpha channel.
  102054. */
  102055. baseTexture: BaseTexture;
  102056. /**
  102057. * Specifies the metallic scalar value of the material.
  102058. * Can also be used to scale the metalness values of the metallic texture.
  102059. */
  102060. metallic: number;
  102061. /**
  102062. * Specifies the roughness scalar value of the material.
  102063. * Can also be used to scale the roughness values of the metallic texture.
  102064. */
  102065. roughness: number;
  102066. /**
  102067. * Texture containing both the metallic value in the B channel and the
  102068. * roughness value in the G channel to keep better precision.
  102069. */
  102070. metallicRoughnessTexture: BaseTexture;
  102071. /**
  102072. * Instantiates a new PBRMetalRoughnessMaterial instance.
  102073. *
  102074. * @param name The material name
  102075. * @param scene The scene the material will be use in.
  102076. */
  102077. constructor(name: string, scene: Scene);
  102078. /**
  102079. * Return the currrent class name of the material.
  102080. */
  102081. getClassName(): string;
  102082. /**
  102083. * Return the active textures of the material.
  102084. */
  102085. getActiveTextures(): BaseTexture[];
  102086. /**
  102087. * Checks to see if a texture is used in the material.
  102088. * @param texture - Base texture to use.
  102089. * @returns - Boolean specifying if a texture is used in the material.
  102090. */
  102091. hasTexture(texture: BaseTexture): boolean;
  102092. /**
  102093. * Makes a duplicate of the current material.
  102094. * @param name - name to use for the new material.
  102095. */
  102096. clone(name: string): PBRMetallicRoughnessMaterial;
  102097. /**
  102098. * Serialize the material to a parsable JSON object.
  102099. */
  102100. serialize(): any;
  102101. /**
  102102. * Parses a JSON object correponding to the serialize function.
  102103. */
  102104. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102105. }
  102106. }
  102107. declare module BABYLON {
  102108. /**
  102109. * The PBR material of BJS following the specular glossiness convention.
  102110. *
  102111. * This fits to the PBR convention in the GLTF definition:
  102112. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102113. */
  102114. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102115. /**
  102116. * Specifies the diffuse color of the material.
  102117. */
  102118. diffuseColor: Color3;
  102119. /**
  102120. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102121. * channel.
  102122. */
  102123. diffuseTexture: BaseTexture;
  102124. /**
  102125. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102126. */
  102127. specularColor: Color3;
  102128. /**
  102129. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102130. */
  102131. glossiness: number;
  102132. /**
  102133. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102134. */
  102135. specularGlossinessTexture: BaseTexture;
  102136. /**
  102137. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102138. *
  102139. * @param name The material name
  102140. * @param scene The scene the material will be use in.
  102141. */
  102142. constructor(name: string, scene: Scene);
  102143. /**
  102144. * Return the currrent class name of the material.
  102145. */
  102146. getClassName(): string;
  102147. /**
  102148. * Return the active textures of the material.
  102149. */
  102150. getActiveTextures(): BaseTexture[];
  102151. /**
  102152. * Checks to see if a texture is used in the material.
  102153. * @param texture - Base texture to use.
  102154. * @returns - Boolean specifying if a texture is used in the material.
  102155. */
  102156. hasTexture(texture: BaseTexture): boolean;
  102157. /**
  102158. * Makes a duplicate of the current material.
  102159. * @param name - name to use for the new material.
  102160. */
  102161. clone(name: string): PBRSpecularGlossinessMaterial;
  102162. /**
  102163. * Serialize the material to a parsable JSON object.
  102164. */
  102165. serialize(): any;
  102166. /**
  102167. * Parses a JSON object correponding to the serialize function.
  102168. */
  102169. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102170. }
  102171. }
  102172. declare module BABYLON {
  102173. /**
  102174. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102175. * It can help converting any input color in a desired output one. This can then be used to create effects
  102176. * from sepia, black and white to sixties or futuristic rendering...
  102177. *
  102178. * The only supported format is currently 3dl.
  102179. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102180. */
  102181. export class ColorGradingTexture extends BaseTexture {
  102182. /**
  102183. * The current texture matrix. (will always be identity in color grading texture)
  102184. */
  102185. private _textureMatrix;
  102186. /**
  102187. * The texture URL.
  102188. */
  102189. url: string;
  102190. /**
  102191. * Empty line regex stored for GC.
  102192. */
  102193. private static _noneEmptyLineRegex;
  102194. private _engine;
  102195. /**
  102196. * Instantiates a ColorGradingTexture from the following parameters.
  102197. *
  102198. * @param url The location of the color gradind data (currently only supporting 3dl)
  102199. * @param scene The scene the texture will be used in
  102200. */
  102201. constructor(url: string, scene: Scene);
  102202. /**
  102203. * Returns the texture matrix used in most of the material.
  102204. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102205. */
  102206. getTextureMatrix(): Matrix;
  102207. /**
  102208. * Occurs when the file being loaded is a .3dl LUT file.
  102209. */
  102210. private load3dlTexture;
  102211. /**
  102212. * Starts the loading process of the texture.
  102213. */
  102214. private loadTexture;
  102215. /**
  102216. * Clones the color gradind texture.
  102217. */
  102218. clone(): ColorGradingTexture;
  102219. /**
  102220. * Called during delayed load for textures.
  102221. */
  102222. delayLoad(): void;
  102223. /**
  102224. * Parses a color grading texture serialized by Babylon.
  102225. * @param parsedTexture The texture information being parsedTexture
  102226. * @param scene The scene to load the texture in
  102227. * @param rootUrl The root url of the data assets to load
  102228. * @return A color gradind texture
  102229. */
  102230. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102231. /**
  102232. * Serializes the LUT texture to json format.
  102233. */
  102234. serialize(): any;
  102235. }
  102236. }
  102237. declare module BABYLON {
  102238. /**
  102239. * Direct draw surface info
  102240. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102241. */
  102242. export interface DDSInfo {
  102243. /**
  102244. * Width of the texture
  102245. */
  102246. width: number;
  102247. /**
  102248. * Width of the texture
  102249. */
  102250. height: number;
  102251. /**
  102252. * Number of Mipmaps for the texture
  102253. * @see https://en.wikipedia.org/wiki/Mipmap
  102254. */
  102255. mipmapCount: number;
  102256. /**
  102257. * If the textures format is a known fourCC format
  102258. * @see https://www.fourcc.org/
  102259. */
  102260. isFourCC: boolean;
  102261. /**
  102262. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102263. */
  102264. isRGB: boolean;
  102265. /**
  102266. * If the texture is a lumincance format
  102267. */
  102268. isLuminance: boolean;
  102269. /**
  102270. * If this is a cube texture
  102271. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102272. */
  102273. isCube: boolean;
  102274. /**
  102275. * If the texture is a compressed format eg. FOURCC_DXT1
  102276. */
  102277. isCompressed: boolean;
  102278. /**
  102279. * The dxgiFormat of the texture
  102280. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102281. */
  102282. dxgiFormat: number;
  102283. /**
  102284. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102285. */
  102286. textureType: number;
  102287. /**
  102288. * Sphericle polynomial created for the dds texture
  102289. */
  102290. sphericalPolynomial?: SphericalPolynomial;
  102291. }
  102292. /**
  102293. * Class used to provide DDS decompression tools
  102294. */
  102295. export class DDSTools {
  102296. /**
  102297. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102298. */
  102299. static StoreLODInAlphaChannel: boolean;
  102300. /**
  102301. * Gets DDS information from an array buffer
  102302. * @param arrayBuffer defines the array buffer to read data from
  102303. * @returns the DDS information
  102304. */
  102305. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102306. private static _FloatView;
  102307. private static _Int32View;
  102308. private static _ToHalfFloat;
  102309. private static _FromHalfFloat;
  102310. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102311. private static _GetHalfFloatRGBAArrayBuffer;
  102312. private static _GetFloatRGBAArrayBuffer;
  102313. private static _GetFloatAsUIntRGBAArrayBuffer;
  102314. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102315. private static _GetRGBAArrayBuffer;
  102316. private static _ExtractLongWordOrder;
  102317. private static _GetRGBArrayBuffer;
  102318. private static _GetLuminanceArrayBuffer;
  102319. /**
  102320. * Uploads DDS Levels to a Babylon Texture
  102321. * @hidden
  102322. */
  102323. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102324. }
  102325. interface Engine {
  102326. /**
  102327. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102328. * @param rootUrl defines the url where the file to load is located
  102329. * @param scene defines the current scene
  102330. * @param lodScale defines scale to apply to the mip map selection
  102331. * @param lodOffset defines offset to apply to the mip map selection
  102332. * @param onLoad defines an optional callback raised when the texture is loaded
  102333. * @param onError defines an optional callback raised if there is an issue to load the texture
  102334. * @param format defines the format of the data
  102335. * @param forcedExtension defines the extension to use to pick the right loader
  102336. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102337. * @returns the cube texture as an InternalTexture
  102338. */
  102339. 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;
  102340. }
  102341. }
  102342. declare module BABYLON {
  102343. /**
  102344. * Implementation of the DDS Texture Loader.
  102345. * @hidden
  102346. */
  102347. export class _DDSTextureLoader implements IInternalTextureLoader {
  102348. /**
  102349. * Defines wether the loader supports cascade loading the different faces.
  102350. */
  102351. readonly supportCascades: boolean;
  102352. /**
  102353. * This returns if the loader support the current file information.
  102354. * @param extension defines the file extension of the file being loaded
  102355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102356. * @param fallback defines the fallback internal texture if any
  102357. * @param isBase64 defines whether the texture is encoded as a base64
  102358. * @param isBuffer defines whether the texture data are stored as a buffer
  102359. * @returns true if the loader can load the specified file
  102360. */
  102361. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102362. /**
  102363. * Transform the url before loading if required.
  102364. * @param rootUrl the url of the texture
  102365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102366. * @returns the transformed texture
  102367. */
  102368. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102369. /**
  102370. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102371. * @param rootUrl the url of the texture
  102372. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102373. * @returns the fallback texture
  102374. */
  102375. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102376. /**
  102377. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102378. * @param data contains the texture data
  102379. * @param texture defines the BabylonJS internal texture
  102380. * @param createPolynomials will be true if polynomials have been requested
  102381. * @param onLoad defines the callback to trigger once the texture is ready
  102382. * @param onError defines the callback to trigger in case of error
  102383. */
  102384. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102385. /**
  102386. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102387. * @param data contains the texture data
  102388. * @param texture defines the BabylonJS internal texture
  102389. * @param callback defines the method to call once ready to upload
  102390. */
  102391. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102392. }
  102393. }
  102394. declare module BABYLON {
  102395. /** @hidden */
  102396. export var rgbdEncodePixelShader: {
  102397. name: string;
  102398. shader: string;
  102399. };
  102400. }
  102401. declare module BABYLON {
  102402. /** @hidden */
  102403. export var rgbdDecodePixelShader: {
  102404. name: string;
  102405. shader: string;
  102406. };
  102407. }
  102408. declare module BABYLON {
  102409. /**
  102410. * Raw texture data and descriptor sufficient for WebGL texture upload
  102411. */
  102412. export interface EnvironmentTextureInfo {
  102413. /**
  102414. * Version of the environment map
  102415. */
  102416. version: number;
  102417. /**
  102418. * Width of image
  102419. */
  102420. width: number;
  102421. /**
  102422. * Irradiance information stored in the file.
  102423. */
  102424. irradiance: any;
  102425. /**
  102426. * Specular information stored in the file.
  102427. */
  102428. specular: any;
  102429. }
  102430. /**
  102431. * Sets of helpers addressing the serialization and deserialization of environment texture
  102432. * stored in a BabylonJS env file.
  102433. * Those files are usually stored as .env files.
  102434. */
  102435. export class EnvironmentTextureTools {
  102436. /**
  102437. * Magic number identifying the env file.
  102438. */
  102439. private static _MagicBytes;
  102440. /**
  102441. * Gets the environment info from an env file.
  102442. * @param data The array buffer containing the .env bytes.
  102443. * @returns the environment file info (the json header) if successfully parsed.
  102444. */
  102445. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102446. /**
  102447. * Creates an environment texture from a loaded cube texture.
  102448. * @param texture defines the cube texture to convert in env file
  102449. * @return a promise containing the environment data if succesfull.
  102450. */
  102451. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102452. /**
  102453. * Creates a JSON representation of the spherical data.
  102454. * @param texture defines the texture containing the polynomials
  102455. * @return the JSON representation of the spherical info
  102456. */
  102457. private static _CreateEnvTextureIrradiance;
  102458. /**
  102459. * Uploads the texture info contained in the env file to the GPU.
  102460. * @param texture defines the internal texture to upload to
  102461. * @param arrayBuffer defines the buffer cotaining the data to load
  102462. * @param info defines the texture info retrieved through the GetEnvInfo method
  102463. * @returns a promise
  102464. */
  102465. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102466. /**
  102467. * Uploads the levels of image data to the GPU.
  102468. * @param texture defines the internal texture to upload to
  102469. * @param imageData defines the array buffer views of image data [mipmap][face]
  102470. * @returns a promise
  102471. */
  102472. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102473. /**
  102474. * Uploads spherical polynomials information to the texture.
  102475. * @param texture defines the texture we are trying to upload the information to
  102476. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102477. */
  102478. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102479. /** @hidden */
  102480. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102481. }
  102482. }
  102483. declare module BABYLON {
  102484. /**
  102485. * Implementation of the ENV Texture Loader.
  102486. * @hidden
  102487. */
  102488. export class _ENVTextureLoader implements IInternalTextureLoader {
  102489. /**
  102490. * Defines wether the loader supports cascade loading the different faces.
  102491. */
  102492. readonly supportCascades: boolean;
  102493. /**
  102494. * This returns if the loader support the current file information.
  102495. * @param extension defines the file extension of the file being loaded
  102496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102497. * @param fallback defines the fallback internal texture if any
  102498. * @param isBase64 defines whether the texture is encoded as a base64
  102499. * @param isBuffer defines whether the texture data are stored as a buffer
  102500. * @returns true if the loader can load the specified file
  102501. */
  102502. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102503. /**
  102504. * Transform the url before loading if required.
  102505. * @param rootUrl the url of the texture
  102506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102507. * @returns the transformed texture
  102508. */
  102509. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102510. /**
  102511. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102512. * @param rootUrl the url of the texture
  102513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102514. * @returns the fallback texture
  102515. */
  102516. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102517. /**
  102518. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102519. * @param data contains the texture data
  102520. * @param texture defines the BabylonJS internal texture
  102521. * @param createPolynomials will be true if polynomials have been requested
  102522. * @param onLoad defines the callback to trigger once the texture is ready
  102523. * @param onError defines the callback to trigger in case of error
  102524. */
  102525. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102526. /**
  102527. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102528. * @param data contains the texture data
  102529. * @param texture defines the BabylonJS internal texture
  102530. * @param callback defines the method to call once ready to upload
  102531. */
  102532. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102533. }
  102534. }
  102535. declare module BABYLON {
  102536. /**
  102537. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102538. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102539. */
  102540. export class KhronosTextureContainer {
  102541. /** contents of the KTX container file */
  102542. arrayBuffer: any;
  102543. private static HEADER_LEN;
  102544. private static COMPRESSED_2D;
  102545. private static COMPRESSED_3D;
  102546. private static TEX_2D;
  102547. private static TEX_3D;
  102548. /**
  102549. * Gets the openGL type
  102550. */
  102551. glType: number;
  102552. /**
  102553. * Gets the openGL type size
  102554. */
  102555. glTypeSize: number;
  102556. /**
  102557. * Gets the openGL format
  102558. */
  102559. glFormat: number;
  102560. /**
  102561. * Gets the openGL internal format
  102562. */
  102563. glInternalFormat: number;
  102564. /**
  102565. * Gets the base internal format
  102566. */
  102567. glBaseInternalFormat: number;
  102568. /**
  102569. * Gets image width in pixel
  102570. */
  102571. pixelWidth: number;
  102572. /**
  102573. * Gets image height in pixel
  102574. */
  102575. pixelHeight: number;
  102576. /**
  102577. * Gets image depth in pixels
  102578. */
  102579. pixelDepth: number;
  102580. /**
  102581. * Gets the number of array elements
  102582. */
  102583. numberOfArrayElements: number;
  102584. /**
  102585. * Gets the number of faces
  102586. */
  102587. numberOfFaces: number;
  102588. /**
  102589. * Gets the number of mipmap levels
  102590. */
  102591. numberOfMipmapLevels: number;
  102592. /**
  102593. * Gets the bytes of key value data
  102594. */
  102595. bytesOfKeyValueData: number;
  102596. /**
  102597. * Gets the load type
  102598. */
  102599. loadType: number;
  102600. /**
  102601. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102602. */
  102603. isInvalid: boolean;
  102604. /**
  102605. * Creates a new KhronosTextureContainer
  102606. * @param arrayBuffer contents of the KTX container file
  102607. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102608. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102609. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102610. */
  102611. constructor(
  102612. /** contents of the KTX container file */
  102613. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102614. /**
  102615. * Uploads KTX content to a Babylon Texture.
  102616. * It is assumed that the texture has already been created & is currently bound
  102617. * @hidden
  102618. */
  102619. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102620. private _upload2DCompressedLevels;
  102621. }
  102622. }
  102623. declare module BABYLON {
  102624. /**
  102625. * Implementation of the KTX Texture Loader.
  102626. * @hidden
  102627. */
  102628. export class _KTXTextureLoader implements IInternalTextureLoader {
  102629. /**
  102630. * Defines wether the loader supports cascade loading the different faces.
  102631. */
  102632. readonly supportCascades: boolean;
  102633. /**
  102634. * This returns if the loader support the current file information.
  102635. * @param extension defines the file extension of the file being loaded
  102636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102637. * @param fallback defines the fallback internal texture if any
  102638. * @param isBase64 defines whether the texture is encoded as a base64
  102639. * @param isBuffer defines whether the texture data are stored as a buffer
  102640. * @returns true if the loader can load the specified file
  102641. */
  102642. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102643. /**
  102644. * Transform the url before loading if required.
  102645. * @param rootUrl the url of the texture
  102646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102647. * @returns the transformed texture
  102648. */
  102649. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102650. /**
  102651. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102652. * @param rootUrl the url of the texture
  102653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102654. * @returns the fallback texture
  102655. */
  102656. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102657. /**
  102658. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102659. * @param data contains the texture data
  102660. * @param texture defines the BabylonJS internal texture
  102661. * @param createPolynomials will be true if polynomials have been requested
  102662. * @param onLoad defines the callback to trigger once the texture is ready
  102663. * @param onError defines the callback to trigger in case of error
  102664. */
  102665. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102666. /**
  102667. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102668. * @param data contains the texture data
  102669. * @param texture defines the BabylonJS internal texture
  102670. * @param callback defines the method to call once ready to upload
  102671. */
  102672. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102673. }
  102674. }
  102675. declare module BABYLON {
  102676. /**
  102677. * Based on jsTGALoader - Javascript loader for TGA file
  102678. * By Vincent Thibault
  102679. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102680. */
  102681. export class TGATools {
  102682. private static _TYPE_INDEXED;
  102683. private static _TYPE_RGB;
  102684. private static _TYPE_GREY;
  102685. private static _TYPE_RLE_INDEXED;
  102686. private static _TYPE_RLE_RGB;
  102687. private static _TYPE_RLE_GREY;
  102688. private static _ORIGIN_MASK;
  102689. private static _ORIGIN_SHIFT;
  102690. private static _ORIGIN_BL;
  102691. private static _ORIGIN_BR;
  102692. private static _ORIGIN_UL;
  102693. private static _ORIGIN_UR;
  102694. /**
  102695. * Gets the header of a TGA file
  102696. * @param data defines the TGA data
  102697. * @returns the header
  102698. */
  102699. static GetTGAHeader(data: Uint8Array): any;
  102700. /**
  102701. * Uploads TGA content to a Babylon Texture
  102702. * @hidden
  102703. */
  102704. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  102705. /** @hidden */
  102706. 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;
  102707. /** @hidden */
  102708. 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;
  102709. /** @hidden */
  102710. 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;
  102711. /** @hidden */
  102712. 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;
  102713. /** @hidden */
  102714. 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;
  102715. /** @hidden */
  102716. 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;
  102717. }
  102718. }
  102719. declare module BABYLON {
  102720. /**
  102721. * Implementation of the TGA Texture Loader.
  102722. * @hidden
  102723. */
  102724. export class _TGATextureLoader implements IInternalTextureLoader {
  102725. /**
  102726. * Defines wether the loader supports cascade loading the different faces.
  102727. */
  102728. readonly supportCascades: boolean;
  102729. /**
  102730. * This returns if the loader support the current file information.
  102731. * @param extension defines the file extension of the file being loaded
  102732. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102733. * @param fallback defines the fallback internal texture if any
  102734. * @param isBase64 defines whether the texture is encoded as a base64
  102735. * @param isBuffer defines whether the texture data are stored as a buffer
  102736. * @returns true if the loader can load the specified file
  102737. */
  102738. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102739. /**
  102740. * Transform the url before loading if required.
  102741. * @param rootUrl the url of the texture
  102742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102743. * @returns the transformed texture
  102744. */
  102745. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102746. /**
  102747. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102748. * @param rootUrl the url of the texture
  102749. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102750. * @returns the fallback texture
  102751. */
  102752. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102753. /**
  102754. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102755. * @param data contains the texture data
  102756. * @param texture defines the BabylonJS internal texture
  102757. * @param createPolynomials will be true if polynomials have been requested
  102758. * @param onLoad defines the callback to trigger once the texture is ready
  102759. * @param onError defines the callback to trigger in case of error
  102760. */
  102761. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102762. /**
  102763. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102764. * @param data contains the texture data
  102765. * @param texture defines the BabylonJS internal texture
  102766. * @param callback defines the method to call once ready to upload
  102767. */
  102768. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102769. }
  102770. }
  102771. declare module BABYLON {
  102772. /**
  102773. * 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.
  102774. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102775. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102776. */
  102777. export class CustomProceduralTexture extends ProceduralTexture {
  102778. private _animate;
  102779. private _time;
  102780. private _config;
  102781. private _texturePath;
  102782. /**
  102783. * Instantiates a new Custom Procedural Texture.
  102784. * 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.
  102785. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102786. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102787. * @param name Define the name of the texture
  102788. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  102789. * @param size Define the size of the texture to create
  102790. * @param scene Define the scene the texture belongs to
  102791. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  102792. * @param generateMipMaps Define if the texture should creates mip maps or not
  102793. */
  102794. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102795. private _loadJson;
  102796. /**
  102797. * Is the texture ready to be used ? (rendered at least once)
  102798. * @returns true if ready, otherwise, false.
  102799. */
  102800. isReady(): boolean;
  102801. /**
  102802. * Render the texture to its associated render target.
  102803. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  102804. */
  102805. render(useCameraPostProcess?: boolean): void;
  102806. /**
  102807. * Update the list of dependant textures samplers in the shader.
  102808. */
  102809. updateTextures(): void;
  102810. /**
  102811. * Update the uniform values of the procedural texture in the shader.
  102812. */
  102813. updateShaderUniforms(): void;
  102814. /**
  102815. * Define if the texture animates or not.
  102816. */
  102817. animate: boolean;
  102818. }
  102819. }
  102820. declare module BABYLON {
  102821. /** @hidden */
  102822. export var noisePixelShader: {
  102823. name: string;
  102824. shader: string;
  102825. };
  102826. }
  102827. declare module BABYLON {
  102828. /**
  102829. * Class used to generate noise procedural textures
  102830. */
  102831. export class NoiseProceduralTexture extends ProceduralTexture {
  102832. private _time;
  102833. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  102834. brightness: number;
  102835. /** Defines the number of octaves to process */
  102836. octaves: number;
  102837. /** Defines the level of persistence (0.8 by default) */
  102838. persistence: number;
  102839. /** Gets or sets animation speed factor (default is 1) */
  102840. animationSpeedFactor: number;
  102841. /**
  102842. * Creates a new NoiseProceduralTexture
  102843. * @param name defines the name fo the texture
  102844. * @param size defines the size of the texture (default is 256)
  102845. * @param scene defines the hosting scene
  102846. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  102847. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  102848. */
  102849. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102850. private _updateShaderUniforms;
  102851. protected _getDefines(): string;
  102852. /** Generate the current state of the procedural texture */
  102853. render(useCameraPostProcess?: boolean): void;
  102854. /**
  102855. * Serializes this noise procedural texture
  102856. * @returns a serialized noise procedural texture object
  102857. */
  102858. serialize(): any;
  102859. /**
  102860. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  102861. * @param parsedTexture defines parsed texture data
  102862. * @param scene defines the current scene
  102863. * @param rootUrl defines the root URL containing noise procedural texture information
  102864. * @returns a parsed NoiseProceduralTexture
  102865. */
  102866. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  102867. }
  102868. }
  102869. declare module BABYLON {
  102870. /**
  102871. * Raw cube texture where the raw buffers are passed in
  102872. */
  102873. export class RawCubeTexture extends CubeTexture {
  102874. /**
  102875. * Creates a cube texture where the raw buffers are passed in.
  102876. * @param scene defines the scene the texture is attached to
  102877. * @param data defines the array of data to use to create each face
  102878. * @param size defines the size of the textures
  102879. * @param format defines the format of the data
  102880. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102881. * @param generateMipMaps defines if the engine should generate the mip levels
  102882. * @param invertY defines if data must be stored with Y axis inverted
  102883. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102884. * @param compression defines the compression used (null by default)
  102885. */
  102886. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  102887. /**
  102888. * Updates the raw cube texture.
  102889. * @param data defines the data to store
  102890. * @param format defines the data format
  102891. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102892. * @param invertY defines if data must be stored with Y axis inverted
  102893. * @param compression defines the compression used (null by default)
  102894. * @param level defines which level of the texture to update
  102895. */
  102896. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  102897. /**
  102898. * Updates a raw cube texture with RGBD encoded data.
  102899. * @param data defines the array of data [mipmap][face] to use to create each face
  102900. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  102901. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  102902. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  102903. * @returns a promsie that resolves when the operation is complete
  102904. */
  102905. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  102906. /**
  102907. * Clones the raw cube texture.
  102908. * @return a new cube texture
  102909. */
  102910. clone(): CubeTexture;
  102911. /** @hidden */
  102912. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102913. }
  102914. }
  102915. declare module BABYLON {
  102916. /**
  102917. * Class used to store 3D textures containing user data
  102918. */
  102919. export class RawTexture3D extends Texture {
  102920. /** Gets or sets the texture format to use */
  102921. format: number;
  102922. private _engine;
  102923. /**
  102924. * Create a new RawTexture3D
  102925. * @param data defines the data of the texture
  102926. * @param width defines the width of the texture
  102927. * @param height defines the height of the texture
  102928. * @param depth defines the depth of the texture
  102929. * @param format defines the texture format to use
  102930. * @param scene defines the hosting scene
  102931. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  102932. * @param invertY defines if texture must be stored with Y axis inverted
  102933. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  102934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  102935. */
  102936. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  102937. /** Gets or sets the texture format to use */
  102938. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  102939. /**
  102940. * Update the texture with new data
  102941. * @param data defines the data to store in the texture
  102942. */
  102943. update(data: ArrayBufferView): void;
  102944. }
  102945. }
  102946. declare module BABYLON {
  102947. /**
  102948. * Creates a refraction texture used by refraction channel of the standard material.
  102949. * It is like a mirror but to see through a material.
  102950. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102951. */
  102952. export class RefractionTexture extends RenderTargetTexture {
  102953. /**
  102954. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  102955. * 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.
  102956. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102957. */
  102958. refractionPlane: Plane;
  102959. /**
  102960. * Define how deep under the surface we should see.
  102961. */
  102962. depth: number;
  102963. /**
  102964. * Creates a refraction texture used by refraction channel of the standard material.
  102965. * It is like a mirror but to see through a material.
  102966. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102967. * @param name Define the texture name
  102968. * @param size Define the size of the underlying texture
  102969. * @param scene Define the scene the refraction belongs to
  102970. * @param generateMipMaps Define if we need to generate mips level for the refraction
  102971. */
  102972. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  102973. /**
  102974. * Clone the refraction texture.
  102975. * @returns the cloned texture
  102976. */
  102977. clone(): RefractionTexture;
  102978. /**
  102979. * Serialize the texture to a JSON representation you could use in Parse later on
  102980. * @returns the serialized JSON representation
  102981. */
  102982. serialize(): any;
  102983. }
  102984. }
  102985. declare module BABYLON {
  102986. /**
  102987. * Configuration for Draco compression
  102988. */
  102989. export interface IDracoCompressionConfiguration {
  102990. /**
  102991. * Configuration for the decoder.
  102992. */
  102993. decoder?: {
  102994. /**
  102995. * The url to the WebAssembly module.
  102996. */
  102997. wasmUrl?: string;
  102998. /**
  102999. * The url to the WebAssembly binary.
  103000. */
  103001. wasmBinaryUrl?: string;
  103002. /**
  103003. * The url to the fallback JavaScript module.
  103004. */
  103005. fallbackUrl?: string;
  103006. };
  103007. }
  103008. /**
  103009. * Draco compression (https://google.github.io/draco/)
  103010. *
  103011. * This class wraps the Draco module.
  103012. *
  103013. * **Encoder**
  103014. *
  103015. * The encoder is not currently implemented.
  103016. *
  103017. * **Decoder**
  103018. *
  103019. * 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.
  103020. *
  103021. * To update the configuration, use the following code:
  103022. * ```javascript
  103023. * DracoCompression.Configuration = {
  103024. * decoder: {
  103025. * wasmUrl: "<url to the WebAssembly library>",
  103026. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  103027. * fallbackUrl: "<url to the fallback JavaScript library>",
  103028. * }
  103029. * };
  103030. * ```
  103031. *
  103032. * 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.
  103033. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  103034. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  103035. *
  103036. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  103037. * ```javascript
  103038. * var dracoCompression = new DracoCompression();
  103039. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  103040. * [VertexBuffer.PositionKind]: 0
  103041. * });
  103042. * ```
  103043. *
  103044. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  103045. */
  103046. export class DracoCompression implements IDisposable {
  103047. private static _DecoderModulePromise;
  103048. /**
  103049. * The configuration. Defaults to the following urls:
  103050. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  103051. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  103052. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  103053. */
  103054. static Configuration: IDracoCompressionConfiguration;
  103055. /**
  103056. * Returns true if the decoder is available.
  103057. */
  103058. static readonly DecoderAvailable: boolean;
  103059. /**
  103060. * Constructor
  103061. */
  103062. constructor();
  103063. /**
  103064. * Stop all async operations and release resources.
  103065. */
  103066. dispose(): void;
  103067. /**
  103068. * Decode Draco compressed mesh data to vertex data.
  103069. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  103070. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  103071. * @returns A promise that resolves with the decoded vertex data
  103072. */
  103073. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  103074. [kind: string]: number;
  103075. }): Promise<VertexData>;
  103076. private static _GetDecoderModule;
  103077. private static _LoadScriptAsync;
  103078. private static _LoadFileAsync;
  103079. }
  103080. }
  103081. declare module BABYLON {
  103082. /**
  103083. * Class for building Constructive Solid Geometry
  103084. */
  103085. export class CSG {
  103086. private polygons;
  103087. /**
  103088. * The world matrix
  103089. */
  103090. matrix: Matrix;
  103091. /**
  103092. * Stores the position
  103093. */
  103094. position: Vector3;
  103095. /**
  103096. * Stores the rotation
  103097. */
  103098. rotation: Vector3;
  103099. /**
  103100. * Stores the rotation quaternion
  103101. */
  103102. rotationQuaternion: Nullable<Quaternion>;
  103103. /**
  103104. * Stores the scaling vector
  103105. */
  103106. scaling: Vector3;
  103107. /**
  103108. * Convert the Mesh to CSG
  103109. * @param mesh The Mesh to convert to CSG
  103110. * @returns A new CSG from the Mesh
  103111. */
  103112. static FromMesh(mesh: Mesh): CSG;
  103113. /**
  103114. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103115. * @param polygons Polygons used to construct a CSG solid
  103116. */
  103117. private static FromPolygons;
  103118. /**
  103119. * Clones, or makes a deep copy, of the CSG
  103120. * @returns A new CSG
  103121. */
  103122. clone(): CSG;
  103123. /**
  103124. * Unions this CSG with another CSG
  103125. * @param csg The CSG to union against this CSG
  103126. * @returns The unioned CSG
  103127. */
  103128. union(csg: CSG): CSG;
  103129. /**
  103130. * Unions this CSG with another CSG in place
  103131. * @param csg The CSG to union against this CSG
  103132. */
  103133. unionInPlace(csg: CSG): void;
  103134. /**
  103135. * Subtracts this CSG with another CSG
  103136. * @param csg The CSG to subtract against this CSG
  103137. * @returns A new CSG
  103138. */
  103139. subtract(csg: CSG): CSG;
  103140. /**
  103141. * Subtracts this CSG with another CSG in place
  103142. * @param csg The CSG to subtact against this CSG
  103143. */
  103144. subtractInPlace(csg: CSG): void;
  103145. /**
  103146. * Intersect this CSG with another CSG
  103147. * @param csg The CSG to intersect against this CSG
  103148. * @returns A new CSG
  103149. */
  103150. intersect(csg: CSG): CSG;
  103151. /**
  103152. * Intersects this CSG with another CSG in place
  103153. * @param csg The CSG to intersect against this CSG
  103154. */
  103155. intersectInPlace(csg: CSG): void;
  103156. /**
  103157. * Return a new CSG solid with solid and empty space switched. This solid is
  103158. * not modified.
  103159. * @returns A new CSG solid with solid and empty space switched
  103160. */
  103161. inverse(): CSG;
  103162. /**
  103163. * Inverses the CSG in place
  103164. */
  103165. inverseInPlace(): void;
  103166. /**
  103167. * This is used to keep meshes transformations so they can be restored
  103168. * when we build back a Babylon Mesh
  103169. * NB : All CSG operations are performed in world coordinates
  103170. * @param csg The CSG to copy the transform attributes from
  103171. * @returns This CSG
  103172. */
  103173. copyTransformAttributes(csg: CSG): CSG;
  103174. /**
  103175. * Build Raw mesh from CSG
  103176. * Coordinates here are in world space
  103177. * @param name The name of the mesh geometry
  103178. * @param scene The Scene
  103179. * @param keepSubMeshes Specifies if the submeshes should be kept
  103180. * @returns A new Mesh
  103181. */
  103182. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103183. /**
  103184. * Build Mesh from CSG taking material and transforms into account
  103185. * @param name The name of the Mesh
  103186. * @param material The material of the Mesh
  103187. * @param scene The Scene
  103188. * @param keepSubMeshes Specifies if submeshes should be kept
  103189. * @returns The new Mesh
  103190. */
  103191. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103192. }
  103193. }
  103194. declare module BABYLON {
  103195. /**
  103196. * Class containing static functions to help procedurally build meshes
  103197. */
  103198. export class RibbonBuilder {
  103199. /**
  103200. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103201. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103202. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103203. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103204. * * 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
  103205. * * 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
  103206. * * 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
  103207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103210. * * 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
  103211. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103212. * * 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
  103213. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103215. * @param name defines the name of the mesh
  103216. * @param options defines the options used to create the mesh
  103217. * @param scene defines the hosting scene
  103218. * @returns the ribbon mesh
  103219. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103221. */
  103222. static CreateRibbon(name: string, options: {
  103223. pathArray: Vector3[][];
  103224. closeArray?: boolean;
  103225. closePath?: boolean;
  103226. offset?: number;
  103227. updatable?: boolean;
  103228. sideOrientation?: number;
  103229. frontUVs?: Vector4;
  103230. backUVs?: Vector4;
  103231. instance?: Mesh;
  103232. invertUV?: boolean;
  103233. uvs?: Vector2[];
  103234. colors?: Color4[];
  103235. }, scene?: Nullable<Scene>): Mesh;
  103236. }
  103237. }
  103238. declare module BABYLON {
  103239. /**
  103240. * Class containing static functions to help procedurally build meshes
  103241. */
  103242. export class TorusKnotBuilder {
  103243. /**
  103244. * Creates a torus knot mesh
  103245. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103246. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103247. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103248. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103252. * @param name defines the name of the mesh
  103253. * @param options defines the options used to create the mesh
  103254. * @param scene defines the hosting scene
  103255. * @returns the torus knot mesh
  103256. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103257. */
  103258. static CreateTorusKnot(name: string, options: {
  103259. radius?: number;
  103260. tube?: number;
  103261. radialSegments?: number;
  103262. tubularSegments?: number;
  103263. p?: number;
  103264. q?: number;
  103265. updatable?: boolean;
  103266. sideOrientation?: number;
  103267. frontUVs?: Vector4;
  103268. backUVs?: Vector4;
  103269. }, scene: any): Mesh;
  103270. }
  103271. }
  103272. declare module BABYLON {
  103273. /**
  103274. * Polygon
  103275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  103276. */
  103277. export class Polygon {
  103278. /**
  103279. * Creates a rectangle
  103280. * @param xmin bottom X coord
  103281. * @param ymin bottom Y coord
  103282. * @param xmax top X coord
  103283. * @param ymax top Y coord
  103284. * @returns points that make the resulting rectation
  103285. */
  103286. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  103287. /**
  103288. * Creates a circle
  103289. * @param radius radius of circle
  103290. * @param cx scale in x
  103291. * @param cy scale in y
  103292. * @param numberOfSides number of sides that make up the circle
  103293. * @returns points that make the resulting circle
  103294. */
  103295. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  103296. /**
  103297. * Creates a polygon from input string
  103298. * @param input Input polygon data
  103299. * @returns the parsed points
  103300. */
  103301. static Parse(input: string): Vector2[];
  103302. /**
  103303. * Starts building a polygon from x and y coordinates
  103304. * @param x x coordinate
  103305. * @param y y coordinate
  103306. * @returns the started path2
  103307. */
  103308. static StartingAt(x: number, y: number): Path2;
  103309. }
  103310. /**
  103311. * Builds a polygon
  103312. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  103313. */
  103314. export class PolygonMeshBuilder {
  103315. private _points;
  103316. private _outlinepoints;
  103317. private _holes;
  103318. private _name;
  103319. private _scene;
  103320. private _epoints;
  103321. private _eholes;
  103322. private _addToepoint;
  103323. /**
  103324. * Babylon reference to the earcut plugin.
  103325. */
  103326. bjsEarcut: any;
  103327. /**
  103328. * Creates a PolygonMeshBuilder
  103329. * @param name name of the builder
  103330. * @param contours Path of the polygon
  103331. * @param scene scene to add to
  103332. * @param earcutInjection can be used to inject your own earcut reference
  103333. */
  103334. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  103335. /**
  103336. * Adds a whole within the polygon
  103337. * @param hole Array of points defining the hole
  103338. * @returns this
  103339. */
  103340. addHole(hole: Vector2[]): PolygonMeshBuilder;
  103341. /**
  103342. * Creates the polygon
  103343. * @param updatable If the mesh should be updatable
  103344. * @param depth The depth of the mesh created
  103345. * @returns the created mesh
  103346. */
  103347. build(updatable?: boolean, depth?: number): Mesh;
  103348. /**
  103349. * Adds a side to the polygon
  103350. * @param positions points that make the polygon
  103351. * @param normals normals of the polygon
  103352. * @param uvs uvs of the polygon
  103353. * @param indices indices of the polygon
  103354. * @param bounds bounds of the polygon
  103355. * @param points points of the polygon
  103356. * @param depth depth of the polygon
  103357. * @param flip flip of the polygon
  103358. */
  103359. private addSide;
  103360. }
  103361. }
  103362. declare module BABYLON {
  103363. /**
  103364. * Class containing static functions to help procedurally build meshes
  103365. */
  103366. export class PolygonBuilder {
  103367. /**
  103368. * Creates a polygon mesh
  103369. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103370. * * 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
  103371. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  103374. * * Remember you can only change the shape positions, not their number when updating a polygon
  103375. * @param name defines the name of the mesh
  103376. * @param options defines the options used to create the mesh
  103377. * @param scene defines the hosting scene
  103378. * @param earcutInjection can be used to inject your own earcut reference
  103379. * @returns the polygon mesh
  103380. */
  103381. static CreatePolygon(name: string, options: {
  103382. shape: Vector3[];
  103383. holes?: Vector3[][];
  103384. depth?: number;
  103385. faceUV?: Vector4[];
  103386. faceColors?: Color4[];
  103387. updatable?: boolean;
  103388. sideOrientation?: number;
  103389. frontUVs?: Vector4;
  103390. backUVs?: Vector4;
  103391. }, scene: Scene, earcutInjection?: any): Mesh;
  103392. /**
  103393. * Creates an extruded polygon mesh, with depth in the Y direction.
  103394. * * 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)
  103395. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103396. * @param name defines the name of the mesh
  103397. * @param options defines the options used to create the mesh
  103398. * @param scene defines the hosting scene
  103399. * @param earcutInjection can be used to inject your own earcut reference
  103400. * @returns the polygon mesh
  103401. */
  103402. static ExtrudePolygon(name: string, options: {
  103403. shape: Vector3[];
  103404. holes?: Vector3[][];
  103405. depth?: number;
  103406. faceUV?: Vector4[];
  103407. faceColors?: Color4[];
  103408. updatable?: boolean;
  103409. sideOrientation?: number;
  103410. frontUVs?: Vector4;
  103411. backUVs?: Vector4;
  103412. }, scene: Scene, earcutInjection?: any): Mesh;
  103413. }
  103414. }
  103415. declare module BABYLON {
  103416. /**
  103417. * Class containing static functions to help procedurally build meshes
  103418. */
  103419. export class ShapeBuilder {
  103420. /**
  103421. * 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.
  103422. * * 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.
  103423. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103424. * * 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.
  103425. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103426. * * 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
  103427. * * 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
  103428. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103433. * @param name defines the name of the mesh
  103434. * @param options defines the options used to create the mesh
  103435. * @param scene defines the hosting scene
  103436. * @returns the extruded shape mesh
  103437. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103439. */
  103440. static ExtrudeShape(name: string, options: {
  103441. shape: Vector3[];
  103442. path: Vector3[];
  103443. scale?: number;
  103444. rotation?: number;
  103445. cap?: number;
  103446. updatable?: boolean;
  103447. sideOrientation?: number;
  103448. frontUVs?: Vector4;
  103449. backUVs?: Vector4;
  103450. instance?: Mesh;
  103451. invertUV?: boolean;
  103452. }, scene?: Nullable<Scene>): Mesh;
  103453. /**
  103454. * Creates an custom extruded shape mesh.
  103455. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103456. * * 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.
  103457. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103458. * * 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
  103459. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103460. * * 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
  103461. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103462. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103463. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103464. * * 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
  103465. * * 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
  103466. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103471. * @param name defines the name of the mesh
  103472. * @param options defines the options used to create the mesh
  103473. * @param scene defines the hosting scene
  103474. * @returns the custom extruded shape mesh
  103475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103476. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103478. */
  103479. static ExtrudeShapeCustom(name: string, options: {
  103480. shape: Vector3[];
  103481. path: Vector3[];
  103482. scaleFunction?: any;
  103483. rotationFunction?: any;
  103484. ribbonCloseArray?: boolean;
  103485. ribbonClosePath?: boolean;
  103486. cap?: number;
  103487. updatable?: boolean;
  103488. sideOrientation?: number;
  103489. frontUVs?: Vector4;
  103490. backUVs?: Vector4;
  103491. instance?: Mesh;
  103492. invertUV?: boolean;
  103493. }, scene: Scene): Mesh;
  103494. private static _ExtrudeShapeGeneric;
  103495. }
  103496. }
  103497. declare module BABYLON {
  103498. /**
  103499. * Class containing static functions to help procedurally build meshes
  103500. */
  103501. export class LatheBuilder {
  103502. /**
  103503. * Creates lathe mesh.
  103504. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103505. * * 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
  103506. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103507. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103508. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103509. * * 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
  103510. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103511. * * 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
  103512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103516. * @param name defines the name of the mesh
  103517. * @param options defines the options used to create the mesh
  103518. * @param scene defines the hosting scene
  103519. * @returns the lathe mesh
  103520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103521. */
  103522. static CreateLathe(name: string, options: {
  103523. shape: Vector3[];
  103524. radius?: number;
  103525. tessellation?: number;
  103526. clip?: number;
  103527. arc?: number;
  103528. closed?: boolean;
  103529. updatable?: boolean;
  103530. sideOrientation?: number;
  103531. frontUVs?: Vector4;
  103532. backUVs?: Vector4;
  103533. cap?: number;
  103534. invertUV?: boolean;
  103535. }, scene: Scene): Mesh;
  103536. }
  103537. }
  103538. declare module BABYLON {
  103539. /**
  103540. * Class containing static functions to help procedurally build meshes
  103541. */
  103542. export class TubeBuilder {
  103543. /**
  103544. * Creates a tube mesh.
  103545. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103546. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  103547. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  103548. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  103549. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  103550. * * 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)
  103551. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  103552. * * 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
  103553. * * 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
  103554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103558. * @param name defines the name of the mesh
  103559. * @param options defines the options used to create the mesh
  103560. * @param scene defines the hosting scene
  103561. * @returns the tube mesh
  103562. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103563. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  103564. */
  103565. static CreateTube(name: string, options: {
  103566. path: Vector3[];
  103567. radius?: number;
  103568. tessellation?: number;
  103569. radiusFunction?: {
  103570. (i: number, distance: number): number;
  103571. };
  103572. cap?: number;
  103573. arc?: number;
  103574. updatable?: boolean;
  103575. sideOrientation?: number;
  103576. frontUVs?: Vector4;
  103577. backUVs?: Vector4;
  103578. instance?: Mesh;
  103579. invertUV?: boolean;
  103580. }, scene: Scene): Mesh;
  103581. }
  103582. }
  103583. declare module BABYLON {
  103584. /**
  103585. * Class containing static functions to help procedurally build meshes
  103586. */
  103587. export class IcoSphereBuilder {
  103588. /**
  103589. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103590. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103591. * * 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`)
  103592. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103593. * * 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
  103594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103597. * @param name defines the name of the mesh
  103598. * @param options defines the options used to create the mesh
  103599. * @param scene defines the hosting scene
  103600. * @returns the icosahedron mesh
  103601. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103602. */
  103603. static CreateIcoSphere(name: string, options: {
  103604. radius?: number;
  103605. radiusX?: number;
  103606. radiusY?: number;
  103607. radiusZ?: number;
  103608. flat?: boolean;
  103609. subdivisions?: number;
  103610. sideOrientation?: number;
  103611. frontUVs?: Vector4;
  103612. backUVs?: Vector4;
  103613. updatable?: boolean;
  103614. }, scene: Scene): Mesh;
  103615. }
  103616. }
  103617. declare module BABYLON {
  103618. /**
  103619. * Class containing static functions to help procedurally build meshes
  103620. */
  103621. export class DecalBuilder {
  103622. /**
  103623. * Creates a decal mesh.
  103624. * 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
  103625. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  103626. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  103627. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  103628. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  103629. * @param name defines the name of the mesh
  103630. * @param sourceMesh defines the mesh where the decal must be applied
  103631. * @param options defines the options used to create the mesh
  103632. * @param scene defines the hosting scene
  103633. * @returns the decal mesh
  103634. * @see https://doc.babylonjs.com/how_to/decals
  103635. */
  103636. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  103637. position?: Vector3;
  103638. normal?: Vector3;
  103639. size?: Vector3;
  103640. angle?: number;
  103641. }): Mesh;
  103642. }
  103643. }
  103644. declare module BABYLON {
  103645. /**
  103646. * Class containing static functions to help procedurally build meshes
  103647. */
  103648. export class MeshBuilder {
  103649. /**
  103650. * Creates a box mesh
  103651. * * The parameter `size` sets the size (float) of each box side (default 1)
  103652. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103653. * * 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)
  103654. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103658. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103659. * @param name defines the name of the mesh
  103660. * @param options defines the options used to create the mesh
  103661. * @param scene defines the hosting scene
  103662. * @returns the box mesh
  103663. */
  103664. static CreateBox(name: string, options: {
  103665. size?: number;
  103666. width?: number;
  103667. height?: number;
  103668. depth?: number;
  103669. faceUV?: Vector4[];
  103670. faceColors?: Color4[];
  103671. sideOrientation?: number;
  103672. frontUVs?: Vector4;
  103673. backUVs?: Vector4;
  103674. updatable?: boolean;
  103675. }, scene?: Nullable<Scene>): Mesh;
  103676. /**
  103677. * Creates a sphere mesh
  103678. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103679. * * 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`)
  103680. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103681. * * 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
  103682. * * 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)
  103683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103686. * @param name defines the name of the mesh
  103687. * @param options defines the options used to create the mesh
  103688. * @param scene defines the hosting scene
  103689. * @returns the sphere mesh
  103690. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103691. */
  103692. static CreateSphere(name: string, options: {
  103693. segments?: number;
  103694. diameter?: number;
  103695. diameterX?: number;
  103696. diameterY?: number;
  103697. diameterZ?: number;
  103698. arc?: number;
  103699. slice?: number;
  103700. sideOrientation?: number;
  103701. frontUVs?: Vector4;
  103702. backUVs?: Vector4;
  103703. updatable?: boolean;
  103704. }, scene: any): Mesh;
  103705. /**
  103706. * Creates a plane polygonal mesh. By default, this is a disc
  103707. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  103708. * * 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
  103709. * * 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
  103710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103713. * @param name defines the name of the mesh
  103714. * @param options defines the options used to create the mesh
  103715. * @param scene defines the hosting scene
  103716. * @returns the plane polygonal mesh
  103717. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  103718. */
  103719. static CreateDisc(name: string, options: {
  103720. radius?: number;
  103721. tessellation?: number;
  103722. arc?: number;
  103723. updatable?: boolean;
  103724. sideOrientation?: number;
  103725. frontUVs?: Vector4;
  103726. backUVs?: Vector4;
  103727. }, scene?: Nullable<Scene>): Mesh;
  103728. /**
  103729. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103730. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103731. * * 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`)
  103732. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103733. * * 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
  103734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103737. * @param name defines the name of the mesh
  103738. * @param options defines the options used to create the mesh
  103739. * @param scene defines the hosting scene
  103740. * @returns the icosahedron mesh
  103741. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103742. */
  103743. static CreateIcoSphere(name: string, options: {
  103744. radius?: number;
  103745. radiusX?: number;
  103746. radiusY?: number;
  103747. radiusZ?: number;
  103748. flat?: boolean;
  103749. subdivisions?: number;
  103750. sideOrientation?: number;
  103751. frontUVs?: Vector4;
  103752. backUVs?: Vector4;
  103753. updatable?: boolean;
  103754. }, scene: Scene): Mesh;
  103755. /**
  103756. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103757. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103758. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103759. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103760. * * 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
  103761. * * 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
  103762. * * 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
  103763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103766. * * 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
  103767. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103768. * * 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
  103769. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103771. * @param name defines the name of the mesh
  103772. * @param options defines the options used to create the mesh
  103773. * @param scene defines the hosting scene
  103774. * @returns the ribbon mesh
  103775. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103777. */
  103778. static CreateRibbon(name: string, options: {
  103779. pathArray: Vector3[][];
  103780. closeArray?: boolean;
  103781. closePath?: boolean;
  103782. offset?: number;
  103783. updatable?: boolean;
  103784. sideOrientation?: number;
  103785. frontUVs?: Vector4;
  103786. backUVs?: Vector4;
  103787. instance?: Mesh;
  103788. invertUV?: boolean;
  103789. uvs?: Vector2[];
  103790. colors?: Color4[];
  103791. }, scene?: Nullable<Scene>): Mesh;
  103792. /**
  103793. * Creates a cylinder or a cone mesh
  103794. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103795. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103796. * * 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.
  103797. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103798. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103799. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103800. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103801. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103802. * * 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).
  103803. * * 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
  103804. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103805. * * 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
  103806. * * 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.
  103807. * * If `enclose` is false, a ring surface is one element.
  103808. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103809. * * 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
  103810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103813. * @param name defines the name of the mesh
  103814. * @param options defines the options used to create the mesh
  103815. * @param scene defines the hosting scene
  103816. * @returns the cylinder mesh
  103817. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103818. */
  103819. static CreateCylinder(name: string, options: {
  103820. height?: number;
  103821. diameterTop?: number;
  103822. diameterBottom?: number;
  103823. diameter?: number;
  103824. tessellation?: number;
  103825. subdivisions?: number;
  103826. arc?: number;
  103827. faceColors?: Color4[];
  103828. faceUV?: Vector4[];
  103829. updatable?: boolean;
  103830. hasRings?: boolean;
  103831. enclose?: boolean;
  103832. sideOrientation?: number;
  103833. frontUVs?: Vector4;
  103834. backUVs?: Vector4;
  103835. }, scene: any): Mesh;
  103836. /**
  103837. * Creates a torus mesh
  103838. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103839. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103840. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103844. * @param name defines the name of the mesh
  103845. * @param options defines the options used to create the mesh
  103846. * @param scene defines the hosting scene
  103847. * @returns the torus mesh
  103848. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103849. */
  103850. static CreateTorus(name: string, options: {
  103851. diameter?: number;
  103852. thickness?: number;
  103853. tessellation?: number;
  103854. updatable?: boolean;
  103855. sideOrientation?: number;
  103856. frontUVs?: Vector4;
  103857. backUVs?: Vector4;
  103858. }, scene: any): Mesh;
  103859. /**
  103860. * Creates a torus knot mesh
  103861. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103862. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103863. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103864. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103868. * @param name defines the name of the mesh
  103869. * @param options defines the options used to create the mesh
  103870. * @param scene defines the hosting scene
  103871. * @returns the torus knot mesh
  103872. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103873. */
  103874. static CreateTorusKnot(name: string, options: {
  103875. radius?: number;
  103876. tube?: number;
  103877. radialSegments?: number;
  103878. tubularSegments?: number;
  103879. p?: number;
  103880. q?: number;
  103881. updatable?: boolean;
  103882. sideOrientation?: number;
  103883. frontUVs?: Vector4;
  103884. backUVs?: Vector4;
  103885. }, scene: any): Mesh;
  103886. /**
  103887. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103888. * * 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
  103889. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103890. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103891. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103892. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103893. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103894. * * 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
  103895. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103898. * @param name defines the name of the new line system
  103899. * @param options defines the options used to create the line system
  103900. * @param scene defines the hosting scene
  103901. * @returns a new line system mesh
  103902. */
  103903. static CreateLineSystem(name: string, options: {
  103904. lines: Vector3[][];
  103905. updatable?: boolean;
  103906. instance?: Nullable<LinesMesh>;
  103907. colors?: Nullable<Color4[][]>;
  103908. useVertexAlpha?: boolean;
  103909. }, scene: Nullable<Scene>): LinesMesh;
  103910. /**
  103911. * Creates a line mesh
  103912. * 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
  103913. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103914. * * The parameter `points` is an array successive Vector3
  103915. * * 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
  103916. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103917. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103918. * * When updating an instance, remember that only point positions can change, not the number of points
  103919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103921. * @param name defines the name of the new line system
  103922. * @param options defines the options used to create the line system
  103923. * @param scene defines the hosting scene
  103924. * @returns a new line mesh
  103925. */
  103926. static CreateLines(name: string, options: {
  103927. points: Vector3[];
  103928. updatable?: boolean;
  103929. instance?: Nullable<LinesMesh>;
  103930. colors?: Color4[];
  103931. useVertexAlpha?: boolean;
  103932. }, scene?: Nullable<Scene>): LinesMesh;
  103933. /**
  103934. * Creates a dashed line mesh
  103935. * * 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
  103936. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103937. * * The parameter `points` is an array successive Vector3
  103938. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103939. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103940. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103941. * * 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
  103942. * * When updating an instance, remember that only point positions can change, not the number of points
  103943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103944. * @param name defines the name of the mesh
  103945. * @param options defines the options used to create the mesh
  103946. * @param scene defines the hosting scene
  103947. * @returns the dashed line mesh
  103948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103949. */
  103950. static CreateDashedLines(name: string, options: {
  103951. points: Vector3[];
  103952. dashSize?: number;
  103953. gapSize?: number;
  103954. dashNb?: number;
  103955. updatable?: boolean;
  103956. instance?: LinesMesh;
  103957. }, scene?: Nullable<Scene>): LinesMesh;
  103958. /**
  103959. * 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.
  103960. * * 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.
  103961. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103962. * * 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.
  103963. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103964. * * 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
  103965. * * 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
  103966. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103971. * @param name defines the name of the mesh
  103972. * @param options defines the options used to create the mesh
  103973. * @param scene defines the hosting scene
  103974. * @returns the extruded shape mesh
  103975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103977. */
  103978. static ExtrudeShape(name: string, options: {
  103979. shape: Vector3[];
  103980. path: Vector3[];
  103981. scale?: number;
  103982. rotation?: number;
  103983. cap?: number;
  103984. updatable?: boolean;
  103985. sideOrientation?: number;
  103986. frontUVs?: Vector4;
  103987. backUVs?: Vector4;
  103988. instance?: Mesh;
  103989. invertUV?: boolean;
  103990. }, scene?: Nullable<Scene>): Mesh;
  103991. /**
  103992. * Creates an custom extruded shape mesh.
  103993. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103994. * * 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.
  103995. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103996. * * 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
  103997. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103998. * * 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
  103999. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104000. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104001. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104002. * * 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
  104003. * * 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
  104004. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104007. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104009. * @param name defines the name of the mesh
  104010. * @param options defines the options used to create the mesh
  104011. * @param scene defines the hosting scene
  104012. * @returns the custom extruded shape mesh
  104013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104014. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104016. */
  104017. static ExtrudeShapeCustom(name: string, options: {
  104018. shape: Vector3[];
  104019. path: Vector3[];
  104020. scaleFunction?: any;
  104021. rotationFunction?: any;
  104022. ribbonCloseArray?: boolean;
  104023. ribbonClosePath?: boolean;
  104024. cap?: number;
  104025. updatable?: boolean;
  104026. sideOrientation?: number;
  104027. frontUVs?: Vector4;
  104028. backUVs?: Vector4;
  104029. instance?: Mesh;
  104030. invertUV?: boolean;
  104031. }, scene: Scene): Mesh;
  104032. /**
  104033. * Creates lathe mesh.
  104034. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104035. * * 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
  104036. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104037. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104038. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104039. * * 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
  104040. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104041. * * 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
  104042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104044. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104046. * @param name defines the name of the mesh
  104047. * @param options defines the options used to create the mesh
  104048. * @param scene defines the hosting scene
  104049. * @returns the lathe mesh
  104050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104051. */
  104052. static CreateLathe(name: string, options: {
  104053. shape: Vector3[];
  104054. radius?: number;
  104055. tessellation?: number;
  104056. clip?: number;
  104057. arc?: number;
  104058. closed?: boolean;
  104059. updatable?: boolean;
  104060. sideOrientation?: number;
  104061. frontUVs?: Vector4;
  104062. backUVs?: Vector4;
  104063. cap?: number;
  104064. invertUV?: boolean;
  104065. }, scene: Scene): Mesh;
  104066. /**
  104067. * Creates a plane mesh
  104068. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104069. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104070. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104074. * @param name defines the name of the mesh
  104075. * @param options defines the options used to create the mesh
  104076. * @param scene defines the hosting scene
  104077. * @returns the plane mesh
  104078. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104079. */
  104080. static CreatePlane(name: string, options: {
  104081. size?: number;
  104082. width?: number;
  104083. height?: number;
  104084. sideOrientation?: number;
  104085. frontUVs?: Vector4;
  104086. backUVs?: Vector4;
  104087. updatable?: boolean;
  104088. sourcePlane?: Plane;
  104089. }, scene: Scene): Mesh;
  104090. /**
  104091. * Creates a ground mesh
  104092. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104093. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104095. * @param name defines the name of the mesh
  104096. * @param options defines the options used to create the mesh
  104097. * @param scene defines the hosting scene
  104098. * @returns the ground mesh
  104099. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104100. */
  104101. static CreateGround(name: string, options: {
  104102. width?: number;
  104103. height?: number;
  104104. subdivisions?: number;
  104105. subdivisionsX?: number;
  104106. subdivisionsY?: number;
  104107. updatable?: boolean;
  104108. }, scene: any): Mesh;
  104109. /**
  104110. * Creates a tiled ground mesh
  104111. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104112. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104113. * * 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
  104114. * * 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
  104115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104116. * @param name defines the name of the mesh
  104117. * @param options defines the options used to create the mesh
  104118. * @param scene defines the hosting scene
  104119. * @returns the tiled ground mesh
  104120. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104121. */
  104122. static CreateTiledGround(name: string, options: {
  104123. xmin: number;
  104124. zmin: number;
  104125. xmax: number;
  104126. zmax: number;
  104127. subdivisions?: {
  104128. w: number;
  104129. h: number;
  104130. };
  104131. precision?: {
  104132. w: number;
  104133. h: number;
  104134. };
  104135. updatable?: boolean;
  104136. }, scene: Scene): Mesh;
  104137. /**
  104138. * Creates a ground mesh from a height map
  104139. * * The parameter `url` sets the URL of the height map image resource.
  104140. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104141. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104142. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104143. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104144. * * 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.
  104145. * * 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).
  104146. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104148. * @param name defines the name of the mesh
  104149. * @param url defines the url to the height map
  104150. * @param options defines the options used to create the mesh
  104151. * @param scene defines the hosting scene
  104152. * @returns the ground mesh
  104153. * @see https://doc.babylonjs.com/babylon101/height_map
  104154. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104155. */
  104156. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104157. width?: number;
  104158. height?: number;
  104159. subdivisions?: number;
  104160. minHeight?: number;
  104161. maxHeight?: number;
  104162. colorFilter?: Color3;
  104163. alphaFilter?: number;
  104164. updatable?: boolean;
  104165. onReady?: (mesh: GroundMesh) => void;
  104166. }, scene: Scene): GroundMesh;
  104167. /**
  104168. * Creates a polygon mesh
  104169. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104170. * * 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
  104171. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104174. * * Remember you can only change the shape positions, not their number when updating a polygon
  104175. * @param name defines the name of the mesh
  104176. * @param options defines the options used to create the mesh
  104177. * @param scene defines the hosting scene
  104178. * @param earcutInjection can be used to inject your own earcut reference
  104179. * @returns the polygon mesh
  104180. */
  104181. static CreatePolygon(name: string, options: {
  104182. shape: Vector3[];
  104183. holes?: Vector3[][];
  104184. depth?: number;
  104185. faceUV?: Vector4[];
  104186. faceColors?: Color4[];
  104187. updatable?: boolean;
  104188. sideOrientation?: number;
  104189. frontUVs?: Vector4;
  104190. backUVs?: Vector4;
  104191. }, scene: Scene, earcutInjection?: any): Mesh;
  104192. /**
  104193. * Creates an extruded polygon mesh, with depth in the Y direction.
  104194. * * 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)
  104195. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104196. * @param name defines the name of the mesh
  104197. * @param options defines the options used to create the mesh
  104198. * @param scene defines the hosting scene
  104199. * @param earcutInjection can be used to inject your own earcut reference
  104200. * @returns the polygon mesh
  104201. */
  104202. static ExtrudePolygon(name: string, options: {
  104203. shape: Vector3[];
  104204. holes?: Vector3[][];
  104205. depth?: number;
  104206. faceUV?: Vector4[];
  104207. faceColors?: Color4[];
  104208. updatable?: boolean;
  104209. sideOrientation?: number;
  104210. frontUVs?: Vector4;
  104211. backUVs?: Vector4;
  104212. }, scene: Scene, earcutInjection?: any): Mesh;
  104213. /**
  104214. * Creates a tube mesh.
  104215. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104216. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104217. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104218. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104219. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104220. * * 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)
  104221. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104222. * * 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
  104223. * * 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
  104224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104228. * @param name defines the name of the mesh
  104229. * @param options defines the options used to create the mesh
  104230. * @param scene defines the hosting scene
  104231. * @returns the tube mesh
  104232. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104233. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104234. */
  104235. static CreateTube(name: string, options: {
  104236. path: Vector3[];
  104237. radius?: number;
  104238. tessellation?: number;
  104239. radiusFunction?: {
  104240. (i: number, distance: number): number;
  104241. };
  104242. cap?: number;
  104243. arc?: number;
  104244. updatable?: boolean;
  104245. sideOrientation?: number;
  104246. frontUVs?: Vector4;
  104247. backUVs?: Vector4;
  104248. instance?: Mesh;
  104249. invertUV?: boolean;
  104250. }, scene: Scene): Mesh;
  104251. /**
  104252. * Creates a polyhedron mesh
  104253. * * 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
  104254. * * The parameter `size` (positive float, default 1) sets the polygon size
  104255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104256. * * 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`
  104257. * * 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
  104258. * * 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)`)
  104259. * * 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
  104260. * * 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
  104261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104264. * @param name defines the name of the mesh
  104265. * @param options defines the options used to create the mesh
  104266. * @param scene defines the hosting scene
  104267. * @returns the polyhedron mesh
  104268. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104269. */
  104270. static CreatePolyhedron(name: string, options: {
  104271. type?: number;
  104272. size?: number;
  104273. sizeX?: number;
  104274. sizeY?: number;
  104275. sizeZ?: number;
  104276. custom?: any;
  104277. faceUV?: Vector4[];
  104278. faceColors?: Color4[];
  104279. flat?: boolean;
  104280. updatable?: boolean;
  104281. sideOrientation?: number;
  104282. frontUVs?: Vector4;
  104283. backUVs?: Vector4;
  104284. }, scene: Scene): Mesh;
  104285. /**
  104286. * Creates a decal mesh.
  104287. * 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
  104288. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104289. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104290. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104291. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104292. * @param name defines the name of the mesh
  104293. * @param sourceMesh defines the mesh where the decal must be applied
  104294. * @param options defines the options used to create the mesh
  104295. * @param scene defines the hosting scene
  104296. * @returns the decal mesh
  104297. * @see https://doc.babylonjs.com/how_to/decals
  104298. */
  104299. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104300. position?: Vector3;
  104301. normal?: Vector3;
  104302. size?: Vector3;
  104303. angle?: number;
  104304. }): Mesh;
  104305. }
  104306. }
  104307. declare module BABYLON {
  104308. /**
  104309. * A simplifier interface for future simplification implementations
  104310. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104311. */
  104312. export interface ISimplifier {
  104313. /**
  104314. * Simplification of a given mesh according to the given settings.
  104315. * Since this requires computation, it is assumed that the function runs async.
  104316. * @param settings The settings of the simplification, including quality and distance
  104317. * @param successCallback A callback that will be called after the mesh was simplified.
  104318. * @param errorCallback in case of an error, this callback will be called. optional.
  104319. */
  104320. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  104321. }
  104322. /**
  104323. * Expected simplification settings.
  104324. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  104325. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104326. */
  104327. export interface ISimplificationSettings {
  104328. /**
  104329. * Gets or sets the expected quality
  104330. */
  104331. quality: number;
  104332. /**
  104333. * Gets or sets the distance when this optimized version should be used
  104334. */
  104335. distance: number;
  104336. /**
  104337. * Gets an already optimized mesh
  104338. */
  104339. optimizeMesh?: boolean;
  104340. }
  104341. /**
  104342. * Class used to specify simplification options
  104343. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104344. */
  104345. export class SimplificationSettings implements ISimplificationSettings {
  104346. /** expected quality */
  104347. quality: number;
  104348. /** distance when this optimized version should be used */
  104349. distance: number;
  104350. /** already optimized mesh */
  104351. optimizeMesh?: boolean | undefined;
  104352. /**
  104353. * Creates a SimplificationSettings
  104354. * @param quality expected quality
  104355. * @param distance distance when this optimized version should be used
  104356. * @param optimizeMesh already optimized mesh
  104357. */
  104358. constructor(
  104359. /** expected quality */
  104360. quality: number,
  104361. /** distance when this optimized version should be used */
  104362. distance: number,
  104363. /** already optimized mesh */
  104364. optimizeMesh?: boolean | undefined);
  104365. }
  104366. /**
  104367. * Interface used to define a simplification task
  104368. */
  104369. export interface ISimplificationTask {
  104370. /**
  104371. * Array of settings
  104372. */
  104373. settings: Array<ISimplificationSettings>;
  104374. /**
  104375. * Simplification type
  104376. */
  104377. simplificationType: SimplificationType;
  104378. /**
  104379. * Mesh to simplify
  104380. */
  104381. mesh: Mesh;
  104382. /**
  104383. * Callback called on success
  104384. */
  104385. successCallback?: () => void;
  104386. /**
  104387. * Defines if parallel processing can be used
  104388. */
  104389. parallelProcessing: boolean;
  104390. }
  104391. /**
  104392. * Queue used to order the simplification tasks
  104393. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104394. */
  104395. export class SimplificationQueue {
  104396. private _simplificationArray;
  104397. /**
  104398. * Gets a boolean indicating that the process is still running
  104399. */
  104400. running: boolean;
  104401. /**
  104402. * Creates a new queue
  104403. */
  104404. constructor();
  104405. /**
  104406. * Adds a new simplification task
  104407. * @param task defines a task to add
  104408. */
  104409. addTask(task: ISimplificationTask): void;
  104410. /**
  104411. * Execute next task
  104412. */
  104413. executeNext(): void;
  104414. /**
  104415. * Execute a simplification task
  104416. * @param task defines the task to run
  104417. */
  104418. runSimplification(task: ISimplificationTask): void;
  104419. private getSimplifier;
  104420. }
  104421. /**
  104422. * The implemented types of simplification
  104423. * At the moment only Quadratic Error Decimation is implemented
  104424. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104425. */
  104426. export enum SimplificationType {
  104427. /** Quadratic error decimation */
  104428. QUADRATIC = 0
  104429. }
  104430. }
  104431. declare module BABYLON {
  104432. interface Scene {
  104433. /** @hidden (Backing field) */
  104434. _simplificationQueue: SimplificationQueue;
  104435. /**
  104436. * Gets or sets the simplification queue attached to the scene
  104437. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104438. */
  104439. simplificationQueue: SimplificationQueue;
  104440. }
  104441. interface Mesh {
  104442. /**
  104443. * Simplify the mesh according to the given array of settings.
  104444. * Function will return immediately and will simplify async
  104445. * @param settings a collection of simplification settings
  104446. * @param parallelProcessing should all levels calculate parallel or one after the other
  104447. * @param simplificationType the type of simplification to run
  104448. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  104449. * @returns the current mesh
  104450. */
  104451. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  104452. }
  104453. /**
  104454. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  104455. * created in a scene
  104456. */
  104457. export class SimplicationQueueSceneComponent implements ISceneComponent {
  104458. /**
  104459. * The component name helpfull to identify the component in the list of scene components.
  104460. */
  104461. readonly name: string;
  104462. /**
  104463. * The scene the component belongs to.
  104464. */
  104465. scene: Scene;
  104466. /**
  104467. * Creates a new instance of the component for the given scene
  104468. * @param scene Defines the scene to register the component in
  104469. */
  104470. constructor(scene: Scene);
  104471. /**
  104472. * Registers the component in a given scene
  104473. */
  104474. register(): void;
  104475. /**
  104476. * Rebuilds the elements related to this component in case of
  104477. * context lost for instance.
  104478. */
  104479. rebuild(): void;
  104480. /**
  104481. * Disposes the component and the associated ressources
  104482. */
  104483. dispose(): void;
  104484. private _beforeCameraUpdate;
  104485. }
  104486. }
  104487. declare module BABYLON {
  104488. /**
  104489. * Class used to enable access to IndexedDB
  104490. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104491. */
  104492. export class Database implements IOfflineProvider {
  104493. private _callbackManifestChecked;
  104494. private _currentSceneUrl;
  104495. private _db;
  104496. private _enableSceneOffline;
  104497. private _enableTexturesOffline;
  104498. private _manifestVersionFound;
  104499. private _mustUpdateRessources;
  104500. private _hasReachedQuota;
  104501. private _isSupported;
  104502. private _idbFactory;
  104503. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  104504. private static IsUASupportingBlobStorage;
  104505. /**
  104506. * Gets a boolean indicating if Database storate is enabled (off by default)
  104507. */
  104508. static IDBStorageEnabled: boolean;
  104509. /**
  104510. * Gets a boolean indicating if scene must be saved in the database
  104511. */
  104512. readonly enableSceneOffline: boolean;
  104513. /**
  104514. * Gets a boolean indicating if textures must be saved in the database
  104515. */
  104516. readonly enableTexturesOffline: boolean;
  104517. /**
  104518. * Creates a new Database
  104519. * @param urlToScene defines the url to load the scene
  104520. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104521. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104522. */
  104523. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  104524. private static _ParseURL;
  104525. private static _ReturnFullUrlLocation;
  104526. private _checkManifestFile;
  104527. /**
  104528. * Open the database and make it available
  104529. * @param successCallback defines the callback to call on success
  104530. * @param errorCallback defines the callback to call on error
  104531. */
  104532. open(successCallback: () => void, errorCallback: () => void): void;
  104533. /**
  104534. * Loads an image from the database
  104535. * @param url defines the url to load from
  104536. * @param image defines the target DOM image
  104537. */
  104538. loadImage(url: string, image: HTMLImageElement): void;
  104539. private _loadImageFromDBAsync;
  104540. private _saveImageIntoDBAsync;
  104541. private _checkVersionFromDB;
  104542. private _loadVersionFromDBAsync;
  104543. private _saveVersionIntoDBAsync;
  104544. /**
  104545. * Loads a file from database
  104546. * @param url defines the URL to load from
  104547. * @param sceneLoaded defines a callback to call on success
  104548. * @param progressCallBack defines a callback to call when progress changed
  104549. * @param errorCallback defines a callback to call on error
  104550. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104551. */
  104552. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  104553. private _loadFileAsync;
  104554. private _saveFileAsync;
  104555. /**
  104556. * Validates if xhr data is correct
  104557. * @param xhr defines the request to validate
  104558. * @param dataType defines the expected data type
  104559. * @returns true if data is correct
  104560. */
  104561. private static _ValidateXHRData;
  104562. }
  104563. }
  104564. declare module BABYLON {
  104565. /** @hidden */
  104566. export var gpuUpdateParticlesPixelShader: {
  104567. name: string;
  104568. shader: string;
  104569. };
  104570. }
  104571. declare module BABYLON {
  104572. /** @hidden */
  104573. export var gpuUpdateParticlesVertexShader: {
  104574. name: string;
  104575. shader: string;
  104576. };
  104577. }
  104578. declare module BABYLON {
  104579. /** @hidden */
  104580. export var clipPlaneFragmentDeclaration2: {
  104581. name: string;
  104582. shader: string;
  104583. };
  104584. }
  104585. declare module BABYLON {
  104586. /** @hidden */
  104587. export var gpuRenderParticlesPixelShader: {
  104588. name: string;
  104589. shader: string;
  104590. };
  104591. }
  104592. declare module BABYLON {
  104593. /** @hidden */
  104594. export var clipPlaneVertexDeclaration2: {
  104595. name: string;
  104596. shader: string;
  104597. };
  104598. }
  104599. declare module BABYLON {
  104600. /** @hidden */
  104601. export var gpuRenderParticlesVertexShader: {
  104602. name: string;
  104603. shader: string;
  104604. };
  104605. }
  104606. declare module BABYLON {
  104607. /**
  104608. * This represents a GPU particle system in Babylon
  104609. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  104610. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  104611. */
  104612. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  104613. /**
  104614. * The layer mask we are rendering the particles through.
  104615. */
  104616. layerMask: number;
  104617. private _capacity;
  104618. private _activeCount;
  104619. private _currentActiveCount;
  104620. private _accumulatedCount;
  104621. private _renderEffect;
  104622. private _updateEffect;
  104623. private _buffer0;
  104624. private _buffer1;
  104625. private _spriteBuffer;
  104626. private _updateVAO;
  104627. private _renderVAO;
  104628. private _targetIndex;
  104629. private _sourceBuffer;
  104630. private _targetBuffer;
  104631. private _engine;
  104632. private _currentRenderId;
  104633. private _started;
  104634. private _stopped;
  104635. private _timeDelta;
  104636. private _randomTexture;
  104637. private _randomTexture2;
  104638. private _attributesStrideSize;
  104639. private _updateEffectOptions;
  104640. private _randomTextureSize;
  104641. private _actualFrame;
  104642. private readonly _rawTextureWidth;
  104643. /**
  104644. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  104645. */
  104646. static readonly IsSupported: boolean;
  104647. /**
  104648. * An event triggered when the system is disposed.
  104649. */
  104650. onDisposeObservable: Observable<GPUParticleSystem>;
  104651. /**
  104652. * Gets the maximum number of particles active at the same time.
  104653. * @returns The max number of active particles.
  104654. */
  104655. getCapacity(): number;
  104656. /**
  104657. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104658. * to override the particles.
  104659. */
  104660. forceDepthWrite: boolean;
  104661. /**
  104662. * Gets or set the number of active particles
  104663. */
  104664. activeParticleCount: number;
  104665. private _preWarmDone;
  104666. /**
  104667. * Is this system ready to be used/rendered
  104668. * @return true if the system is ready
  104669. */
  104670. isReady(): boolean;
  104671. /**
  104672. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104673. * @returns True if it has been started, otherwise false.
  104674. */
  104675. isStarted(): boolean;
  104676. /**
  104677. * Starts the particle system and begins to emit
  104678. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104679. */
  104680. start(delay?: number): void;
  104681. /**
  104682. * Stops the particle system.
  104683. */
  104684. stop(): void;
  104685. /**
  104686. * Remove all active particles
  104687. */
  104688. reset(): void;
  104689. /**
  104690. * Returns the string "GPUParticleSystem"
  104691. * @returns a string containing the class name
  104692. */
  104693. getClassName(): string;
  104694. private _colorGradientsTexture;
  104695. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  104696. /**
  104697. * Adds a new color gradient
  104698. * @param gradient defines the gradient to use (between 0 and 1)
  104699. * @param color1 defines the color to affect to the specified gradient
  104700. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104701. * @returns the current particle system
  104702. */
  104703. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  104704. /**
  104705. * Remove a specific color gradient
  104706. * @param gradient defines the gradient to remove
  104707. * @returns the current particle system
  104708. */
  104709. removeColorGradient(gradient: number): GPUParticleSystem;
  104710. private _angularSpeedGradientsTexture;
  104711. private _sizeGradientsTexture;
  104712. private _velocityGradientsTexture;
  104713. private _limitVelocityGradientsTexture;
  104714. private _dragGradientsTexture;
  104715. private _addFactorGradient;
  104716. /**
  104717. * Adds a new size gradient
  104718. * @param gradient defines the gradient to use (between 0 and 1)
  104719. * @param factor defines the size factor to affect to the specified gradient
  104720. * @returns the current particle system
  104721. */
  104722. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  104723. /**
  104724. * Remove a specific size gradient
  104725. * @param gradient defines the gradient to remove
  104726. * @returns the current particle system
  104727. */
  104728. removeSizeGradient(gradient: number): GPUParticleSystem;
  104729. /**
  104730. * Adds a new angular speed gradient
  104731. * @param gradient defines the gradient to use (between 0 and 1)
  104732. * @param factor defines the angular speed to affect to the specified gradient
  104733. * @returns the current particle system
  104734. */
  104735. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  104736. /**
  104737. * Remove a specific angular speed gradient
  104738. * @param gradient defines the gradient to remove
  104739. * @returns the current particle system
  104740. */
  104741. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  104742. /**
  104743. * Adds a new velocity gradient
  104744. * @param gradient defines the gradient to use (between 0 and 1)
  104745. * @param factor defines the velocity to affect to the specified gradient
  104746. * @returns the current particle system
  104747. */
  104748. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104749. /**
  104750. * Remove a specific velocity gradient
  104751. * @param gradient defines the gradient to remove
  104752. * @returns the current particle system
  104753. */
  104754. removeVelocityGradient(gradient: number): GPUParticleSystem;
  104755. /**
  104756. * Adds a new limit velocity gradient
  104757. * @param gradient defines the gradient to use (between 0 and 1)
  104758. * @param factor defines the limit velocity value to affect to the specified gradient
  104759. * @returns the current particle system
  104760. */
  104761. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104762. /**
  104763. * Remove a specific limit velocity gradient
  104764. * @param gradient defines the gradient to remove
  104765. * @returns the current particle system
  104766. */
  104767. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  104768. /**
  104769. * Adds a new drag gradient
  104770. * @param gradient defines the gradient to use (between 0 and 1)
  104771. * @param factor defines the drag value to affect to the specified gradient
  104772. * @returns the current particle system
  104773. */
  104774. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  104775. /**
  104776. * Remove a specific drag gradient
  104777. * @param gradient defines the gradient to remove
  104778. * @returns the current particle system
  104779. */
  104780. removeDragGradient(gradient: number): GPUParticleSystem;
  104781. /**
  104782. * Not supported by GPUParticleSystem
  104783. * @param gradient defines the gradient to use (between 0 and 1)
  104784. * @param factor defines the emit rate value to affect to the specified gradient
  104785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104786. * @returns the current particle system
  104787. */
  104788. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104789. /**
  104790. * Not supported by GPUParticleSystem
  104791. * @param gradient defines the gradient to remove
  104792. * @returns the current particle system
  104793. */
  104794. removeEmitRateGradient(gradient: number): IParticleSystem;
  104795. /**
  104796. * Not supported by GPUParticleSystem
  104797. * @param gradient defines the gradient to use (between 0 and 1)
  104798. * @param factor defines the start size value to affect to the specified gradient
  104799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104800. * @returns the current particle system
  104801. */
  104802. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104803. /**
  104804. * Not supported by GPUParticleSystem
  104805. * @param gradient defines the gradient to remove
  104806. * @returns the current particle system
  104807. */
  104808. removeStartSizeGradient(gradient: number): IParticleSystem;
  104809. /**
  104810. * Not supported by GPUParticleSystem
  104811. * @param gradient defines the gradient to use (between 0 and 1)
  104812. * @param min defines the color remap minimal range
  104813. * @param max defines the color remap maximal range
  104814. * @returns the current particle system
  104815. */
  104816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104817. /**
  104818. * Not supported by GPUParticleSystem
  104819. * @param gradient defines the gradient to remove
  104820. * @returns the current particle system
  104821. */
  104822. removeColorRemapGradient(): IParticleSystem;
  104823. /**
  104824. * Not supported by GPUParticleSystem
  104825. * @param gradient defines the gradient to use (between 0 and 1)
  104826. * @param min defines the alpha remap minimal range
  104827. * @param max defines the alpha remap maximal range
  104828. * @returns the current particle system
  104829. */
  104830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104831. /**
  104832. * Not supported by GPUParticleSystem
  104833. * @param gradient defines the gradient to remove
  104834. * @returns the current particle system
  104835. */
  104836. removeAlphaRemapGradient(): IParticleSystem;
  104837. /**
  104838. * Not supported by GPUParticleSystem
  104839. * @param gradient defines the gradient to use (between 0 and 1)
  104840. * @param color defines the color to affect to the specified gradient
  104841. * @returns the current particle system
  104842. */
  104843. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  104844. /**
  104845. * Not supported by GPUParticleSystem
  104846. * @param gradient defines the gradient to remove
  104847. * @returns the current particle system
  104848. */
  104849. removeRampGradient(): IParticleSystem;
  104850. /**
  104851. * Not supported by GPUParticleSystem
  104852. * @returns the list of ramp gradients
  104853. */
  104854. getRampGradients(): Nullable<Array<Color3Gradient>>;
  104855. /**
  104856. * Not supported by GPUParticleSystem
  104857. * Gets or sets a boolean indicating that ramp gradients must be used
  104858. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104859. */
  104860. useRampGradients: boolean;
  104861. /**
  104862. * Not supported by GPUParticleSystem
  104863. * @param gradient defines the gradient to use (between 0 and 1)
  104864. * @param factor defines the life time factor to affect to the specified gradient
  104865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104866. * @returns the current particle system
  104867. */
  104868. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104869. /**
  104870. * Not supported by GPUParticleSystem
  104871. * @param gradient defines the gradient to remove
  104872. * @returns the current particle system
  104873. */
  104874. removeLifeTimeGradient(gradient: number): IParticleSystem;
  104875. /**
  104876. * Instantiates a GPU particle system.
  104877. * 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.
  104878. * @param name The name of the particle system
  104879. * @param options The options used to create the system
  104880. * @param scene The scene the particle system belongs to
  104881. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104882. */
  104883. constructor(name: string, options: Partial<{
  104884. capacity: number;
  104885. randomTextureSize: number;
  104886. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  104887. protected _reset(): void;
  104888. private _createUpdateVAO;
  104889. private _createRenderVAO;
  104890. private _initialize;
  104891. /** @hidden */
  104892. _recreateUpdateEffect(): void;
  104893. /** @hidden */
  104894. _recreateRenderEffect(): void;
  104895. /**
  104896. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104897. * @param preWarm defines if we are in the pre-warmimg phase
  104898. */
  104899. animate(preWarm?: boolean): void;
  104900. private _createFactorGradientTexture;
  104901. private _createSizeGradientTexture;
  104902. private _createAngularSpeedGradientTexture;
  104903. private _createVelocityGradientTexture;
  104904. private _createLimitVelocityGradientTexture;
  104905. private _createDragGradientTexture;
  104906. private _createColorGradientTexture;
  104907. /**
  104908. * Renders the particle system in its current state
  104909. * @param preWarm defines if the system should only update the particles but not render them
  104910. * @returns the current number of particles
  104911. */
  104912. render(preWarm?: boolean): number;
  104913. /**
  104914. * Rebuilds the particle system
  104915. */
  104916. rebuild(): void;
  104917. private _releaseBuffers;
  104918. private _releaseVAOs;
  104919. /**
  104920. * Disposes the particle system and free the associated resources
  104921. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104922. */
  104923. dispose(disposeTexture?: boolean): void;
  104924. /**
  104925. * Clones the particle system.
  104926. * @param name The name of the cloned object
  104927. * @param newEmitter The new emitter to use
  104928. * @returns the cloned particle system
  104929. */
  104930. clone(name: string, newEmitter: any): GPUParticleSystem;
  104931. /**
  104932. * Serializes the particle system to a JSON object.
  104933. * @returns the JSON object
  104934. */
  104935. serialize(): any;
  104936. /**
  104937. * Parses a JSON object to create a GPU particle system.
  104938. * @param parsedParticleSystem The JSON object to parse
  104939. * @param scene The scene to create the particle system in
  104940. * @param rootUrl The root url to use to load external dependencies like texture
  104941. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104942. * @returns the parsed GPU particle system
  104943. */
  104944. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  104945. }
  104946. }
  104947. declare module BABYLON {
  104948. /**
  104949. * Represents a set of particle systems working together to create a specific effect
  104950. */
  104951. export class ParticleSystemSet implements IDisposable {
  104952. private _emitterCreationOptions;
  104953. private _emitterNode;
  104954. /**
  104955. * Gets the particle system list
  104956. */
  104957. systems: IParticleSystem[];
  104958. /**
  104959. * Gets the emitter node used with this set
  104960. */
  104961. readonly emitterNode: Nullable<TransformNode>;
  104962. /**
  104963. * Creates a new emitter mesh as a sphere
  104964. * @param options defines the options used to create the sphere
  104965. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  104966. * @param scene defines the hosting scene
  104967. */
  104968. setEmitterAsSphere(options: {
  104969. diameter: number;
  104970. segments: number;
  104971. color: Color3;
  104972. }, renderingGroupId: number, scene: Scene): void;
  104973. /**
  104974. * Starts all particle systems of the set
  104975. * @param emitter defines an optional mesh to use as emitter for the particle systems
  104976. */
  104977. start(emitter?: AbstractMesh): void;
  104978. /**
  104979. * Release all associated resources
  104980. */
  104981. dispose(): void;
  104982. /**
  104983. * Serialize the set into a JSON compatible object
  104984. * @returns a JSON compatible representation of the set
  104985. */
  104986. serialize(): any;
  104987. /**
  104988. * Parse a new ParticleSystemSet from a serialized source
  104989. * @param data defines a JSON compatible representation of the set
  104990. * @param scene defines the hosting scene
  104991. * @param gpu defines if we want GPU particles or CPU particles
  104992. * @returns a new ParticleSystemSet
  104993. */
  104994. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  104995. }
  104996. }
  104997. declare module BABYLON {
  104998. /**
  104999. * This class is made for on one-liner static method to help creating particle system set.
  105000. */
  105001. export class ParticleHelper {
  105002. /**
  105003. * Gets or sets base Assets URL
  105004. */
  105005. static BaseAssetsUrl: string;
  105006. /**
  105007. * Create a default particle system that you can tweak
  105008. * @param emitter defines the emitter to use
  105009. * @param capacity defines the system capacity (default is 500 particles)
  105010. * @param scene defines the hosting scene
  105011. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105012. * @returns the new Particle system
  105013. */
  105014. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  105015. /**
  105016. * This is the main static method (one-liner) of this helper to create different particle systems
  105017. * @param type This string represents the type to the particle system to create
  105018. * @param scene The scene where the particle system should live
  105019. * @param gpu If the system will use gpu
  105020. * @returns the ParticleSystemSet created
  105021. */
  105022. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  105023. /**
  105024. * Static function used to export a particle system to a ParticleSystemSet variable.
  105025. * Please note that the emitter shape is not exported
  105026. * @param systems defines the particle systems to export
  105027. * @returns the created particle system set
  105028. */
  105029. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  105030. }
  105031. }
  105032. declare module BABYLON {
  105033. interface Engine {
  105034. /**
  105035. * Create an effect to use with particle systems.
  105036. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  105037. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  105038. * @param uniformsNames defines a list of attribute names
  105039. * @param samplers defines an array of string used to represent textures
  105040. * @param defines defines the string containing the defines to use to compile the shaders
  105041. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105042. * @param onCompiled defines a function to call when the effect creation is successful
  105043. * @param onError defines a function to call when the effect creation has failed
  105044. * @returns the new Effect
  105045. */
  105046. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  105047. }
  105048. interface Mesh {
  105049. /**
  105050. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  105051. * @returns an array of IParticleSystem
  105052. */
  105053. getEmittedParticleSystems(): IParticleSystem[];
  105054. /**
  105055. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  105056. * @returns an array of IParticleSystem
  105057. */
  105058. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  105059. }
  105060. /**
  105061. * @hidden
  105062. */
  105063. export var _IDoNeedToBeInTheBuild: number;
  105064. }
  105065. declare module BABYLON {
  105066. interface Scene {
  105067. /** @hidden (Backing field) */
  105068. _physicsEngine: Nullable<IPhysicsEngine>;
  105069. /**
  105070. * Gets the current physics engine
  105071. * @returns a IPhysicsEngine or null if none attached
  105072. */
  105073. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  105074. /**
  105075. * Enables physics to the current scene
  105076. * @param gravity defines the scene's gravity for the physics engine
  105077. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  105078. * @return a boolean indicating if the physics engine was initialized
  105079. */
  105080. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  105081. /**
  105082. * Disables and disposes the physics engine associated with the scene
  105083. */
  105084. disablePhysicsEngine(): void;
  105085. /**
  105086. * Gets a boolean indicating if there is an active physics engine
  105087. * @returns a boolean indicating if there is an active physics engine
  105088. */
  105089. isPhysicsEnabled(): boolean;
  105090. /**
  105091. * Deletes a physics compound impostor
  105092. * @param compound defines the compound to delete
  105093. */
  105094. deleteCompoundImpostor(compound: any): void;
  105095. /**
  105096. * An event triggered when physic simulation is about to be run
  105097. */
  105098. onBeforePhysicsObservable: Observable<Scene>;
  105099. /**
  105100. * An event triggered when physic simulation has been done
  105101. */
  105102. onAfterPhysicsObservable: Observable<Scene>;
  105103. }
  105104. interface AbstractMesh {
  105105. /** @hidden */
  105106. _physicsImpostor: Nullable<PhysicsImpostor>;
  105107. /**
  105108. * Gets or sets impostor used for physic simulation
  105109. * @see http://doc.babylonjs.com/features/physics_engine
  105110. */
  105111. physicsImpostor: Nullable<PhysicsImpostor>;
  105112. /**
  105113. * Gets the current physics impostor
  105114. * @see http://doc.babylonjs.com/features/physics_engine
  105115. * @returns a physics impostor or null
  105116. */
  105117. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  105118. /** Apply a physic impulse to the mesh
  105119. * @param force defines the force to apply
  105120. * @param contactPoint defines where to apply the force
  105121. * @returns the current mesh
  105122. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105123. */
  105124. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  105125. /**
  105126. * Creates a physic joint between two meshes
  105127. * @param otherMesh defines the other mesh to use
  105128. * @param pivot1 defines the pivot to use on this mesh
  105129. * @param pivot2 defines the pivot to use on the other mesh
  105130. * @param options defines additional options (can be plugin dependent)
  105131. * @returns the current mesh
  105132. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  105133. */
  105134. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  105135. /** @hidden */
  105136. _disposePhysicsObserver: Nullable<Observer<Node>>;
  105137. }
  105138. /**
  105139. * Defines the physics engine scene component responsible to manage a physics engine
  105140. */
  105141. export class PhysicsEngineSceneComponent implements ISceneComponent {
  105142. /**
  105143. * The component name helpful to identify the component in the list of scene components.
  105144. */
  105145. readonly name: string;
  105146. /**
  105147. * The scene the component belongs to.
  105148. */
  105149. scene: Scene;
  105150. /**
  105151. * Creates a new instance of the component for the given scene
  105152. * @param scene Defines the scene to register the component in
  105153. */
  105154. constructor(scene: Scene);
  105155. /**
  105156. * Registers the component in a given scene
  105157. */
  105158. register(): void;
  105159. /**
  105160. * Rebuilds the elements related to this component in case of
  105161. * context lost for instance.
  105162. */
  105163. rebuild(): void;
  105164. /**
  105165. * Disposes the component and the associated ressources
  105166. */
  105167. dispose(): void;
  105168. }
  105169. }
  105170. declare module BABYLON {
  105171. /**
  105172. * A helper for physics simulations
  105173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105174. */
  105175. export class PhysicsHelper {
  105176. private _scene;
  105177. private _physicsEngine;
  105178. /**
  105179. * Initializes the Physics helper
  105180. * @param scene Babylon.js scene
  105181. */
  105182. constructor(scene: Scene);
  105183. /**
  105184. * Applies a radial explosion impulse
  105185. * @param origin the origin of the explosion
  105186. * @param radius the explosion radius
  105187. * @param strength the explosion strength
  105188. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105189. * @returns A physics radial explosion event, or null
  105190. */
  105191. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105192. /**
  105193. * Applies a radial explosion force
  105194. * @param origin the origin of the explosion
  105195. * @param radius the explosion radius
  105196. * @param strength the explosion strength
  105197. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105198. * @returns A physics radial explosion event, or null
  105199. */
  105200. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105201. /**
  105202. * Creates a gravitational field
  105203. * @param origin the origin of the explosion
  105204. * @param radius the explosion radius
  105205. * @param strength the explosion strength
  105206. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105207. * @returns A physics gravitational field event, or null
  105208. */
  105209. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  105210. /**
  105211. * Creates a physics updraft event
  105212. * @param origin the origin of the updraft
  105213. * @param radius the radius of the updraft
  105214. * @param strength the strength of the updraft
  105215. * @param height the height of the updraft
  105216. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  105217. * @returns A physics updraft event, or null
  105218. */
  105219. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  105220. /**
  105221. * Creates a physics vortex event
  105222. * @param origin the of the vortex
  105223. * @param radius the radius of the vortex
  105224. * @param strength the strength of the vortex
  105225. * @param height the height of the vortex
  105226. * @returns a Physics vortex event, or null
  105227. * A physics vortex event or null
  105228. */
  105229. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  105230. }
  105231. /**
  105232. * Represents a physics radial explosion event
  105233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105234. */
  105235. export class PhysicsRadialExplosionEvent {
  105236. private _scene;
  105237. private _sphere;
  105238. private _sphereOptions;
  105239. private _rays;
  105240. private _dataFetched;
  105241. /**
  105242. * Initializes a radial explosioin event
  105243. * @param scene BabylonJS scene
  105244. */
  105245. constructor(scene: Scene);
  105246. /**
  105247. * Returns the data related to the radial explosion event (sphere & rays).
  105248. * @returns The radial explosion event data
  105249. */
  105250. getData(): PhysicsRadialExplosionEventData;
  105251. /**
  105252. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  105253. * @param impostor A physics imposter
  105254. * @param origin the origin of the explosion
  105255. * @param radius the explosion radius
  105256. * @param strength the explosion strength
  105257. * @param falloff possible options: Constant & Linear
  105258. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  105259. */
  105260. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  105261. /**
  105262. * Disposes the sphere.
  105263. * @param force Specifies if the sphere should be disposed by force
  105264. */
  105265. dispose(force?: boolean): void;
  105266. /*** Helpers ***/
  105267. private _prepareSphere;
  105268. private _intersectsWithSphere;
  105269. }
  105270. /**
  105271. * Represents a gravitational field event
  105272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105273. */
  105274. export class PhysicsGravitationalFieldEvent {
  105275. private _physicsHelper;
  105276. private _scene;
  105277. private _origin;
  105278. private _radius;
  105279. private _strength;
  105280. private _falloff;
  105281. private _tickCallback;
  105282. private _sphere;
  105283. private _dataFetched;
  105284. /**
  105285. * Initializes the physics gravitational field event
  105286. * @param physicsHelper A physics helper
  105287. * @param scene BabylonJS scene
  105288. * @param origin The origin position of the gravitational field event
  105289. * @param radius The radius of the gravitational field event
  105290. * @param strength The strength of the gravitational field event
  105291. * @param falloff The falloff for the gravitational field event
  105292. */
  105293. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  105294. /**
  105295. * Returns the data related to the gravitational field event (sphere).
  105296. * @returns A gravitational field event
  105297. */
  105298. getData(): PhysicsGravitationalFieldEventData;
  105299. /**
  105300. * Enables the gravitational field.
  105301. */
  105302. enable(): void;
  105303. /**
  105304. * Disables the gravitational field.
  105305. */
  105306. disable(): void;
  105307. /**
  105308. * Disposes the sphere.
  105309. * @param force The force to dispose from the gravitational field event
  105310. */
  105311. dispose(force?: boolean): void;
  105312. private _tick;
  105313. }
  105314. /**
  105315. * Represents a physics updraft event
  105316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105317. */
  105318. export class PhysicsUpdraftEvent {
  105319. private _scene;
  105320. private _origin;
  105321. private _radius;
  105322. private _strength;
  105323. private _height;
  105324. private _updraftMode;
  105325. private _physicsEngine;
  105326. private _originTop;
  105327. private _originDirection;
  105328. private _tickCallback;
  105329. private _cylinder;
  105330. private _cylinderPosition;
  105331. private _dataFetched;
  105332. /**
  105333. * Initializes the physics updraft event
  105334. * @param _scene BabylonJS scene
  105335. * @param _origin The origin position of the updraft
  105336. * @param _radius The radius of the updraft
  105337. * @param _strength The strength of the updraft
  105338. * @param _height The height of the updraft
  105339. * @param _updraftMode The mode of the updraft
  105340. */
  105341. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  105342. /**
  105343. * Returns the data related to the updraft event (cylinder).
  105344. * @returns A physics updraft event
  105345. */
  105346. getData(): PhysicsUpdraftEventData;
  105347. /**
  105348. * Enables the updraft.
  105349. */
  105350. enable(): void;
  105351. /**
  105352. * Disables the cortex.
  105353. */
  105354. disable(): void;
  105355. /**
  105356. * Disposes the sphere.
  105357. * @param force Specifies if the updraft should be disposed by force
  105358. */
  105359. dispose(force?: boolean): void;
  105360. private getImpostorForceAndContactPoint;
  105361. private _tick;
  105362. /*** Helpers ***/
  105363. private _prepareCylinder;
  105364. private _intersectsWithCylinder;
  105365. }
  105366. /**
  105367. * Represents a physics vortex event
  105368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105369. */
  105370. export class PhysicsVortexEvent {
  105371. private _scene;
  105372. private _origin;
  105373. private _radius;
  105374. private _strength;
  105375. private _height;
  105376. private _physicsEngine;
  105377. private _originTop;
  105378. private _centripetalForceThreshold;
  105379. private _updraftMultiplier;
  105380. private _tickCallback;
  105381. private _cylinder;
  105382. private _cylinderPosition;
  105383. private _dataFetched;
  105384. /**
  105385. * Initializes the physics vortex event
  105386. * @param _scene The BabylonJS scene
  105387. * @param _origin The origin position of the vortex
  105388. * @param _radius The radius of the vortex
  105389. * @param _strength The strength of the vortex
  105390. * @param _height The height of the vortex
  105391. */
  105392. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  105393. /**
  105394. * Returns the data related to the vortex event (cylinder).
  105395. * @returns The physics vortex event data
  105396. */
  105397. getData(): PhysicsVortexEventData;
  105398. /**
  105399. * Enables the vortex.
  105400. */
  105401. enable(): void;
  105402. /**
  105403. * Disables the cortex.
  105404. */
  105405. disable(): void;
  105406. /**
  105407. * Disposes the sphere.
  105408. * @param force
  105409. */
  105410. dispose(force?: boolean): void;
  105411. private getImpostorForceAndContactPoint;
  105412. private _tick;
  105413. /*** Helpers ***/
  105414. private _prepareCylinder;
  105415. private _intersectsWithCylinder;
  105416. }
  105417. /**
  105418. * The strenght of the force in correspondence to the distance of the affected object
  105419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105420. */
  105421. export enum PhysicsRadialImpulseFalloff {
  105422. /** Defines that impulse is constant in strength across it's whole radius */
  105423. Constant = 0,
  105424. /** DEfines that impulse gets weaker if it's further from the origin */
  105425. Linear = 1
  105426. }
  105427. /**
  105428. * The strength of the force in correspondence to the distance of the affected object
  105429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105430. */
  105431. export enum PhysicsUpdraftMode {
  105432. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  105433. Center = 0,
  105434. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  105435. Perpendicular = 1
  105436. }
  105437. /**
  105438. * Interface for a physics force and contact point
  105439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105440. */
  105441. export interface PhysicsForceAndContactPoint {
  105442. /**
  105443. * The force applied at the contact point
  105444. */
  105445. force: Vector3;
  105446. /**
  105447. * The contact point
  105448. */
  105449. contactPoint: Vector3;
  105450. }
  105451. /**
  105452. * Interface for radial explosion event data
  105453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105454. */
  105455. export interface PhysicsRadialExplosionEventData {
  105456. /**
  105457. * A sphere used for the radial explosion event
  105458. */
  105459. sphere: Mesh;
  105460. /**
  105461. * An array of rays for the radial explosion event
  105462. */
  105463. rays: Array<Ray>;
  105464. }
  105465. /**
  105466. * Interface for gravitational field event data
  105467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105468. */
  105469. export interface PhysicsGravitationalFieldEventData {
  105470. /**
  105471. * A sphere mesh used for the gravitational field event
  105472. */
  105473. sphere: Mesh;
  105474. }
  105475. /**
  105476. * Interface for updraft event data
  105477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105478. */
  105479. export interface PhysicsUpdraftEventData {
  105480. /**
  105481. * A cylinder used for the updraft event
  105482. */
  105483. cylinder: Mesh;
  105484. }
  105485. /**
  105486. * Interface for vortex event data
  105487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105488. */
  105489. export interface PhysicsVortexEventData {
  105490. /**
  105491. * A cylinder used for the vortex event
  105492. */
  105493. cylinder: Mesh;
  105494. }
  105495. }
  105496. declare module BABYLON {
  105497. /**
  105498. * AmmoJS Physics plugin
  105499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105500. * @see https://github.com/kripken/ammo.js/
  105501. */
  105502. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  105503. private _useDeltaForWorldStep;
  105504. /**
  105505. * Reference to the Ammo library
  105506. */
  105507. bjsAMMO: any;
  105508. /**
  105509. * Created ammoJS world which physics bodies are added to
  105510. */
  105511. world: any;
  105512. /**
  105513. * Name of the plugin
  105514. */
  105515. name: string;
  105516. private _timeStep;
  105517. private _fixedTimeStep;
  105518. private _maxSteps;
  105519. private _tmpQuaternion;
  105520. private _tmpAmmoTransform;
  105521. private _tmpAmmoQuaternion;
  105522. private _tmpAmmoConcreteContactResultCallback;
  105523. private _collisionConfiguration;
  105524. private _dispatcher;
  105525. private _overlappingPairCache;
  105526. private _solver;
  105527. private _tmpAmmoVectorA;
  105528. private _tmpAmmoVectorB;
  105529. private _tmpAmmoVectorC;
  105530. private _tmpContactCallbackResult;
  105531. private static readonly DISABLE_COLLISION_FLAG;
  105532. private static readonly KINEMATIC_FLAG;
  105533. private static readonly DISABLE_DEACTIVATION_FLAG;
  105534. /**
  105535. * Initializes the ammoJS plugin
  105536. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  105537. * @param ammoInjection can be used to inject your own ammo reference
  105538. */
  105539. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  105540. /**
  105541. * Sets the gravity of the physics world (m/(s^2))
  105542. * @param gravity Gravity to set
  105543. */
  105544. setGravity(gravity: Vector3): void;
  105545. /**
  105546. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  105547. * @param timeStep timestep to use in seconds
  105548. */
  105549. setTimeStep(timeStep: number): void;
  105550. /**
  105551. * 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)
  105552. * @param fixedTimeStep fixedTimeStep to use in seconds
  105553. */
  105554. setFixedTimeStep(fixedTimeStep: number): void;
  105555. /**
  105556. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  105557. * @param maxSteps the maximum number of steps by the physics engine per frame
  105558. */
  105559. setMaxSteps(maxSteps: number): void;
  105560. /**
  105561. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  105562. * @returns the current timestep in seconds
  105563. */
  105564. getTimeStep(): number;
  105565. private _isImpostorInContact;
  105566. private _isImpostorPairInContact;
  105567. private _stepSimulation;
  105568. /**
  105569. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  105570. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  105571. * After the step the babylon meshes are set to the position of the physics imposters
  105572. * @param delta amount of time to step forward
  105573. * @param impostors array of imposters to update before/after the step
  105574. */
  105575. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105576. private _tmpVector;
  105577. private _tmpMatrix;
  105578. /**
  105579. * Applies an implulse on the imposter
  105580. * @param impostor imposter to apply impulse
  105581. * @param force amount of force to be applied to the imposter
  105582. * @param contactPoint the location to apply the impulse on the imposter
  105583. */
  105584. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105585. /**
  105586. * Applies a force on the imposter
  105587. * @param impostor imposter to apply force
  105588. * @param force amount of force to be applied to the imposter
  105589. * @param contactPoint the location to apply the force on the imposter
  105590. */
  105591. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105592. /**
  105593. * Creates a physics body using the plugin
  105594. * @param impostor the imposter to create the physics body on
  105595. */
  105596. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105597. /**
  105598. * Removes the physics body from the imposter and disposes of the body's memory
  105599. * @param impostor imposter to remove the physics body from
  105600. */
  105601. removePhysicsBody(impostor: PhysicsImpostor): void;
  105602. /**
  105603. * Generates a joint
  105604. * @param impostorJoint the imposter joint to create the joint with
  105605. */
  105606. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105607. /**
  105608. * Removes a joint
  105609. * @param impostorJoint the imposter joint to remove the joint from
  105610. */
  105611. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105612. private _addMeshVerts;
  105613. private _createShape;
  105614. /**
  105615. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  105616. * @param impostor imposter containing the physics body and babylon object
  105617. */
  105618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105619. /**
  105620. * Sets the babylon object's position/rotation from the physics body's position/rotation
  105621. * @param impostor imposter containing the physics body and babylon object
  105622. * @param newPosition new position
  105623. * @param newRotation new rotation
  105624. */
  105625. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105626. /**
  105627. * If this plugin is supported
  105628. * @returns true if its supported
  105629. */
  105630. isSupported(): boolean;
  105631. /**
  105632. * Sets the linear velocity of the physics body
  105633. * @param impostor imposter to set the velocity on
  105634. * @param velocity velocity to set
  105635. */
  105636. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105637. /**
  105638. * Sets the angular velocity of the physics body
  105639. * @param impostor imposter to set the velocity on
  105640. * @param velocity velocity to set
  105641. */
  105642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105643. /**
  105644. * gets the linear velocity
  105645. * @param impostor imposter to get linear velocity from
  105646. * @returns linear velocity
  105647. */
  105648. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105649. /**
  105650. * gets the angular velocity
  105651. * @param impostor imposter to get angular velocity from
  105652. * @returns angular velocity
  105653. */
  105654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105655. /**
  105656. * Sets the mass of physics body
  105657. * @param impostor imposter to set the mass on
  105658. * @param mass mass to set
  105659. */
  105660. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105661. /**
  105662. * Gets the mass of the physics body
  105663. * @param impostor imposter to get the mass from
  105664. * @returns mass
  105665. */
  105666. getBodyMass(impostor: PhysicsImpostor): number;
  105667. /**
  105668. * Gets friction of the impostor
  105669. * @param impostor impostor to get friction from
  105670. * @returns friction value
  105671. */
  105672. getBodyFriction(impostor: PhysicsImpostor): number;
  105673. /**
  105674. * Sets friction of the impostor
  105675. * @param impostor impostor to set friction on
  105676. * @param friction friction value
  105677. */
  105678. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105679. /**
  105680. * Gets restitution of the impostor
  105681. * @param impostor impostor to get restitution from
  105682. * @returns restitution value
  105683. */
  105684. getBodyRestitution(impostor: PhysicsImpostor): number;
  105685. /**
  105686. * Sets resitution of the impostor
  105687. * @param impostor impostor to set resitution on
  105688. * @param restitution resitution value
  105689. */
  105690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105691. /**
  105692. * Sleeps the physics body and stops it from being active
  105693. * @param impostor impostor to sleep
  105694. */
  105695. sleepBody(impostor: PhysicsImpostor): void;
  105696. /**
  105697. * Activates the physics body
  105698. * @param impostor impostor to activate
  105699. */
  105700. wakeUpBody(impostor: PhysicsImpostor): void;
  105701. /**
  105702. * Updates the distance parameters of the joint
  105703. * @param joint joint to update
  105704. * @param maxDistance maximum distance of the joint
  105705. * @param minDistance minimum distance of the joint
  105706. */
  105707. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105708. /**
  105709. * Sets a motor on the joint
  105710. * @param joint joint to set motor on
  105711. * @param speed speed of the motor
  105712. * @param maxForce maximum force of the motor
  105713. * @param motorIndex index of the motor
  105714. */
  105715. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105716. /**
  105717. * Sets the motors limit
  105718. * @param joint joint to set limit on
  105719. * @param upperLimit upper limit
  105720. * @param lowerLimit lower limit
  105721. */
  105722. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105723. /**
  105724. * Syncs the position and rotation of a mesh with the impostor
  105725. * @param mesh mesh to sync
  105726. * @param impostor impostor to update the mesh with
  105727. */
  105728. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105729. /**
  105730. * Gets the radius of the impostor
  105731. * @param impostor impostor to get radius from
  105732. * @returns the radius
  105733. */
  105734. getRadius(impostor: PhysicsImpostor): number;
  105735. /**
  105736. * Gets the box size of the impostor
  105737. * @param impostor impostor to get box size from
  105738. * @param result the resulting box size
  105739. */
  105740. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105741. /**
  105742. * Disposes of the impostor
  105743. */
  105744. dispose(): void;
  105745. }
  105746. }
  105747. declare module BABYLON {
  105748. /** @hidden */
  105749. export var blackAndWhitePixelShader: {
  105750. name: string;
  105751. shader: string;
  105752. };
  105753. }
  105754. declare module BABYLON {
  105755. /**
  105756. * Post process used to render in black and white
  105757. */
  105758. export class BlackAndWhitePostProcess extends PostProcess {
  105759. /**
  105760. * Linear about to convert he result to black and white (default: 1)
  105761. */
  105762. degree: number;
  105763. /**
  105764. * Creates a black and white post process
  105765. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  105766. * @param name The name of the effect.
  105767. * @param options The required width/height ratio to downsize to before computing the render pass.
  105768. * @param camera The camera to apply the render pass to.
  105769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105770. * @param engine The engine which the post process will be applied. (default: current engine)
  105771. * @param reusable If the post process can be reused on the same frame. (default: false)
  105772. */
  105773. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105774. }
  105775. }
  105776. declare module BABYLON {
  105777. /**
  105778. * This represents a set of one or more post processes in Babylon.
  105779. * A post process can be used to apply a shader to a texture after it is rendered.
  105780. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  105781. */
  105782. export class PostProcessRenderEffect {
  105783. private _postProcesses;
  105784. private _getPostProcesses;
  105785. private _singleInstance;
  105786. private _cameras;
  105787. private _indicesForCamera;
  105788. /**
  105789. * Name of the effect
  105790. * @hidden
  105791. */
  105792. _name: string;
  105793. /**
  105794. * Instantiates a post process render effect.
  105795. * A post process can be used to apply a shader to a texture after it is rendered.
  105796. * @param engine The engine the effect is tied to
  105797. * @param name The name of the effect
  105798. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  105799. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  105800. */
  105801. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  105802. /**
  105803. * Checks if all the post processes in the effect are supported.
  105804. */
  105805. readonly isSupported: boolean;
  105806. /**
  105807. * Updates the current state of the effect
  105808. * @hidden
  105809. */
  105810. _update(): void;
  105811. /**
  105812. * Attaches the effect on cameras
  105813. * @param cameras The camera to attach to.
  105814. * @hidden
  105815. */
  105816. _attachCameras(cameras: Camera): void;
  105817. /**
  105818. * Attaches the effect on cameras
  105819. * @param cameras The camera to attach to.
  105820. * @hidden
  105821. */
  105822. _attachCameras(cameras: Camera[]): void;
  105823. /**
  105824. * Detatches the effect on cameras
  105825. * @param cameras The camera to detatch from.
  105826. * @hidden
  105827. */
  105828. _detachCameras(cameras: Camera): void;
  105829. /**
  105830. * Detatches the effect on cameras
  105831. * @param cameras The camera to detatch from.
  105832. * @hidden
  105833. */
  105834. _detachCameras(cameras: Camera[]): void;
  105835. /**
  105836. * Enables the effect on given cameras
  105837. * @param cameras The camera to enable.
  105838. * @hidden
  105839. */
  105840. _enable(cameras: Camera): void;
  105841. /**
  105842. * Enables the effect on given cameras
  105843. * @param cameras The camera to enable.
  105844. * @hidden
  105845. */
  105846. _enable(cameras: Nullable<Camera[]>): void;
  105847. /**
  105848. * Disables the effect on the given cameras
  105849. * @param cameras The camera to disable.
  105850. * @hidden
  105851. */
  105852. _disable(cameras: Camera): void;
  105853. /**
  105854. * Disables the effect on the given cameras
  105855. * @param cameras The camera to disable.
  105856. * @hidden
  105857. */
  105858. _disable(cameras: Nullable<Camera[]>): void;
  105859. /**
  105860. * Gets a list of the post processes contained in the effect.
  105861. * @param camera The camera to get the post processes on.
  105862. * @returns The list of the post processes in the effect.
  105863. */
  105864. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  105865. }
  105866. }
  105867. declare module BABYLON {
  105868. /** @hidden */
  105869. export var extractHighlightsPixelShader: {
  105870. name: string;
  105871. shader: string;
  105872. };
  105873. }
  105874. declare module BABYLON {
  105875. /**
  105876. * 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.
  105877. */
  105878. export class ExtractHighlightsPostProcess extends PostProcess {
  105879. /**
  105880. * The luminance threshold, pixels below this value will be set to black.
  105881. */
  105882. threshold: number;
  105883. /** @hidden */
  105884. _exposure: number;
  105885. /**
  105886. * Post process which has the input texture to be used when performing highlight extraction
  105887. * @hidden
  105888. */
  105889. _inputPostProcess: Nullable<PostProcess>;
  105890. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105891. }
  105892. }
  105893. declare module BABYLON {
  105894. /** @hidden */
  105895. export var bloomMergePixelShader: {
  105896. name: string;
  105897. shader: string;
  105898. };
  105899. }
  105900. declare module BABYLON {
  105901. /**
  105902. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  105903. */
  105904. export class BloomMergePostProcess extends PostProcess {
  105905. /** Weight of the bloom to be added to the original input. */
  105906. weight: number;
  105907. /**
  105908. * Creates a new instance of @see BloomMergePostProcess
  105909. * @param name The name of the effect.
  105910. * @param originalFromInput Post process which's input will be used for the merge.
  105911. * @param blurred Blurred highlights post process which's output will be used.
  105912. * @param weight Weight of the bloom to be added to the original input.
  105913. * @param options The required width/height ratio to downsize to before computing the render pass.
  105914. * @param camera The camera to apply the render pass to.
  105915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105916. * @param engine The engine which the post process will be applied. (default: current engine)
  105917. * @param reusable If the post process can be reused on the same frame. (default: false)
  105918. * @param textureType Type of textures used when performing the post process. (default: 0)
  105919. * @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)
  105920. */
  105921. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  105922. /** Weight of the bloom to be added to the original input. */
  105923. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105924. }
  105925. }
  105926. declare module BABYLON {
  105927. /**
  105928. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  105929. */
  105930. export class BloomEffect extends PostProcessRenderEffect {
  105931. private bloomScale;
  105932. /**
  105933. * @hidden Internal
  105934. */
  105935. _effects: Array<PostProcess>;
  105936. /**
  105937. * @hidden Internal
  105938. */
  105939. _downscale: ExtractHighlightsPostProcess;
  105940. private _blurX;
  105941. private _blurY;
  105942. private _merge;
  105943. /**
  105944. * The luminance threshold to find bright areas of the image to bloom.
  105945. */
  105946. threshold: number;
  105947. /**
  105948. * The strength of the bloom.
  105949. */
  105950. weight: number;
  105951. /**
  105952. * Specifies the size of the bloom blur kernel, relative to the final output size
  105953. */
  105954. kernel: number;
  105955. /**
  105956. * Creates a new instance of @see BloomEffect
  105957. * @param scene The scene the effect belongs to.
  105958. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  105959. * @param bloomKernel The size of the kernel to be used when applying the blur.
  105960. * @param bloomWeight The the strength of bloom.
  105961. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105962. * @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)
  105963. */
  105964. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  105965. /**
  105966. * Disposes each of the internal effects for a given camera.
  105967. * @param camera The camera to dispose the effect on.
  105968. */
  105969. disposeEffects(camera: Camera): void;
  105970. /**
  105971. * @hidden Internal
  105972. */
  105973. _updateEffects(): void;
  105974. /**
  105975. * Internal
  105976. * @returns if all the contained post processes are ready.
  105977. * @hidden
  105978. */
  105979. _isReady(): boolean;
  105980. }
  105981. }
  105982. declare module BABYLON {
  105983. /** @hidden */
  105984. export var chromaticAberrationPixelShader: {
  105985. name: string;
  105986. shader: string;
  105987. };
  105988. }
  105989. declare module BABYLON {
  105990. /**
  105991. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  105992. */
  105993. export class ChromaticAberrationPostProcess extends PostProcess {
  105994. /**
  105995. * The amount of seperation of rgb channels (default: 30)
  105996. */
  105997. aberrationAmount: number;
  105998. /**
  105999. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  106000. */
  106001. radialIntensity: number;
  106002. /**
  106003. * 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))
  106004. */
  106005. direction: Vector2;
  106006. /**
  106007. * 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))
  106008. */
  106009. centerPosition: Vector2;
  106010. /**
  106011. * Creates a new instance ChromaticAberrationPostProcess
  106012. * @param name The name of the effect.
  106013. * @param screenWidth The width of the screen to apply the effect on.
  106014. * @param screenHeight The height of the screen to apply the effect on.
  106015. * @param options The required width/height ratio to downsize to before computing the render pass.
  106016. * @param camera The camera to apply the render pass to.
  106017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106018. * @param engine The engine which the post process will be applied. (default: current engine)
  106019. * @param reusable If the post process can be reused on the same frame. (default: false)
  106020. * @param textureType Type of textures used when performing the post process. (default: 0)
  106021. * @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)
  106022. */
  106023. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106024. }
  106025. }
  106026. declare module BABYLON {
  106027. /** @hidden */
  106028. export var circleOfConfusionPixelShader: {
  106029. name: string;
  106030. shader: string;
  106031. };
  106032. }
  106033. declare module BABYLON {
  106034. /**
  106035. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  106036. */
  106037. export class CircleOfConfusionPostProcess extends PostProcess {
  106038. /**
  106039. * 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.
  106040. */
  106041. lensSize: number;
  106042. /**
  106043. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106044. */
  106045. fStop: number;
  106046. /**
  106047. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106048. */
  106049. focusDistance: number;
  106050. /**
  106051. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  106052. */
  106053. focalLength: number;
  106054. private _depthTexture;
  106055. /**
  106056. * Creates a new instance CircleOfConfusionPostProcess
  106057. * @param name The name of the effect.
  106058. * @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.
  106059. * @param options The required width/height ratio to downsize to before computing the render pass.
  106060. * @param camera The camera to apply the render pass to.
  106061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106062. * @param engine The engine which the post process will be applied. (default: current engine)
  106063. * @param reusable If the post process can be reused on the same frame. (default: false)
  106064. * @param textureType Type of textures used when performing the post process. (default: 0)
  106065. * @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)
  106066. */
  106067. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106068. /**
  106069. * 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.
  106070. */
  106071. depthTexture: RenderTargetTexture;
  106072. }
  106073. }
  106074. declare module BABYLON {
  106075. /** @hidden */
  106076. export var colorCorrectionPixelShader: {
  106077. name: string;
  106078. shader: string;
  106079. };
  106080. }
  106081. declare module BABYLON {
  106082. /**
  106083. *
  106084. * This post-process allows the modification of rendered colors by using
  106085. * a 'look-up table' (LUT). This effect is also called Color Grading.
  106086. *
  106087. * The object needs to be provided an url to a texture containing the color
  106088. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  106089. * Use an image editing software to tweak the LUT to match your needs.
  106090. *
  106091. * For an example of a color LUT, see here:
  106092. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  106093. * For explanations on color grading, see here:
  106094. * @see http://udn.epicgames.com/Three/ColorGrading.html
  106095. *
  106096. */
  106097. export class ColorCorrectionPostProcess extends PostProcess {
  106098. private _colorTableTexture;
  106099. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106100. }
  106101. }
  106102. declare module BABYLON {
  106103. /** @hidden */
  106104. export var convolutionPixelShader: {
  106105. name: string;
  106106. shader: string;
  106107. };
  106108. }
  106109. declare module BABYLON {
  106110. /**
  106111. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  106112. * input texture to perform effects such as edge detection or sharpening
  106113. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106114. */
  106115. export class ConvolutionPostProcess extends PostProcess {
  106116. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106117. kernel: number[];
  106118. /**
  106119. * Creates a new instance ConvolutionPostProcess
  106120. * @param name The name of the effect.
  106121. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  106122. * @param options The required width/height ratio to downsize to before computing the render pass.
  106123. * @param camera The camera to apply the render pass to.
  106124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106125. * @param engine The engine which the post process will be applied. (default: current engine)
  106126. * @param reusable If the post process can be reused on the same frame. (default: false)
  106127. * @param textureType Type of textures used when performing the post process. (default: 0)
  106128. */
  106129. constructor(name: string,
  106130. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106131. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106132. /**
  106133. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106134. */
  106135. static EdgeDetect0Kernel: number[];
  106136. /**
  106137. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106138. */
  106139. static EdgeDetect1Kernel: number[];
  106140. /**
  106141. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106142. */
  106143. static EdgeDetect2Kernel: number[];
  106144. /**
  106145. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106146. */
  106147. static SharpenKernel: number[];
  106148. /**
  106149. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106150. */
  106151. static EmbossKernel: number[];
  106152. /**
  106153. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106154. */
  106155. static GaussianKernel: number[];
  106156. }
  106157. }
  106158. declare module BABYLON {
  106159. /**
  106160. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  106161. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  106162. * based on samples that have a large difference in distance than the center pixel.
  106163. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  106164. */
  106165. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  106166. direction: Vector2;
  106167. /**
  106168. * Creates a new instance CircleOfConfusionPostProcess
  106169. * @param name The name of the effect.
  106170. * @param scene The scene the effect belongs to.
  106171. * @param direction The direction the blur should be applied.
  106172. * @param kernel The size of the kernel used to blur.
  106173. * @param options The required width/height ratio to downsize to before computing the render pass.
  106174. * @param camera The camera to apply the render pass to.
  106175. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  106176. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  106177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106178. * @param engine The engine which the post process will be applied. (default: current engine)
  106179. * @param reusable If the post process can be reused on the same frame. (default: false)
  106180. * @param textureType Type of textures used when performing the post process. (default: 0)
  106181. * @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)
  106182. */
  106183. 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);
  106184. }
  106185. }
  106186. declare module BABYLON {
  106187. /** @hidden */
  106188. export var depthOfFieldMergePixelShader: {
  106189. name: string;
  106190. shader: string;
  106191. };
  106192. }
  106193. declare module BABYLON {
  106194. /**
  106195. * Options to be set when merging outputs from the default pipeline.
  106196. */
  106197. export class DepthOfFieldMergePostProcessOptions {
  106198. /**
  106199. * The original image to merge on top of
  106200. */
  106201. originalFromInput: PostProcess;
  106202. /**
  106203. * Parameters to perform the merge of the depth of field effect
  106204. */
  106205. depthOfField?: {
  106206. circleOfConfusion: PostProcess;
  106207. blurSteps: Array<PostProcess>;
  106208. };
  106209. /**
  106210. * Parameters to perform the merge of bloom effect
  106211. */
  106212. bloom?: {
  106213. blurred: PostProcess;
  106214. weight: number;
  106215. };
  106216. }
  106217. /**
  106218. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106219. */
  106220. export class DepthOfFieldMergePostProcess extends PostProcess {
  106221. private blurSteps;
  106222. /**
  106223. * Creates a new instance of DepthOfFieldMergePostProcess
  106224. * @param name The name of the effect.
  106225. * @param originalFromInput Post process which's input will be used for the merge.
  106226. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  106227. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  106228. * @param options The required width/height ratio to downsize to before computing the render pass.
  106229. * @param camera The camera to apply the render pass to.
  106230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106231. * @param engine The engine which the post process will be applied. (default: current engine)
  106232. * @param reusable If the post process can be reused on the same frame. (default: false)
  106233. * @param textureType Type of textures used when performing the post process. (default: 0)
  106234. * @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)
  106235. */
  106236. 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);
  106237. /**
  106238. * Updates the effect with the current post process compile time values and recompiles the shader.
  106239. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  106240. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  106241. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  106242. * @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
  106243. * @param onCompiled Called when the shader has been compiled.
  106244. * @param onError Called if there is an error when compiling a shader.
  106245. */
  106246. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  106247. }
  106248. }
  106249. declare module BABYLON {
  106250. /**
  106251. * Specifies the level of max blur that should be applied when using the depth of field effect
  106252. */
  106253. export enum DepthOfFieldEffectBlurLevel {
  106254. /**
  106255. * Subtle blur
  106256. */
  106257. Low = 0,
  106258. /**
  106259. * Medium blur
  106260. */
  106261. Medium = 1,
  106262. /**
  106263. * Large blur
  106264. */
  106265. High = 2
  106266. }
  106267. /**
  106268. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  106269. */
  106270. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  106271. private _circleOfConfusion;
  106272. /**
  106273. * @hidden Internal, blurs from high to low
  106274. */
  106275. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  106276. private _depthOfFieldBlurY;
  106277. private _dofMerge;
  106278. /**
  106279. * @hidden Internal post processes in depth of field effect
  106280. */
  106281. _effects: Array<PostProcess>;
  106282. /**
  106283. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  106284. */
  106285. focalLength: number;
  106286. /**
  106287. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106288. */
  106289. fStop: number;
  106290. /**
  106291. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106292. */
  106293. focusDistance: number;
  106294. /**
  106295. * 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.
  106296. */
  106297. lensSize: number;
  106298. /**
  106299. * Creates a new instance DepthOfFieldEffect
  106300. * @param scene The scene the effect belongs to.
  106301. * @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.
  106302. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106303. * @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)
  106304. */
  106305. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  106306. /**
  106307. * 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.
  106308. */
  106309. depthTexture: RenderTargetTexture;
  106310. /**
  106311. * Disposes each of the internal effects for a given camera.
  106312. * @param camera The camera to dispose the effect on.
  106313. */
  106314. disposeEffects(camera: Camera): void;
  106315. /**
  106316. * @hidden Internal
  106317. */
  106318. _updateEffects(): void;
  106319. /**
  106320. * Internal
  106321. * @returns if all the contained post processes are ready.
  106322. * @hidden
  106323. */
  106324. _isReady(): boolean;
  106325. }
  106326. }
  106327. declare module BABYLON {
  106328. /** @hidden */
  106329. export var displayPassPixelShader: {
  106330. name: string;
  106331. shader: string;
  106332. };
  106333. }
  106334. declare module BABYLON {
  106335. /**
  106336. * DisplayPassPostProcess which produces an output the same as it's input
  106337. */
  106338. export class DisplayPassPostProcess extends PostProcess {
  106339. /**
  106340. * Creates the DisplayPassPostProcess
  106341. * @param name The name of the effect.
  106342. * @param options The required width/height ratio to downsize to before computing the render pass.
  106343. * @param camera The camera to apply the render pass to.
  106344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106345. * @param engine The engine which the post process will be applied. (default: current engine)
  106346. * @param reusable If the post process can be reused on the same frame. (default: false)
  106347. */
  106348. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106349. }
  106350. }
  106351. declare module BABYLON {
  106352. /** @hidden */
  106353. export var filterPixelShader: {
  106354. name: string;
  106355. shader: string;
  106356. };
  106357. }
  106358. declare module BABYLON {
  106359. /**
  106360. * Applies a kernel filter to the image
  106361. */
  106362. export class FilterPostProcess extends PostProcess {
  106363. /** The matrix to be applied to the image */
  106364. kernelMatrix: Matrix;
  106365. /**
  106366. *
  106367. * @param name The name of the effect.
  106368. * @param kernelMatrix The matrix to be applied to the image
  106369. * @param options The required width/height ratio to downsize to before computing the render pass.
  106370. * @param camera The camera to apply the render pass to.
  106371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106372. * @param engine The engine which the post process will be applied. (default: current engine)
  106373. * @param reusable If the post process can be reused on the same frame. (default: false)
  106374. */
  106375. constructor(name: string,
  106376. /** The matrix to be applied to the image */
  106377. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106378. }
  106379. }
  106380. declare module BABYLON {
  106381. /** @hidden */
  106382. export var fxaaPixelShader: {
  106383. name: string;
  106384. shader: string;
  106385. };
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var fxaaVertexShader: {
  106390. name: string;
  106391. shader: string;
  106392. };
  106393. }
  106394. declare module BABYLON {
  106395. /**
  106396. * Fxaa post process
  106397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  106398. */
  106399. export class FxaaPostProcess extends PostProcess {
  106400. /** @hidden */
  106401. texelWidth: number;
  106402. /** @hidden */
  106403. texelHeight: number;
  106404. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106405. private _getDefines;
  106406. }
  106407. }
  106408. declare module BABYLON {
  106409. /** @hidden */
  106410. export var grainPixelShader: {
  106411. name: string;
  106412. shader: string;
  106413. };
  106414. }
  106415. declare module BABYLON {
  106416. /**
  106417. * The GrainPostProcess adds noise to the image at mid luminance levels
  106418. */
  106419. export class GrainPostProcess extends PostProcess {
  106420. /**
  106421. * The intensity of the grain added (default: 30)
  106422. */
  106423. intensity: number;
  106424. /**
  106425. * If the grain should be randomized on every frame
  106426. */
  106427. animated: boolean;
  106428. /**
  106429. * Creates a new instance of @see GrainPostProcess
  106430. * @param name The name of the effect.
  106431. * @param options The required width/height ratio to downsize to before computing the render pass.
  106432. * @param camera The camera to apply the render pass to.
  106433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106434. * @param engine The engine which the post process will be applied. (default: current engine)
  106435. * @param reusable If the post process can be reused on the same frame. (default: false)
  106436. * @param textureType Type of textures used when performing the post process. (default: 0)
  106437. * @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)
  106438. */
  106439. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106440. }
  106441. }
  106442. declare module BABYLON {
  106443. /** @hidden */
  106444. export var highlightsPixelShader: {
  106445. name: string;
  106446. shader: string;
  106447. };
  106448. }
  106449. declare module BABYLON {
  106450. /**
  106451. * Extracts highlights from the image
  106452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106453. */
  106454. export class HighlightsPostProcess extends PostProcess {
  106455. /**
  106456. * Extracts highlights from the image
  106457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106458. * @param name The name of the effect.
  106459. * @param options The required width/height ratio to downsize to before computing the render pass.
  106460. * @param camera The camera to apply the render pass to.
  106461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106462. * @param engine The engine which the post process will be applied. (default: current engine)
  106463. * @param reusable If the post process can be reused on the same frame. (default: false)
  106464. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  106465. */
  106466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106467. }
  106468. }
  106469. declare module BABYLON {
  106470. /** @hidden */
  106471. export var mrtFragmentDeclaration: {
  106472. name: string;
  106473. shader: string;
  106474. };
  106475. }
  106476. declare module BABYLON {
  106477. /** @hidden */
  106478. export var geometryPixelShader: {
  106479. name: string;
  106480. shader: string;
  106481. };
  106482. }
  106483. declare module BABYLON {
  106484. /** @hidden */
  106485. export var geometryVertexShader: {
  106486. name: string;
  106487. shader: string;
  106488. };
  106489. }
  106490. declare module BABYLON {
  106491. /**
  106492. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  106493. */
  106494. export class GeometryBufferRenderer {
  106495. /**
  106496. * Constant used to retrieve the position texture index in the G-Buffer textures array
  106497. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  106498. */
  106499. static readonly POSITION_TEXTURE_TYPE: number;
  106500. /**
  106501. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  106502. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  106503. */
  106504. static readonly VELOCITY_TEXTURE_TYPE: number;
  106505. /**
  106506. * Dictionary used to store the previous transformation matrices of each rendered mesh
  106507. * in order to compute objects velocities when enableVelocity is set to "true"
  106508. * @hidden
  106509. */
  106510. _previousTransformationMatrices: {
  106511. [index: number]: Matrix;
  106512. };
  106513. private _scene;
  106514. private _multiRenderTarget;
  106515. private _ratio;
  106516. private _enablePosition;
  106517. private _enableVelocity;
  106518. private _positionIndex;
  106519. private _velocityIndex;
  106520. protected _effect: Effect;
  106521. protected _cachedDefines: string;
  106522. /**
  106523. * Set the render list (meshes to be rendered) used in the G buffer.
  106524. */
  106525. renderList: Mesh[];
  106526. /**
  106527. * Gets wether or not G buffer are supported by the running hardware.
  106528. * This requires draw buffer supports
  106529. */
  106530. readonly isSupported: boolean;
  106531. /**
  106532. * Returns the index of the given texture type in the G-Buffer textures array
  106533. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  106534. * @returns the index of the given texture type in the G-Buffer textures array
  106535. */
  106536. getTextureIndex(textureType: number): number;
  106537. /**
  106538. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  106539. */
  106540. /**
  106541. * Sets whether or not objects positions are enabled for the G buffer.
  106542. */
  106543. enablePosition: boolean;
  106544. /**
  106545. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  106546. */
  106547. /**
  106548. * Sets wether or not objects velocities are enabled for the G buffer.
  106549. */
  106550. enableVelocity: boolean;
  106551. /**
  106552. * Gets the scene associated with the buffer.
  106553. */
  106554. readonly scene: Scene;
  106555. /**
  106556. * Gets the ratio used by the buffer during its creation.
  106557. * How big is the buffer related to the main canvas.
  106558. */
  106559. readonly ratio: number;
  106560. /** @hidden */
  106561. static _SceneComponentInitialization: (scene: Scene) => void;
  106562. /**
  106563. * Creates a new G Buffer for the scene
  106564. * @param scene The scene the buffer belongs to
  106565. * @param ratio How big is the buffer related to the main canvas.
  106566. */
  106567. constructor(scene: Scene, ratio?: number);
  106568. /**
  106569. * Checks wether everything is ready to render a submesh to the G buffer.
  106570. * @param subMesh the submesh to check readiness for
  106571. * @param useInstances is the mesh drawn using instance or not
  106572. * @returns true if ready otherwise false
  106573. */
  106574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106575. /**
  106576. * Gets the current underlying G Buffer.
  106577. * @returns the buffer
  106578. */
  106579. getGBuffer(): MultiRenderTarget;
  106580. /**
  106581. * Gets the number of samples used to render the buffer (anti aliasing).
  106582. */
  106583. /**
  106584. * Sets the number of samples used to render the buffer (anti aliasing).
  106585. */
  106586. samples: number;
  106587. /**
  106588. * Disposes the renderer and frees up associated resources.
  106589. */
  106590. dispose(): void;
  106591. protected _createRenderTargets(): void;
  106592. }
  106593. }
  106594. declare module BABYLON {
  106595. /** @hidden */
  106596. export var motionBlurPixelShader: {
  106597. name: string;
  106598. shader: string;
  106599. };
  106600. }
  106601. declare module BABYLON {
  106602. /**
  106603. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  106604. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  106605. * As an example, all you have to do is to create the post-process:
  106606. * var mb = new BABYLON.MotionBlurPostProcess(
  106607. * 'mb', // The name of the effect.
  106608. * scene, // The scene containing the objects to blur according to their velocity.
  106609. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  106610. * camera // The camera to apply the render pass to.
  106611. * );
  106612. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  106613. */
  106614. export class MotionBlurPostProcess extends PostProcess {
  106615. /**
  106616. * Defines how much the image is blurred by the movement. Default value is equal to 1
  106617. */
  106618. motionStrength: number;
  106619. /**
  106620. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  106621. */
  106622. /**
  106623. * Sets the number of iterations to be used for motion blur quality
  106624. */
  106625. motionBlurSamples: number;
  106626. private _motionBlurSamples;
  106627. private _geometryBufferRenderer;
  106628. /**
  106629. * Creates a new instance MotionBlurPostProcess
  106630. * @param name The name of the effect.
  106631. * @param scene The scene containing the objects to blur according to their velocity.
  106632. * @param options The required width/height ratio to downsize to before computing the render pass.
  106633. * @param camera The camera to apply the render pass to.
  106634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106635. * @param engine The engine which the post process will be applied. (default: current engine)
  106636. * @param reusable If the post process can be reused on the same frame. (default: false)
  106637. * @param textureType Type of textures used when performing the post process. (default: 0)
  106638. * @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)
  106639. */
  106640. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106641. /**
  106642. * Disposes the post process.
  106643. * @param camera The camera to dispose the post process on.
  106644. */
  106645. dispose(camera?: Camera): void;
  106646. }
  106647. }
  106648. declare module BABYLON {
  106649. /** @hidden */
  106650. export var refractionPixelShader: {
  106651. name: string;
  106652. shader: string;
  106653. };
  106654. }
  106655. declare module BABYLON {
  106656. /**
  106657. * Post process which applies a refractin texture
  106658. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106659. */
  106660. export class RefractionPostProcess extends PostProcess {
  106661. /** the base color of the refraction (used to taint the rendering) */
  106662. color: Color3;
  106663. /** simulated refraction depth */
  106664. depth: number;
  106665. /** the coefficient of the base color (0 to remove base color tainting) */
  106666. colorLevel: number;
  106667. private _refTexture;
  106668. private _ownRefractionTexture;
  106669. /**
  106670. * Gets or sets the refraction texture
  106671. * Please note that you are responsible for disposing the texture if you set it manually
  106672. */
  106673. refractionTexture: Texture;
  106674. /**
  106675. * Initializes the RefractionPostProcess
  106676. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106677. * @param name The name of the effect.
  106678. * @param refractionTextureUrl Url of the refraction texture to use
  106679. * @param color the base color of the refraction (used to taint the rendering)
  106680. * @param depth simulated refraction depth
  106681. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  106682. * @param camera The camera to apply the render pass to.
  106683. * @param options The required width/height ratio to downsize to before computing the render pass.
  106684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106685. * @param engine The engine which the post process will be applied. (default: current engine)
  106686. * @param reusable If the post process can be reused on the same frame. (default: false)
  106687. */
  106688. constructor(name: string, refractionTextureUrl: string,
  106689. /** the base color of the refraction (used to taint the rendering) */
  106690. color: Color3,
  106691. /** simulated refraction depth */
  106692. depth: number,
  106693. /** the coefficient of the base color (0 to remove base color tainting) */
  106694. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106695. /**
  106696. * Disposes of the post process
  106697. * @param camera Camera to dispose post process on
  106698. */
  106699. dispose(camera: Camera): void;
  106700. }
  106701. }
  106702. declare module BABYLON {
  106703. /** @hidden */
  106704. export var sharpenPixelShader: {
  106705. name: string;
  106706. shader: string;
  106707. };
  106708. }
  106709. declare module BABYLON {
  106710. /**
  106711. * The SharpenPostProcess applies a sharpen kernel to every pixel
  106712. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106713. */
  106714. export class SharpenPostProcess extends PostProcess {
  106715. /**
  106716. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  106717. */
  106718. colorAmount: number;
  106719. /**
  106720. * How much sharpness should be applied (default: 0.3)
  106721. */
  106722. edgeAmount: number;
  106723. /**
  106724. * Creates a new instance ConvolutionPostProcess
  106725. * @param name The name of the effect.
  106726. * @param options The required width/height ratio to downsize to before computing the render pass.
  106727. * @param camera The camera to apply the render pass to.
  106728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106729. * @param engine The engine which the post process will be applied. (default: current engine)
  106730. * @param reusable If the post process can be reused on the same frame. (default: false)
  106731. * @param textureType Type of textures used when performing the post process. (default: 0)
  106732. * @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)
  106733. */
  106734. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106735. }
  106736. }
  106737. declare module BABYLON {
  106738. /**
  106739. * PostProcessRenderPipeline
  106740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106741. */
  106742. export class PostProcessRenderPipeline {
  106743. private engine;
  106744. private _renderEffects;
  106745. private _renderEffectsForIsolatedPass;
  106746. /**
  106747. * @hidden
  106748. */
  106749. protected _cameras: Camera[];
  106750. /** @hidden */
  106751. _name: string;
  106752. /**
  106753. * Initializes a PostProcessRenderPipeline
  106754. * @param engine engine to add the pipeline to
  106755. * @param name name of the pipeline
  106756. */
  106757. constructor(engine: Engine, name: string);
  106758. /**
  106759. * "PostProcessRenderPipeline"
  106760. * @returns "PostProcessRenderPipeline"
  106761. */
  106762. getClassName(): string;
  106763. /**
  106764. * If all the render effects in the pipeline are support
  106765. */
  106766. readonly isSupported: boolean;
  106767. /**
  106768. * Adds an effect to the pipeline
  106769. * @param renderEffect the effect to add
  106770. */
  106771. addEffect(renderEffect: PostProcessRenderEffect): void;
  106772. /** @hidden */
  106773. _rebuild(): void;
  106774. /** @hidden */
  106775. _enableEffect(renderEffectName: string, cameras: Camera): void;
  106776. /** @hidden */
  106777. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  106778. /** @hidden */
  106779. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106780. /** @hidden */
  106781. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106782. /** @hidden */
  106783. _attachCameras(cameras: Camera, unique: boolean): void;
  106784. /** @hidden */
  106785. _attachCameras(cameras: Camera[], unique: boolean): void;
  106786. /** @hidden */
  106787. _detachCameras(cameras: Camera): void;
  106788. /** @hidden */
  106789. _detachCameras(cameras: Nullable<Camera[]>): void;
  106790. /** @hidden */
  106791. _update(): void;
  106792. /** @hidden */
  106793. _reset(): void;
  106794. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  106795. /**
  106796. * Disposes of the pipeline
  106797. */
  106798. dispose(): void;
  106799. }
  106800. }
  106801. declare module BABYLON {
  106802. /**
  106803. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  106804. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  106805. */
  106806. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  106807. private _scene;
  106808. private _camerasToBeAttached;
  106809. /**
  106810. * ID of the sharpen post process,
  106811. */
  106812. private readonly SharpenPostProcessId;
  106813. /**
  106814. * @ignore
  106815. * ID of the image processing post process;
  106816. */
  106817. readonly ImageProcessingPostProcessId: string;
  106818. /**
  106819. * @ignore
  106820. * ID of the Fast Approximate Anti-Aliasing post process;
  106821. */
  106822. readonly FxaaPostProcessId: string;
  106823. /**
  106824. * ID of the chromatic aberration post process,
  106825. */
  106826. private readonly ChromaticAberrationPostProcessId;
  106827. /**
  106828. * ID of the grain post process
  106829. */
  106830. private readonly GrainPostProcessId;
  106831. /**
  106832. * Sharpen post process which will apply a sharpen convolution to enhance edges
  106833. */
  106834. sharpen: SharpenPostProcess;
  106835. private _sharpenEffect;
  106836. private bloom;
  106837. /**
  106838. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  106839. */
  106840. depthOfField: DepthOfFieldEffect;
  106841. /**
  106842. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  106843. */
  106844. fxaa: FxaaPostProcess;
  106845. /**
  106846. * Image post processing pass used to perform operations such as tone mapping or color grading.
  106847. */
  106848. imageProcessing: ImageProcessingPostProcess;
  106849. /**
  106850. * Chromatic aberration post process which will shift rgb colors in the image
  106851. */
  106852. chromaticAberration: ChromaticAberrationPostProcess;
  106853. private _chromaticAberrationEffect;
  106854. /**
  106855. * Grain post process which add noise to the image
  106856. */
  106857. grain: GrainPostProcess;
  106858. private _grainEffect;
  106859. /**
  106860. * Glow post process which adds a glow to emmisive areas of the image
  106861. */
  106862. private _glowLayer;
  106863. /**
  106864. * Animations which can be used to tweak settings over a period of time
  106865. */
  106866. animations: Animation[];
  106867. private _imageProcessingConfigurationObserver;
  106868. private _sharpenEnabled;
  106869. private _bloomEnabled;
  106870. private _depthOfFieldEnabled;
  106871. private _depthOfFieldBlurLevel;
  106872. private _fxaaEnabled;
  106873. private _imageProcessingEnabled;
  106874. private _defaultPipelineTextureType;
  106875. private _bloomScale;
  106876. private _chromaticAberrationEnabled;
  106877. private _grainEnabled;
  106878. private _buildAllowed;
  106879. /**
  106880. * Enable or disable the sharpen process from the pipeline
  106881. */
  106882. sharpenEnabled: boolean;
  106883. private _resizeObserver;
  106884. private _hardwareScaleLevel;
  106885. private _bloomKernel;
  106886. /**
  106887. * Specifies the size of the bloom blur kernel, relative to the final output size
  106888. */
  106889. bloomKernel: number;
  106890. /**
  106891. * Specifies the weight of the bloom in the final rendering
  106892. */
  106893. private _bloomWeight;
  106894. /**
  106895. * Specifies the luma threshold for the area that will be blurred by the bloom
  106896. */
  106897. private _bloomThreshold;
  106898. private _hdr;
  106899. /**
  106900. * The strength of the bloom.
  106901. */
  106902. bloomWeight: number;
  106903. /**
  106904. * The strength of the bloom.
  106905. */
  106906. bloomThreshold: number;
  106907. /**
  106908. * The scale of the bloom, lower value will provide better performance.
  106909. */
  106910. bloomScale: number;
  106911. /**
  106912. * Enable or disable the bloom from the pipeline
  106913. */
  106914. bloomEnabled: boolean;
  106915. private _rebuildBloom;
  106916. /**
  106917. * If the depth of field is enabled.
  106918. */
  106919. depthOfFieldEnabled: boolean;
  106920. /**
  106921. * Blur level of the depth of field effect. (Higher blur will effect performance)
  106922. */
  106923. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  106924. /**
  106925. * If the anti aliasing is enabled.
  106926. */
  106927. fxaaEnabled: boolean;
  106928. private _samples;
  106929. /**
  106930. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  106931. */
  106932. samples: number;
  106933. /**
  106934. * If image processing is enabled.
  106935. */
  106936. imageProcessingEnabled: boolean;
  106937. /**
  106938. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  106939. */
  106940. glowLayerEnabled: boolean;
  106941. /**
  106942. * Enable or disable the chromaticAberration process from the pipeline
  106943. */
  106944. chromaticAberrationEnabled: boolean;
  106945. /**
  106946. * Enable or disable the grain process from the pipeline
  106947. */
  106948. grainEnabled: boolean;
  106949. /**
  106950. * @constructor
  106951. * @param name - The rendering pipeline name (default: "")
  106952. * @param hdr - If high dynamic range textures should be used (default: true)
  106953. * @param scene - The scene linked to this pipeline (default: the last created scene)
  106954. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  106955. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  106956. */
  106957. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  106958. /**
  106959. * Force the compilation of the entire pipeline.
  106960. */
  106961. prepare(): void;
  106962. private _hasCleared;
  106963. private _prevPostProcess;
  106964. private _prevPrevPostProcess;
  106965. private _setAutoClearAndTextureSharing;
  106966. private _depthOfFieldSceneObserver;
  106967. private _buildPipeline;
  106968. private _disposePostProcesses;
  106969. /**
  106970. * Adds a camera to the pipeline
  106971. * @param camera the camera to be added
  106972. */
  106973. addCamera(camera: Camera): void;
  106974. /**
  106975. * Removes a camera from the pipeline
  106976. * @param camera the camera to remove
  106977. */
  106978. removeCamera(camera: Camera): void;
  106979. /**
  106980. * Dispose of the pipeline and stop all post processes
  106981. */
  106982. dispose(): void;
  106983. /**
  106984. * Serialize the rendering pipeline (Used when exporting)
  106985. * @returns the serialized object
  106986. */
  106987. serialize(): any;
  106988. /**
  106989. * Parse the serialized pipeline
  106990. * @param source Source pipeline.
  106991. * @param scene The scene to load the pipeline to.
  106992. * @param rootUrl The URL of the serialized pipeline.
  106993. * @returns An instantiated pipeline from the serialized object.
  106994. */
  106995. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  106996. }
  106997. }
  106998. declare module BABYLON {
  106999. /** @hidden */
  107000. export var lensHighlightsPixelShader: {
  107001. name: string;
  107002. shader: string;
  107003. };
  107004. }
  107005. declare module BABYLON {
  107006. /** @hidden */
  107007. export var depthOfFieldPixelShader: {
  107008. name: string;
  107009. shader: string;
  107010. };
  107011. }
  107012. declare module BABYLON {
  107013. /**
  107014. * BABYLON.JS Chromatic Aberration GLSL Shader
  107015. * Author: Olivier Guyot
  107016. * Separates very slightly R, G and B colors on the edges of the screen
  107017. * Inspired by Francois Tarlier & Martins Upitis
  107018. */
  107019. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  107020. /**
  107021. * @ignore
  107022. * The chromatic aberration PostProcess id in the pipeline
  107023. */
  107024. LensChromaticAberrationEffect: string;
  107025. /**
  107026. * @ignore
  107027. * The highlights enhancing PostProcess id in the pipeline
  107028. */
  107029. HighlightsEnhancingEffect: string;
  107030. /**
  107031. * @ignore
  107032. * The depth-of-field PostProcess id in the pipeline
  107033. */
  107034. LensDepthOfFieldEffect: string;
  107035. private _scene;
  107036. private _depthTexture;
  107037. private _grainTexture;
  107038. private _chromaticAberrationPostProcess;
  107039. private _highlightsPostProcess;
  107040. private _depthOfFieldPostProcess;
  107041. private _edgeBlur;
  107042. private _grainAmount;
  107043. private _chromaticAberration;
  107044. private _distortion;
  107045. private _highlightsGain;
  107046. private _highlightsThreshold;
  107047. private _dofDistance;
  107048. private _dofAperture;
  107049. private _dofDarken;
  107050. private _dofPentagon;
  107051. private _blurNoise;
  107052. /**
  107053. * @constructor
  107054. *
  107055. * Effect parameters are as follow:
  107056. * {
  107057. * chromatic_aberration: number; // from 0 to x (1 for realism)
  107058. * edge_blur: number; // from 0 to x (1 for realism)
  107059. * distortion: number; // from 0 to x (1 for realism)
  107060. * grain_amount: number; // from 0 to 1
  107061. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  107062. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  107063. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  107064. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  107065. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  107066. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  107067. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  107068. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  107069. * }
  107070. * Note: if an effect parameter is unset, effect is disabled
  107071. *
  107072. * @param name The rendering pipeline name
  107073. * @param parameters - An object containing all parameters (see above)
  107074. * @param scene The scene linked to this pipeline
  107075. * @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)
  107076. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107077. */
  107078. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  107079. /**
  107080. * Sets the amount of blur at the edges
  107081. * @param amount blur amount
  107082. */
  107083. setEdgeBlur(amount: number): void;
  107084. /**
  107085. * Sets edge blur to 0
  107086. */
  107087. disableEdgeBlur(): void;
  107088. /**
  107089. * Sets the amout of grain
  107090. * @param amount Amount of grain
  107091. */
  107092. setGrainAmount(amount: number): void;
  107093. /**
  107094. * Set grain amount to 0
  107095. */
  107096. disableGrain(): void;
  107097. /**
  107098. * Sets the chromatic aberration amount
  107099. * @param amount amount of chromatic aberration
  107100. */
  107101. setChromaticAberration(amount: number): void;
  107102. /**
  107103. * Sets chromatic aberration amount to 0
  107104. */
  107105. disableChromaticAberration(): void;
  107106. /**
  107107. * Sets the EdgeDistortion amount
  107108. * @param amount amount of EdgeDistortion
  107109. */
  107110. setEdgeDistortion(amount: number): void;
  107111. /**
  107112. * Sets edge distortion to 0
  107113. */
  107114. disableEdgeDistortion(): void;
  107115. /**
  107116. * Sets the FocusDistance amount
  107117. * @param amount amount of FocusDistance
  107118. */
  107119. setFocusDistance(amount: number): void;
  107120. /**
  107121. * Disables depth of field
  107122. */
  107123. disableDepthOfField(): void;
  107124. /**
  107125. * Sets the Aperture amount
  107126. * @param amount amount of Aperture
  107127. */
  107128. setAperture(amount: number): void;
  107129. /**
  107130. * Sets the DarkenOutOfFocus amount
  107131. * @param amount amount of DarkenOutOfFocus
  107132. */
  107133. setDarkenOutOfFocus(amount: number): void;
  107134. /**
  107135. * Creates a pentagon bokeh effect
  107136. */
  107137. enablePentagonBokeh(): void;
  107138. /**
  107139. * Disables the pentagon bokeh effect
  107140. */
  107141. disablePentagonBokeh(): void;
  107142. /**
  107143. * Enables noise blur
  107144. */
  107145. enableNoiseBlur(): void;
  107146. /**
  107147. * Disables noise blur
  107148. */
  107149. disableNoiseBlur(): void;
  107150. /**
  107151. * Sets the HighlightsGain amount
  107152. * @param amount amount of HighlightsGain
  107153. */
  107154. setHighlightsGain(amount: number): void;
  107155. /**
  107156. * Sets the HighlightsThreshold amount
  107157. * @param amount amount of HighlightsThreshold
  107158. */
  107159. setHighlightsThreshold(amount: number): void;
  107160. /**
  107161. * Disables highlights
  107162. */
  107163. disableHighlights(): void;
  107164. /**
  107165. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  107166. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  107167. */
  107168. dispose(disableDepthRender?: boolean): void;
  107169. private _createChromaticAberrationPostProcess;
  107170. private _createHighlightsPostProcess;
  107171. private _createDepthOfFieldPostProcess;
  107172. private _createGrainTexture;
  107173. }
  107174. }
  107175. declare module BABYLON {
  107176. /** @hidden */
  107177. export var ssao2PixelShader: {
  107178. name: string;
  107179. shader: string;
  107180. };
  107181. }
  107182. declare module BABYLON {
  107183. /** @hidden */
  107184. export var ssaoCombinePixelShader: {
  107185. name: string;
  107186. shader: string;
  107187. };
  107188. }
  107189. declare module BABYLON {
  107190. /**
  107191. * Render pipeline to produce ssao effect
  107192. */
  107193. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  107194. /**
  107195. * @ignore
  107196. * The PassPostProcess id in the pipeline that contains the original scene color
  107197. */
  107198. SSAOOriginalSceneColorEffect: string;
  107199. /**
  107200. * @ignore
  107201. * The SSAO PostProcess id in the pipeline
  107202. */
  107203. SSAORenderEffect: string;
  107204. /**
  107205. * @ignore
  107206. * The horizontal blur PostProcess id in the pipeline
  107207. */
  107208. SSAOBlurHRenderEffect: string;
  107209. /**
  107210. * @ignore
  107211. * The vertical blur PostProcess id in the pipeline
  107212. */
  107213. SSAOBlurVRenderEffect: string;
  107214. /**
  107215. * @ignore
  107216. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107217. */
  107218. SSAOCombineRenderEffect: string;
  107219. /**
  107220. * The output strength of the SSAO post-process. Default value is 1.0.
  107221. */
  107222. totalStrength: number;
  107223. /**
  107224. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  107225. */
  107226. maxZ: number;
  107227. /**
  107228. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  107229. */
  107230. minZAspect: number;
  107231. private _samples;
  107232. /**
  107233. * Number of samples used for the SSAO calculations. Default value is 8
  107234. */
  107235. samples: number;
  107236. private _textureSamples;
  107237. /**
  107238. * Number of samples to use for antialiasing
  107239. */
  107240. textureSamples: number;
  107241. /**
  107242. * Ratio object used for SSAO ratio and blur ratio
  107243. */
  107244. private _ratio;
  107245. /**
  107246. * Dynamically generated sphere sampler.
  107247. */
  107248. private _sampleSphere;
  107249. /**
  107250. * Blur filter offsets
  107251. */
  107252. private _samplerOffsets;
  107253. private _expensiveBlur;
  107254. /**
  107255. * If bilateral blur should be used
  107256. */
  107257. expensiveBlur: boolean;
  107258. /**
  107259. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  107260. */
  107261. radius: number;
  107262. /**
  107263. * The base color of the SSAO post-process
  107264. * The final result is "base + ssao" between [0, 1]
  107265. */
  107266. base: number;
  107267. /**
  107268. * Support test.
  107269. */
  107270. static readonly IsSupported: boolean;
  107271. private _scene;
  107272. private _depthTexture;
  107273. private _normalTexture;
  107274. private _randomTexture;
  107275. private _originalColorPostProcess;
  107276. private _ssaoPostProcess;
  107277. private _blurHPostProcess;
  107278. private _blurVPostProcess;
  107279. private _ssaoCombinePostProcess;
  107280. private _firstUpdate;
  107281. /**
  107282. * @constructor
  107283. * @param name The rendering pipeline name
  107284. * @param scene The scene linked to this pipeline
  107285. * @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 }
  107286. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107287. */
  107288. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107289. /**
  107290. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107291. */
  107292. dispose(disableGeometryBufferRenderer?: boolean): void;
  107293. private _createBlurPostProcess;
  107294. /** @hidden */
  107295. _rebuild(): void;
  107296. private _bits;
  107297. private _radicalInverse_VdC;
  107298. private _hammersley;
  107299. private _hemisphereSample_uniform;
  107300. private _generateHemisphere;
  107301. private _createSSAOPostProcess;
  107302. private _createSSAOCombinePostProcess;
  107303. private _createRandomTexture;
  107304. /**
  107305. * Serialize the rendering pipeline (Used when exporting)
  107306. * @returns the serialized object
  107307. */
  107308. serialize(): any;
  107309. /**
  107310. * Parse the serialized pipeline
  107311. * @param source Source pipeline.
  107312. * @param scene The scene to load the pipeline to.
  107313. * @param rootUrl The URL of the serialized pipeline.
  107314. * @returns An instantiated pipeline from the serialized object.
  107315. */
  107316. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  107317. }
  107318. }
  107319. declare module BABYLON {
  107320. /** @hidden */
  107321. export var ssaoPixelShader: {
  107322. name: string;
  107323. shader: string;
  107324. };
  107325. }
  107326. declare module BABYLON {
  107327. /**
  107328. * Render pipeline to produce ssao effect
  107329. */
  107330. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  107331. /**
  107332. * @ignore
  107333. * The PassPostProcess id in the pipeline that contains the original scene color
  107334. */
  107335. SSAOOriginalSceneColorEffect: string;
  107336. /**
  107337. * @ignore
  107338. * The SSAO PostProcess id in the pipeline
  107339. */
  107340. SSAORenderEffect: string;
  107341. /**
  107342. * @ignore
  107343. * The horizontal blur PostProcess id in the pipeline
  107344. */
  107345. SSAOBlurHRenderEffect: string;
  107346. /**
  107347. * @ignore
  107348. * The vertical blur PostProcess id in the pipeline
  107349. */
  107350. SSAOBlurVRenderEffect: string;
  107351. /**
  107352. * @ignore
  107353. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107354. */
  107355. SSAOCombineRenderEffect: string;
  107356. /**
  107357. * The output strength of the SSAO post-process. Default value is 1.0.
  107358. */
  107359. totalStrength: number;
  107360. /**
  107361. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  107362. */
  107363. radius: number;
  107364. /**
  107365. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  107366. * Must not be equal to fallOff and superior to fallOff.
  107367. * Default value is 0.975
  107368. */
  107369. area: number;
  107370. /**
  107371. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  107372. * Must not be equal to area and inferior to area.
  107373. * Default value is 0.0
  107374. */
  107375. fallOff: number;
  107376. /**
  107377. * The base color of the SSAO post-process
  107378. * The final result is "base + ssao" between [0, 1]
  107379. */
  107380. base: number;
  107381. private _scene;
  107382. private _depthTexture;
  107383. private _randomTexture;
  107384. private _originalColorPostProcess;
  107385. private _ssaoPostProcess;
  107386. private _blurHPostProcess;
  107387. private _blurVPostProcess;
  107388. private _ssaoCombinePostProcess;
  107389. private _firstUpdate;
  107390. /**
  107391. * @constructor
  107392. * @param name - The rendering pipeline name
  107393. * @param scene - The scene linked to this pipeline
  107394. * @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 }
  107395. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  107396. */
  107397. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107398. /**
  107399. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107400. */
  107401. dispose(disableDepthRender?: boolean): void;
  107402. private _createBlurPostProcess;
  107403. /** @hidden */
  107404. _rebuild(): void;
  107405. private _createSSAOPostProcess;
  107406. private _createSSAOCombinePostProcess;
  107407. private _createRandomTexture;
  107408. }
  107409. }
  107410. declare module BABYLON {
  107411. /** @hidden */
  107412. export var standardPixelShader: {
  107413. name: string;
  107414. shader: string;
  107415. };
  107416. }
  107417. declare module BABYLON {
  107418. /**
  107419. * Standard rendering pipeline
  107420. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107421. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  107422. */
  107423. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107424. /**
  107425. * Public members
  107426. */
  107427. /**
  107428. * Post-process which contains the original scene color before the pipeline applies all the effects
  107429. */
  107430. originalPostProcess: Nullable<PostProcess>;
  107431. /**
  107432. * Post-process used to down scale an image x4
  107433. */
  107434. downSampleX4PostProcess: Nullable<PostProcess>;
  107435. /**
  107436. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  107437. */
  107438. brightPassPostProcess: Nullable<PostProcess>;
  107439. /**
  107440. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  107441. */
  107442. blurHPostProcesses: PostProcess[];
  107443. /**
  107444. * Post-process array storing all the vertical blur post-processes used by the pipeline
  107445. */
  107446. blurVPostProcesses: PostProcess[];
  107447. /**
  107448. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  107449. */
  107450. textureAdderPostProcess: Nullable<PostProcess>;
  107451. /**
  107452. * Post-process used to create volumetric lighting effect
  107453. */
  107454. volumetricLightPostProcess: Nullable<PostProcess>;
  107455. /**
  107456. * Post-process used to smooth the previous volumetric light post-process on the X axis
  107457. */
  107458. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  107459. /**
  107460. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  107461. */
  107462. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  107463. /**
  107464. * Post-process used to merge the volumetric light effect and the real scene color
  107465. */
  107466. volumetricLightMergePostProces: Nullable<PostProcess>;
  107467. /**
  107468. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  107469. */
  107470. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  107471. /**
  107472. * Base post-process used to calculate the average luminance of the final image for HDR
  107473. */
  107474. luminancePostProcess: Nullable<PostProcess>;
  107475. /**
  107476. * Post-processes used to create down sample post-processes in order to get
  107477. * the average luminance of the final image for HDR
  107478. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  107479. */
  107480. luminanceDownSamplePostProcesses: PostProcess[];
  107481. /**
  107482. * Post-process used to create a HDR effect (light adaptation)
  107483. */
  107484. hdrPostProcess: Nullable<PostProcess>;
  107485. /**
  107486. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  107487. */
  107488. textureAdderFinalPostProcess: Nullable<PostProcess>;
  107489. /**
  107490. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  107491. */
  107492. lensFlareFinalPostProcess: Nullable<PostProcess>;
  107493. /**
  107494. * Post-process used to merge the final HDR post-process and the real scene color
  107495. */
  107496. hdrFinalPostProcess: Nullable<PostProcess>;
  107497. /**
  107498. * Post-process used to create a lens flare effect
  107499. */
  107500. lensFlarePostProcess: Nullable<PostProcess>;
  107501. /**
  107502. * Post-process that merges the result of the lens flare post-process and the real scene color
  107503. */
  107504. lensFlareComposePostProcess: Nullable<PostProcess>;
  107505. /**
  107506. * Post-process used to create a motion blur effect
  107507. */
  107508. motionBlurPostProcess: Nullable<PostProcess>;
  107509. /**
  107510. * Post-process used to create a depth of field effect
  107511. */
  107512. depthOfFieldPostProcess: Nullable<PostProcess>;
  107513. /**
  107514. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107515. */
  107516. fxaaPostProcess: Nullable<FxaaPostProcess>;
  107517. /**
  107518. * Represents the brightness threshold in order to configure the illuminated surfaces
  107519. */
  107520. brightThreshold: number;
  107521. /**
  107522. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  107523. */
  107524. blurWidth: number;
  107525. /**
  107526. * Sets if the blur for highlighted surfaces must be only horizontal
  107527. */
  107528. horizontalBlur: boolean;
  107529. /**
  107530. * Sets the overall exposure used by the pipeline
  107531. */
  107532. exposure: number;
  107533. /**
  107534. * Texture used typically to simulate "dirty" on camera lens
  107535. */
  107536. lensTexture: Nullable<Texture>;
  107537. /**
  107538. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  107539. */
  107540. volumetricLightCoefficient: number;
  107541. /**
  107542. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  107543. */
  107544. volumetricLightPower: number;
  107545. /**
  107546. * Used the set the blur intensity to smooth the volumetric lights
  107547. */
  107548. volumetricLightBlurScale: number;
  107549. /**
  107550. * Light (spot or directional) used to generate the volumetric lights rays
  107551. * The source light must have a shadow generate so the pipeline can get its
  107552. * depth map
  107553. */
  107554. sourceLight: Nullable<SpotLight | DirectionalLight>;
  107555. /**
  107556. * For eye adaptation, represents the minimum luminance the eye can see
  107557. */
  107558. hdrMinimumLuminance: number;
  107559. /**
  107560. * For eye adaptation, represents the decrease luminance speed
  107561. */
  107562. hdrDecreaseRate: number;
  107563. /**
  107564. * For eye adaptation, represents the increase luminance speed
  107565. */
  107566. hdrIncreaseRate: number;
  107567. /**
  107568. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  107569. */
  107570. lensColorTexture: Nullable<Texture>;
  107571. /**
  107572. * The overall strengh for the lens flare effect
  107573. */
  107574. lensFlareStrength: number;
  107575. /**
  107576. * Dispersion coefficient for lens flare ghosts
  107577. */
  107578. lensFlareGhostDispersal: number;
  107579. /**
  107580. * Main lens flare halo width
  107581. */
  107582. lensFlareHaloWidth: number;
  107583. /**
  107584. * Based on the lens distortion effect, defines how much the lens flare result
  107585. * is distorted
  107586. */
  107587. lensFlareDistortionStrength: number;
  107588. /**
  107589. * Lens star texture must be used to simulate rays on the flares and is available
  107590. * in the documentation
  107591. */
  107592. lensStarTexture: Nullable<Texture>;
  107593. /**
  107594. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  107595. * flare effect by taking account of the dirt texture
  107596. */
  107597. lensFlareDirtTexture: Nullable<Texture>;
  107598. /**
  107599. * Represents the focal length for the depth of field effect
  107600. */
  107601. depthOfFieldDistance: number;
  107602. /**
  107603. * Represents the blur intensity for the blurred part of the depth of field effect
  107604. */
  107605. depthOfFieldBlurWidth: number;
  107606. /**
  107607. * For motion blur, defines how much the image is blurred by the movement
  107608. */
  107609. motionStrength: number;
  107610. /**
  107611. * List of animations for the pipeline (IAnimatable implementation)
  107612. */
  107613. animations: Animation[];
  107614. /**
  107615. * Private members
  107616. */
  107617. private _scene;
  107618. private _currentDepthOfFieldSource;
  107619. private _basePostProcess;
  107620. private _hdrCurrentLuminance;
  107621. private _floatTextureType;
  107622. private _ratio;
  107623. private _bloomEnabled;
  107624. private _depthOfFieldEnabled;
  107625. private _vlsEnabled;
  107626. private _lensFlareEnabled;
  107627. private _hdrEnabled;
  107628. private _motionBlurEnabled;
  107629. private _fxaaEnabled;
  107630. private _motionBlurSamples;
  107631. private _volumetricLightStepsCount;
  107632. private _samples;
  107633. /**
  107634. * @ignore
  107635. * Specifies if the bloom pipeline is enabled
  107636. */
  107637. BloomEnabled: boolean;
  107638. /**
  107639. * @ignore
  107640. * Specifies if the depth of field pipeline is enabed
  107641. */
  107642. DepthOfFieldEnabled: boolean;
  107643. /**
  107644. * @ignore
  107645. * Specifies if the lens flare pipeline is enabed
  107646. */
  107647. LensFlareEnabled: boolean;
  107648. /**
  107649. * @ignore
  107650. * Specifies if the HDR pipeline is enabled
  107651. */
  107652. HDREnabled: boolean;
  107653. /**
  107654. * @ignore
  107655. * Specifies if the volumetric lights scattering effect is enabled
  107656. */
  107657. VLSEnabled: boolean;
  107658. /**
  107659. * @ignore
  107660. * Specifies if the motion blur effect is enabled
  107661. */
  107662. MotionBlurEnabled: boolean;
  107663. /**
  107664. * Specifies if anti-aliasing is enabled
  107665. */
  107666. fxaaEnabled: boolean;
  107667. /**
  107668. * Specifies the number of steps used to calculate the volumetric lights
  107669. * Typically in interval [50, 200]
  107670. */
  107671. volumetricLightStepsCount: number;
  107672. /**
  107673. * Specifies the number of samples used for the motion blur effect
  107674. * Typically in interval [16, 64]
  107675. */
  107676. motionBlurSamples: number;
  107677. /**
  107678. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107679. */
  107680. samples: number;
  107681. /**
  107682. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107683. * @constructor
  107684. * @param name The rendering pipeline name
  107685. * @param scene The scene linked to this pipeline
  107686. * @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)
  107687. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  107688. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107689. */
  107690. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  107691. private _buildPipeline;
  107692. private _createDownSampleX4PostProcess;
  107693. private _createBrightPassPostProcess;
  107694. private _createBlurPostProcesses;
  107695. private _createTextureAdderPostProcess;
  107696. private _createVolumetricLightPostProcess;
  107697. private _createLuminancePostProcesses;
  107698. private _createHdrPostProcess;
  107699. private _createLensFlarePostProcess;
  107700. private _createDepthOfFieldPostProcess;
  107701. private _createMotionBlurPostProcess;
  107702. private _getDepthTexture;
  107703. private _disposePostProcesses;
  107704. /**
  107705. * Dispose of the pipeline and stop all post processes
  107706. */
  107707. dispose(): void;
  107708. /**
  107709. * Serialize the rendering pipeline (Used when exporting)
  107710. * @returns the serialized object
  107711. */
  107712. serialize(): any;
  107713. /**
  107714. * Parse the serialized pipeline
  107715. * @param source Source pipeline.
  107716. * @param scene The scene to load the pipeline to.
  107717. * @param rootUrl The URL of the serialized pipeline.
  107718. * @returns An instantiated pipeline from the serialized object.
  107719. */
  107720. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  107721. /**
  107722. * Luminance steps
  107723. */
  107724. static LuminanceSteps: number;
  107725. }
  107726. }
  107727. declare module BABYLON {
  107728. /**
  107729. * PostProcessRenderPipelineManager class
  107730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107731. */
  107732. export class PostProcessRenderPipelineManager {
  107733. private _renderPipelines;
  107734. /**
  107735. * Initializes a PostProcessRenderPipelineManager
  107736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107737. */
  107738. constructor();
  107739. /**
  107740. * Adds a pipeline to the manager
  107741. * @param renderPipeline The pipeline to add
  107742. */
  107743. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  107744. /**
  107745. * Attaches a camera to the pipeline
  107746. * @param renderPipelineName The name of the pipeline to attach to
  107747. * @param cameras the camera to attach
  107748. * @param unique if the camera can be attached multiple times to the pipeline
  107749. */
  107750. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  107751. /**
  107752. * Detaches a camera from the pipeline
  107753. * @param renderPipelineName The name of the pipeline to detach from
  107754. * @param cameras the camera to detach
  107755. */
  107756. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  107757. /**
  107758. * Enables an effect by name on a pipeline
  107759. * @param renderPipelineName the name of the pipeline to enable the effect in
  107760. * @param renderEffectName the name of the effect to enable
  107761. * @param cameras the cameras that the effect should be enabled on
  107762. */
  107763. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107764. /**
  107765. * Disables an effect by name on a pipeline
  107766. * @param renderPipelineName the name of the pipeline to disable the effect in
  107767. * @param renderEffectName the name of the effect to disable
  107768. * @param cameras the cameras that the effect should be disabled on
  107769. */
  107770. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107771. /**
  107772. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  107773. */
  107774. update(): void;
  107775. /** @hidden */
  107776. _rebuild(): void;
  107777. /**
  107778. * Disposes of the manager and pipelines
  107779. */
  107780. dispose(): void;
  107781. }
  107782. }
  107783. declare module BABYLON {
  107784. interface Scene {
  107785. /** @hidden (Backing field) */
  107786. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107787. /**
  107788. * Gets the postprocess render pipeline manager
  107789. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107790. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107791. */
  107792. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107793. }
  107794. /**
  107795. * Defines the Render Pipeline scene component responsible to rendering pipelines
  107796. */
  107797. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  107798. /**
  107799. * The component name helpfull to identify the component in the list of scene components.
  107800. */
  107801. readonly name: string;
  107802. /**
  107803. * The scene the component belongs to.
  107804. */
  107805. scene: Scene;
  107806. /**
  107807. * Creates a new instance of the component for the given scene
  107808. * @param scene Defines the scene to register the component in
  107809. */
  107810. constructor(scene: Scene);
  107811. /**
  107812. * Registers the component in a given scene
  107813. */
  107814. register(): void;
  107815. /**
  107816. * Rebuilds the elements related to this component in case of
  107817. * context lost for instance.
  107818. */
  107819. rebuild(): void;
  107820. /**
  107821. * Disposes the component and the associated ressources
  107822. */
  107823. dispose(): void;
  107824. private _gatherRenderTargets;
  107825. }
  107826. }
  107827. declare module BABYLON {
  107828. /** @hidden */
  107829. export var tonemapPixelShader: {
  107830. name: string;
  107831. shader: string;
  107832. };
  107833. }
  107834. declare module BABYLON {
  107835. /** Defines operator used for tonemapping */
  107836. export enum TonemappingOperator {
  107837. /** Hable */
  107838. Hable = 0,
  107839. /** Reinhard */
  107840. Reinhard = 1,
  107841. /** HejiDawson */
  107842. HejiDawson = 2,
  107843. /** Photographic */
  107844. Photographic = 3
  107845. }
  107846. /**
  107847. * Defines a post process to apply tone mapping
  107848. */
  107849. export class TonemapPostProcess extends PostProcess {
  107850. private _operator;
  107851. /** Defines the required exposure adjustement */
  107852. exposureAdjustment: number;
  107853. /**
  107854. * Creates a new TonemapPostProcess
  107855. * @param name defines the name of the postprocess
  107856. * @param _operator defines the operator to use
  107857. * @param exposureAdjustment defines the required exposure adjustement
  107858. * @param camera defines the camera to use (can be null)
  107859. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  107860. * @param engine defines the hosting engine (can be ignore if camera is set)
  107861. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107862. */
  107863. constructor(name: string, _operator: TonemappingOperator,
  107864. /** Defines the required exposure adjustement */
  107865. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  107866. }
  107867. }
  107868. declare module BABYLON {
  107869. /** @hidden */
  107870. export var depthVertexShader: {
  107871. name: string;
  107872. shader: string;
  107873. };
  107874. }
  107875. declare module BABYLON {
  107876. /** @hidden */
  107877. export var volumetricLightScatteringPixelShader: {
  107878. name: string;
  107879. shader: string;
  107880. };
  107881. }
  107882. declare module BABYLON {
  107883. /** @hidden */
  107884. export var volumetricLightScatteringPassPixelShader: {
  107885. name: string;
  107886. shader: string;
  107887. };
  107888. }
  107889. declare module BABYLON {
  107890. /**
  107891. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  107892. */
  107893. export class VolumetricLightScatteringPostProcess extends PostProcess {
  107894. private _volumetricLightScatteringPass;
  107895. private _volumetricLightScatteringRTT;
  107896. private _viewPort;
  107897. private _screenCoordinates;
  107898. private _cachedDefines;
  107899. /**
  107900. * If not undefined, the mesh position is computed from the attached node position
  107901. */
  107902. attachedNode: {
  107903. position: Vector3;
  107904. };
  107905. /**
  107906. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  107907. */
  107908. customMeshPosition: Vector3;
  107909. /**
  107910. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  107911. */
  107912. useCustomMeshPosition: boolean;
  107913. /**
  107914. * If the post-process should inverse the light scattering direction
  107915. */
  107916. invert: boolean;
  107917. /**
  107918. * The internal mesh used by the post-process
  107919. */
  107920. mesh: Mesh;
  107921. /**
  107922. * @hidden
  107923. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  107924. */
  107925. useDiffuseColor: boolean;
  107926. /**
  107927. * Array containing the excluded meshes not rendered in the internal pass
  107928. */
  107929. excludedMeshes: AbstractMesh[];
  107930. /**
  107931. * Controls the overall intensity of the post-process
  107932. */
  107933. exposure: number;
  107934. /**
  107935. * Dissipates each sample's contribution in range [0, 1]
  107936. */
  107937. decay: number;
  107938. /**
  107939. * Controls the overall intensity of each sample
  107940. */
  107941. weight: number;
  107942. /**
  107943. * Controls the density of each sample
  107944. */
  107945. density: number;
  107946. /**
  107947. * @constructor
  107948. * @param name The post-process name
  107949. * @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)
  107950. * @param camera The camera that the post-process will be attached to
  107951. * @param mesh The mesh used to create the light scattering
  107952. * @param samples The post-process quality, default 100
  107953. * @param samplingModeThe post-process filtering mode
  107954. * @param engine The babylon engine
  107955. * @param reusable If the post-process is reusable
  107956. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  107957. */
  107958. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  107959. /**
  107960. * Returns the string "VolumetricLightScatteringPostProcess"
  107961. * @returns "VolumetricLightScatteringPostProcess"
  107962. */
  107963. getClassName(): string;
  107964. private _isReady;
  107965. /**
  107966. * Sets the new light position for light scattering effect
  107967. * @param position The new custom light position
  107968. */
  107969. setCustomMeshPosition(position: Vector3): void;
  107970. /**
  107971. * Returns the light position for light scattering effect
  107972. * @return Vector3 The custom light position
  107973. */
  107974. getCustomMeshPosition(): Vector3;
  107975. /**
  107976. * Disposes the internal assets and detaches the post-process from the camera
  107977. */
  107978. dispose(camera: Camera): void;
  107979. /**
  107980. * Returns the render target texture used by the post-process
  107981. * @return the render target texture used by the post-process
  107982. */
  107983. getPass(): RenderTargetTexture;
  107984. private _meshExcluded;
  107985. private _createPass;
  107986. private _updateMeshScreenCoordinates;
  107987. /**
  107988. * Creates a default mesh for the Volumeric Light Scattering post-process
  107989. * @param name The mesh name
  107990. * @param scene The scene where to create the mesh
  107991. * @return the default mesh
  107992. */
  107993. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  107994. }
  107995. }
  107996. declare module BABYLON {
  107997. interface Scene {
  107998. /** @hidden (Backing field) */
  107999. _boundingBoxRenderer: BoundingBoxRenderer;
  108000. /** @hidden (Backing field) */
  108001. _forceShowBoundingBoxes: boolean;
  108002. /**
  108003. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  108004. */
  108005. forceShowBoundingBoxes: boolean;
  108006. /**
  108007. * Gets the bounding box renderer associated with the scene
  108008. * @returns a BoundingBoxRenderer
  108009. */
  108010. getBoundingBoxRenderer(): BoundingBoxRenderer;
  108011. }
  108012. interface AbstractMesh {
  108013. /** @hidden (Backing field) */
  108014. _showBoundingBox: boolean;
  108015. /**
  108016. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  108017. */
  108018. showBoundingBox: boolean;
  108019. }
  108020. /**
  108021. * Component responsible of rendering the bounding box of the meshes in a scene.
  108022. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  108023. */
  108024. export class BoundingBoxRenderer implements ISceneComponent {
  108025. /**
  108026. * The component name helpfull to identify the component in the list of scene components.
  108027. */
  108028. readonly name: string;
  108029. /**
  108030. * The scene the component belongs to.
  108031. */
  108032. scene: Scene;
  108033. /**
  108034. * Color of the bounding box lines placed in front of an object
  108035. */
  108036. frontColor: Color3;
  108037. /**
  108038. * Color of the bounding box lines placed behind an object
  108039. */
  108040. backColor: Color3;
  108041. /**
  108042. * Defines if the renderer should show the back lines or not
  108043. */
  108044. showBackLines: boolean;
  108045. /**
  108046. * @hidden
  108047. */
  108048. renderList: SmartArray<BoundingBox>;
  108049. private _colorShader;
  108050. private _vertexBuffers;
  108051. private _indexBuffer;
  108052. /**
  108053. * Instantiates a new bounding box renderer in a scene.
  108054. * @param scene the scene the renderer renders in
  108055. */
  108056. constructor(scene: Scene);
  108057. /**
  108058. * Registers the component in a given scene
  108059. */
  108060. register(): void;
  108061. private _evaluateSubMesh;
  108062. private _activeMesh;
  108063. private _prepareRessources;
  108064. private _createIndexBuffer;
  108065. /**
  108066. * Rebuilds the elements related to this component in case of
  108067. * context lost for instance.
  108068. */
  108069. rebuild(): void;
  108070. /**
  108071. * @hidden
  108072. */
  108073. reset(): void;
  108074. /**
  108075. * Render the bounding boxes of a specific rendering group
  108076. * @param renderingGroupId defines the rendering group to render
  108077. */
  108078. render(renderingGroupId: number): void;
  108079. /**
  108080. * In case of occlusion queries, we can render the occlusion bounding box through this method
  108081. * @param mesh Define the mesh to render the occlusion bounding box for
  108082. */
  108083. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  108084. /**
  108085. * Dispose and release the resources attached to this renderer.
  108086. */
  108087. dispose(): void;
  108088. }
  108089. }
  108090. declare module BABYLON {
  108091. /** @hidden */
  108092. export var depthPixelShader: {
  108093. name: string;
  108094. shader: string;
  108095. };
  108096. }
  108097. declare module BABYLON {
  108098. /**
  108099. * This represents a depth renderer in Babylon.
  108100. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  108101. */
  108102. export class DepthRenderer {
  108103. private _scene;
  108104. private _depthMap;
  108105. private _effect;
  108106. private _cachedDefines;
  108107. private _camera;
  108108. /**
  108109. * Specifiess that the depth renderer will only be used within
  108110. * the camera it is created for.
  108111. * This can help forcing its rendering during the camera processing.
  108112. */
  108113. useOnlyInActiveCamera: boolean;
  108114. /** @hidden */
  108115. static _SceneComponentInitialization: (scene: Scene) => void;
  108116. /**
  108117. * Instantiates a depth renderer
  108118. * @param scene The scene the renderer belongs to
  108119. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  108120. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  108121. */
  108122. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  108123. /**
  108124. * Creates the depth rendering effect and checks if the effect is ready.
  108125. * @param subMesh The submesh to be used to render the depth map of
  108126. * @param useInstances If multiple world instances should be used
  108127. * @returns if the depth renderer is ready to render the depth map
  108128. */
  108129. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108130. /**
  108131. * Gets the texture which the depth map will be written to.
  108132. * @returns The depth map texture
  108133. */
  108134. getDepthMap(): RenderTargetTexture;
  108135. /**
  108136. * Disposes of the depth renderer.
  108137. */
  108138. dispose(): void;
  108139. }
  108140. }
  108141. declare module BABYLON {
  108142. interface Scene {
  108143. /** @hidden (Backing field) */
  108144. _depthRenderer: {
  108145. [id: string]: DepthRenderer;
  108146. };
  108147. /**
  108148. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  108149. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  108150. * @returns the created depth renderer
  108151. */
  108152. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  108153. /**
  108154. * Disables a depth renderer for a given camera
  108155. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  108156. */
  108157. disableDepthRenderer(camera?: Nullable<Camera>): void;
  108158. }
  108159. /**
  108160. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  108161. * in several rendering techniques.
  108162. */
  108163. export class DepthRendererSceneComponent implements ISceneComponent {
  108164. /**
  108165. * The component name helpfull to identify the component in the list of scene components.
  108166. */
  108167. readonly name: string;
  108168. /**
  108169. * The scene the component belongs to.
  108170. */
  108171. scene: Scene;
  108172. /**
  108173. * Creates a new instance of the component for the given scene
  108174. * @param scene Defines the scene to register the component in
  108175. */
  108176. constructor(scene: Scene);
  108177. /**
  108178. * Registers the component in a given scene
  108179. */
  108180. register(): void;
  108181. /**
  108182. * Rebuilds the elements related to this component in case of
  108183. * context lost for instance.
  108184. */
  108185. rebuild(): void;
  108186. /**
  108187. * Disposes the component and the associated ressources
  108188. */
  108189. dispose(): void;
  108190. private _gatherRenderTargets;
  108191. private _gatherActiveCameraRenderTargets;
  108192. }
  108193. }
  108194. declare module BABYLON {
  108195. interface Scene {
  108196. /** @hidden (Backing field) */
  108197. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108198. /**
  108199. * Gets or Sets the current geometry buffer associated to the scene.
  108200. */
  108201. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108202. /**
  108203. * Enables a GeometryBufferRender and associates it with the scene
  108204. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108205. * @returns the GeometryBufferRenderer
  108206. */
  108207. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108208. /**
  108209. * Disables the GeometryBufferRender associated with the scene
  108210. */
  108211. disableGeometryBufferRenderer(): void;
  108212. }
  108213. /**
  108214. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108215. * in several rendering techniques.
  108216. */
  108217. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108218. /**
  108219. * The component name helpful to identify the component in the list of scene components.
  108220. */
  108221. readonly name: string;
  108222. /**
  108223. * The scene the component belongs to.
  108224. */
  108225. scene: Scene;
  108226. /**
  108227. * Creates a new instance of the component for the given scene
  108228. * @param scene Defines the scene to register the component in
  108229. */
  108230. constructor(scene: Scene);
  108231. /**
  108232. * Registers the component in a given scene
  108233. */
  108234. register(): void;
  108235. /**
  108236. * Rebuilds the elements related to this component in case of
  108237. * context lost for instance.
  108238. */
  108239. rebuild(): void;
  108240. /**
  108241. * Disposes the component and the associated ressources
  108242. */
  108243. dispose(): void;
  108244. private _gatherRenderTargets;
  108245. }
  108246. }
  108247. declare module BABYLON {
  108248. /** @hidden */
  108249. export var outlinePixelShader: {
  108250. name: string;
  108251. shader: string;
  108252. };
  108253. }
  108254. declare module BABYLON {
  108255. /** @hidden */
  108256. export var outlineVertexShader: {
  108257. name: string;
  108258. shader: string;
  108259. };
  108260. }
  108261. declare module BABYLON {
  108262. interface Scene {
  108263. /** @hidden */
  108264. _outlineRenderer: OutlineRenderer;
  108265. /**
  108266. * Gets the outline renderer associated with the scene
  108267. * @returns a OutlineRenderer
  108268. */
  108269. getOutlineRenderer(): OutlineRenderer;
  108270. }
  108271. interface AbstractMesh {
  108272. /** @hidden (Backing field) */
  108273. _renderOutline: boolean;
  108274. /**
  108275. * Gets or sets a boolean indicating if the outline must be rendered as well
  108276. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  108277. */
  108278. renderOutline: boolean;
  108279. /** @hidden (Backing field) */
  108280. _renderOverlay: boolean;
  108281. /**
  108282. * Gets or sets a boolean indicating if the overlay must be rendered as well
  108283. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  108284. */
  108285. renderOverlay: boolean;
  108286. }
  108287. /**
  108288. * This class is responsible to draw bothe outline/overlay of meshes.
  108289. * It should not be used directly but through the available method on mesh.
  108290. */
  108291. export class OutlineRenderer implements ISceneComponent {
  108292. /**
  108293. * The name of the component. Each component must have a unique name.
  108294. */
  108295. name: string;
  108296. /**
  108297. * The scene the component belongs to.
  108298. */
  108299. scene: Scene;
  108300. /**
  108301. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  108302. */
  108303. zOffset: number;
  108304. private _engine;
  108305. private _effect;
  108306. private _cachedDefines;
  108307. private _savedDepthWrite;
  108308. /**
  108309. * Instantiates a new outline renderer. (There could be only one per scene).
  108310. * @param scene Defines the scene it belongs to
  108311. */
  108312. constructor(scene: Scene);
  108313. /**
  108314. * Register the component to one instance of a scene.
  108315. */
  108316. register(): void;
  108317. /**
  108318. * Rebuilds the elements related to this component in case of
  108319. * context lost for instance.
  108320. */
  108321. rebuild(): void;
  108322. /**
  108323. * Disposes the component and the associated ressources.
  108324. */
  108325. dispose(): void;
  108326. /**
  108327. * Renders the outline in the canvas.
  108328. * @param subMesh Defines the sumesh to render
  108329. * @param batch Defines the batch of meshes in case of instances
  108330. * @param useOverlay Defines if the rendering is for the overlay or the outline
  108331. */
  108332. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  108333. /**
  108334. * Returns whether or not the outline renderer is ready for a given submesh.
  108335. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  108336. * @param subMesh Defines the submesh to check readyness for
  108337. * @param useInstances Defines wheter wee are trying to render instances or not
  108338. * @returns true if ready otherwise false
  108339. */
  108340. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108341. private _beforeRenderingMesh;
  108342. private _afterRenderingMesh;
  108343. }
  108344. }
  108345. declare module BABYLON {
  108346. /**
  108347. * Defines the list of states available for a task inside a AssetsManager
  108348. */
  108349. export enum AssetTaskState {
  108350. /**
  108351. * Initialization
  108352. */
  108353. INIT = 0,
  108354. /**
  108355. * Running
  108356. */
  108357. RUNNING = 1,
  108358. /**
  108359. * Done
  108360. */
  108361. DONE = 2,
  108362. /**
  108363. * Error
  108364. */
  108365. ERROR = 3
  108366. }
  108367. /**
  108368. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  108369. */
  108370. export abstract class AbstractAssetTask {
  108371. /**
  108372. * Task name
  108373. */ name: string;
  108374. /**
  108375. * Callback called when the task is successful
  108376. */
  108377. onSuccess: (task: any) => void;
  108378. /**
  108379. * Callback called when the task is not successful
  108380. */
  108381. onError: (task: any, message?: string, exception?: any) => void;
  108382. /**
  108383. * Creates a new AssetsManager
  108384. * @param name defines the name of the task
  108385. */
  108386. constructor(
  108387. /**
  108388. * Task name
  108389. */ name: string);
  108390. private _isCompleted;
  108391. private _taskState;
  108392. private _errorObject;
  108393. /**
  108394. * Get if the task is completed
  108395. */
  108396. readonly isCompleted: boolean;
  108397. /**
  108398. * Gets the current state of the task
  108399. */
  108400. readonly taskState: AssetTaskState;
  108401. /**
  108402. * Gets the current error object (if task is in error)
  108403. */
  108404. readonly errorObject: {
  108405. message?: string;
  108406. exception?: any;
  108407. };
  108408. /**
  108409. * Internal only
  108410. * @hidden
  108411. */
  108412. _setErrorObject(message?: string, exception?: any): void;
  108413. /**
  108414. * Execute the current task
  108415. * @param scene defines the scene where you want your assets to be loaded
  108416. * @param onSuccess is a callback called when the task is successfully executed
  108417. * @param onError is a callback called if an error occurs
  108418. */
  108419. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108420. /**
  108421. * Execute the current task
  108422. * @param scene defines the scene where you want your assets to be loaded
  108423. * @param onSuccess is a callback called when the task is successfully executed
  108424. * @param onError is a callback called if an error occurs
  108425. */
  108426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108427. /**
  108428. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  108429. * This can be used with failed tasks that have the reason for failure fixed.
  108430. */
  108431. reset(): void;
  108432. private onErrorCallback;
  108433. private onDoneCallback;
  108434. }
  108435. /**
  108436. * Define the interface used by progress events raised during assets loading
  108437. */
  108438. export interface IAssetsProgressEvent {
  108439. /**
  108440. * Defines the number of remaining tasks to process
  108441. */
  108442. remainingCount: number;
  108443. /**
  108444. * Defines the total number of tasks
  108445. */
  108446. totalCount: number;
  108447. /**
  108448. * Defines the task that was just processed
  108449. */
  108450. task: AbstractAssetTask;
  108451. }
  108452. /**
  108453. * Class used to share progress information about assets loading
  108454. */
  108455. export class AssetsProgressEvent implements IAssetsProgressEvent {
  108456. /**
  108457. * Defines the number of remaining tasks to process
  108458. */
  108459. remainingCount: number;
  108460. /**
  108461. * Defines the total number of tasks
  108462. */
  108463. totalCount: number;
  108464. /**
  108465. * Defines the task that was just processed
  108466. */
  108467. task: AbstractAssetTask;
  108468. /**
  108469. * Creates a AssetsProgressEvent
  108470. * @param remainingCount defines the number of remaining tasks to process
  108471. * @param totalCount defines the total number of tasks
  108472. * @param task defines the task that was just processed
  108473. */
  108474. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  108475. }
  108476. /**
  108477. * Define a task used by AssetsManager to load meshes
  108478. */
  108479. export class MeshAssetTask extends AbstractAssetTask {
  108480. /**
  108481. * Defines the name of the task
  108482. */
  108483. name: string;
  108484. /**
  108485. * Defines the list of mesh's names you want to load
  108486. */
  108487. meshesNames: any;
  108488. /**
  108489. * Defines the root url to use as a base to load your meshes and associated resources
  108490. */
  108491. rootUrl: string;
  108492. /**
  108493. * Defines the filename of the scene to load from
  108494. */
  108495. sceneFilename: string;
  108496. /**
  108497. * Gets the list of loaded meshes
  108498. */
  108499. loadedMeshes: Array<AbstractMesh>;
  108500. /**
  108501. * Gets the list of loaded particle systems
  108502. */
  108503. loadedParticleSystems: Array<IParticleSystem>;
  108504. /**
  108505. * Gets the list of loaded skeletons
  108506. */
  108507. loadedSkeletons: Array<Skeleton>;
  108508. /**
  108509. * Gets the list of loaded animation groups
  108510. */
  108511. loadedAnimationGroups: Array<AnimationGroup>;
  108512. /**
  108513. * Callback called when the task is successful
  108514. */
  108515. onSuccess: (task: MeshAssetTask) => void;
  108516. /**
  108517. * Callback called when the task is successful
  108518. */
  108519. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  108520. /**
  108521. * Creates a new MeshAssetTask
  108522. * @param name defines the name of the task
  108523. * @param meshesNames defines the list of mesh's names you want to load
  108524. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  108525. * @param sceneFilename defines the filename of the scene to load from
  108526. */
  108527. constructor(
  108528. /**
  108529. * Defines the name of the task
  108530. */
  108531. name: string,
  108532. /**
  108533. * Defines the list of mesh's names you want to load
  108534. */
  108535. meshesNames: any,
  108536. /**
  108537. * Defines the root url to use as a base to load your meshes and associated resources
  108538. */
  108539. rootUrl: string,
  108540. /**
  108541. * Defines the filename of the scene to load from
  108542. */
  108543. sceneFilename: string);
  108544. /**
  108545. * Execute the current task
  108546. * @param scene defines the scene where you want your assets to be loaded
  108547. * @param onSuccess is a callback called when the task is successfully executed
  108548. * @param onError is a callback called if an error occurs
  108549. */
  108550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108551. }
  108552. /**
  108553. * Define a task used by AssetsManager to load text content
  108554. */
  108555. export class TextFileAssetTask extends AbstractAssetTask {
  108556. /**
  108557. * Defines the name of the task
  108558. */
  108559. name: string;
  108560. /**
  108561. * Defines the location of the file to load
  108562. */
  108563. url: string;
  108564. /**
  108565. * Gets the loaded text string
  108566. */
  108567. text: string;
  108568. /**
  108569. * Callback called when the task is successful
  108570. */
  108571. onSuccess: (task: TextFileAssetTask) => void;
  108572. /**
  108573. * Callback called when the task is successful
  108574. */
  108575. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  108576. /**
  108577. * Creates a new TextFileAssetTask object
  108578. * @param name defines the name of the task
  108579. * @param url defines the location of the file to load
  108580. */
  108581. constructor(
  108582. /**
  108583. * Defines the name of the task
  108584. */
  108585. name: string,
  108586. /**
  108587. * Defines the location of the file to load
  108588. */
  108589. url: string);
  108590. /**
  108591. * Execute the current task
  108592. * @param scene defines the scene where you want your assets to be loaded
  108593. * @param onSuccess is a callback called when the task is successfully executed
  108594. * @param onError is a callback called if an error occurs
  108595. */
  108596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108597. }
  108598. /**
  108599. * Define a task used by AssetsManager to load binary data
  108600. */
  108601. export class BinaryFileAssetTask extends AbstractAssetTask {
  108602. /**
  108603. * Defines the name of the task
  108604. */
  108605. name: string;
  108606. /**
  108607. * Defines the location of the file to load
  108608. */
  108609. url: string;
  108610. /**
  108611. * Gets the lodaded data (as an array buffer)
  108612. */
  108613. data: ArrayBuffer;
  108614. /**
  108615. * Callback called when the task is successful
  108616. */
  108617. onSuccess: (task: BinaryFileAssetTask) => void;
  108618. /**
  108619. * Callback called when the task is successful
  108620. */
  108621. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  108622. /**
  108623. * Creates a new BinaryFileAssetTask object
  108624. * @param name defines the name of the new task
  108625. * @param url defines the location of the file to load
  108626. */
  108627. constructor(
  108628. /**
  108629. * Defines the name of the task
  108630. */
  108631. name: string,
  108632. /**
  108633. * Defines the location of the file to load
  108634. */
  108635. url: string);
  108636. /**
  108637. * Execute the current task
  108638. * @param scene defines the scene where you want your assets to be loaded
  108639. * @param onSuccess is a callback called when the task is successfully executed
  108640. * @param onError is a callback called if an error occurs
  108641. */
  108642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108643. }
  108644. /**
  108645. * Define a task used by AssetsManager to load images
  108646. */
  108647. export class ImageAssetTask extends AbstractAssetTask {
  108648. /**
  108649. * Defines the name of the task
  108650. */
  108651. name: string;
  108652. /**
  108653. * Defines the location of the image to load
  108654. */
  108655. url: string;
  108656. /**
  108657. * Gets the loaded images
  108658. */
  108659. image: HTMLImageElement;
  108660. /**
  108661. * Callback called when the task is successful
  108662. */
  108663. onSuccess: (task: ImageAssetTask) => void;
  108664. /**
  108665. * Callback called when the task is successful
  108666. */
  108667. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  108668. /**
  108669. * Creates a new ImageAssetTask
  108670. * @param name defines the name of the task
  108671. * @param url defines the location of the image to load
  108672. */
  108673. constructor(
  108674. /**
  108675. * Defines the name of the task
  108676. */
  108677. name: string,
  108678. /**
  108679. * Defines the location of the image to load
  108680. */
  108681. url: string);
  108682. /**
  108683. * Execute the current task
  108684. * @param scene defines the scene where you want your assets to be loaded
  108685. * @param onSuccess is a callback called when the task is successfully executed
  108686. * @param onError is a callback called if an error occurs
  108687. */
  108688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108689. }
  108690. /**
  108691. * Defines the interface used by texture loading tasks
  108692. */
  108693. export interface ITextureAssetTask<TEX extends BaseTexture> {
  108694. /**
  108695. * Gets the loaded texture
  108696. */
  108697. texture: TEX;
  108698. }
  108699. /**
  108700. * Define a task used by AssetsManager to load 2D textures
  108701. */
  108702. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  108703. /**
  108704. * Defines the name of the task
  108705. */
  108706. name: string;
  108707. /**
  108708. * Defines the location of the file to load
  108709. */
  108710. url: string;
  108711. /**
  108712. * Defines if mipmap should not be generated (default is false)
  108713. */
  108714. noMipmap?: boolean | undefined;
  108715. /**
  108716. * Defines if texture must be inverted on Y axis (default is false)
  108717. */
  108718. invertY?: boolean | undefined;
  108719. /**
  108720. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108721. */
  108722. samplingMode: number;
  108723. /**
  108724. * Gets the loaded texture
  108725. */
  108726. texture: Texture;
  108727. /**
  108728. * Callback called when the task is successful
  108729. */
  108730. onSuccess: (task: TextureAssetTask) => void;
  108731. /**
  108732. * Callback called when the task is successful
  108733. */
  108734. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  108735. /**
  108736. * Creates a new TextureAssetTask object
  108737. * @param name defines the name of the task
  108738. * @param url defines the location of the file to load
  108739. * @param noMipmap defines if mipmap should not be generated (default is false)
  108740. * @param invertY defines if texture must be inverted on Y axis (default is false)
  108741. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108742. */
  108743. constructor(
  108744. /**
  108745. * Defines the name of the task
  108746. */
  108747. name: string,
  108748. /**
  108749. * Defines the location of the file to load
  108750. */
  108751. url: string,
  108752. /**
  108753. * Defines if mipmap should not be generated (default is false)
  108754. */
  108755. noMipmap?: boolean | undefined,
  108756. /**
  108757. * Defines if texture must be inverted on Y axis (default is false)
  108758. */
  108759. invertY?: boolean | undefined,
  108760. /**
  108761. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108762. */
  108763. samplingMode?: number);
  108764. /**
  108765. * Execute the current task
  108766. * @param scene defines the scene where you want your assets to be loaded
  108767. * @param onSuccess is a callback called when the task is successfully executed
  108768. * @param onError is a callback called if an error occurs
  108769. */
  108770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108771. }
  108772. /**
  108773. * Define a task used by AssetsManager to load cube textures
  108774. */
  108775. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  108776. /**
  108777. * Defines the name of the task
  108778. */
  108779. name: string;
  108780. /**
  108781. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108782. */
  108783. url: string;
  108784. /**
  108785. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108786. */
  108787. extensions?: string[] | undefined;
  108788. /**
  108789. * Defines if mipmaps should not be generated (default is false)
  108790. */
  108791. noMipmap?: boolean | undefined;
  108792. /**
  108793. * Defines the explicit list of files (undefined by default)
  108794. */
  108795. files?: string[] | undefined;
  108796. /**
  108797. * Gets the loaded texture
  108798. */
  108799. texture: CubeTexture;
  108800. /**
  108801. * Callback called when the task is successful
  108802. */
  108803. onSuccess: (task: CubeTextureAssetTask) => void;
  108804. /**
  108805. * Callback called when the task is successful
  108806. */
  108807. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  108808. /**
  108809. * Creates a new CubeTextureAssetTask
  108810. * @param name defines the name of the task
  108811. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108812. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108813. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108814. * @param files defines the explicit list of files (undefined by default)
  108815. */
  108816. constructor(
  108817. /**
  108818. * Defines the name of the task
  108819. */
  108820. name: string,
  108821. /**
  108822. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108823. */
  108824. url: string,
  108825. /**
  108826. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108827. */
  108828. extensions?: string[] | undefined,
  108829. /**
  108830. * Defines if mipmaps should not be generated (default is false)
  108831. */
  108832. noMipmap?: boolean | undefined,
  108833. /**
  108834. * Defines the explicit list of files (undefined by default)
  108835. */
  108836. files?: string[] | undefined);
  108837. /**
  108838. * Execute the current task
  108839. * @param scene defines the scene where you want your assets to be loaded
  108840. * @param onSuccess is a callback called when the task is successfully executed
  108841. * @param onError is a callback called if an error occurs
  108842. */
  108843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108844. }
  108845. /**
  108846. * Define a task used by AssetsManager to load HDR cube textures
  108847. */
  108848. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  108849. /**
  108850. * Defines the name of the task
  108851. */
  108852. name: string;
  108853. /**
  108854. * Defines the location of the file to load
  108855. */
  108856. url: string;
  108857. /**
  108858. * Defines the desired size (the more it increases the longer the generation will be)
  108859. */
  108860. size: number;
  108861. /**
  108862. * Defines if mipmaps should not be generated (default is false)
  108863. */
  108864. noMipmap: boolean;
  108865. /**
  108866. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108867. */
  108868. generateHarmonics: boolean;
  108869. /**
  108870. * 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)
  108871. */
  108872. gammaSpace: boolean;
  108873. /**
  108874. * Internal Use Only
  108875. */
  108876. reserved: boolean;
  108877. /**
  108878. * Gets the loaded texture
  108879. */
  108880. texture: HDRCubeTexture;
  108881. /**
  108882. * Callback called when the task is successful
  108883. */
  108884. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  108885. /**
  108886. * Callback called when the task is successful
  108887. */
  108888. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  108889. /**
  108890. * Creates a new HDRCubeTextureAssetTask object
  108891. * @param name defines the name of the task
  108892. * @param url defines the location of the file to load
  108893. * @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.
  108894. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108895. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108896. * @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)
  108897. * @param reserved Internal use only
  108898. */
  108899. constructor(
  108900. /**
  108901. * Defines the name of the task
  108902. */
  108903. name: string,
  108904. /**
  108905. * Defines the location of the file to load
  108906. */
  108907. url: string,
  108908. /**
  108909. * Defines the desired size (the more it increases the longer the generation will be)
  108910. */
  108911. size: number,
  108912. /**
  108913. * Defines if mipmaps should not be generated (default is false)
  108914. */
  108915. noMipmap?: boolean,
  108916. /**
  108917. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108918. */
  108919. generateHarmonics?: boolean,
  108920. /**
  108921. * 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)
  108922. */
  108923. gammaSpace?: boolean,
  108924. /**
  108925. * Internal Use Only
  108926. */
  108927. reserved?: boolean);
  108928. /**
  108929. * Execute the current task
  108930. * @param scene defines the scene where you want your assets to be loaded
  108931. * @param onSuccess is a callback called when the task is successfully executed
  108932. * @param onError is a callback called if an error occurs
  108933. */
  108934. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108935. }
  108936. /**
  108937. * This class can be used to easily import assets into a scene
  108938. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  108939. */
  108940. export class AssetsManager {
  108941. private _scene;
  108942. private _isLoading;
  108943. protected _tasks: AbstractAssetTask[];
  108944. protected _waitingTasksCount: number;
  108945. protected _totalTasksCount: number;
  108946. /**
  108947. * Callback called when all tasks are processed
  108948. */
  108949. onFinish: (tasks: AbstractAssetTask[]) => void;
  108950. /**
  108951. * Callback called when a task is successful
  108952. */
  108953. onTaskSuccess: (task: AbstractAssetTask) => void;
  108954. /**
  108955. * Callback called when a task had an error
  108956. */
  108957. onTaskError: (task: AbstractAssetTask) => void;
  108958. /**
  108959. * Callback called when a task is done (whatever the result is)
  108960. */
  108961. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  108962. /**
  108963. * Observable called when all tasks are processed
  108964. */
  108965. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  108966. /**
  108967. * Observable called when a task had an error
  108968. */
  108969. onTaskErrorObservable: Observable<AbstractAssetTask>;
  108970. /**
  108971. * Observable called when a task is successful
  108972. */
  108973. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  108974. /**
  108975. * Observable called when a task is done (whatever the result is)
  108976. */
  108977. onProgressObservable: Observable<IAssetsProgressEvent>;
  108978. /**
  108979. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  108980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108981. */
  108982. useDefaultLoadingScreen: boolean;
  108983. /**
  108984. * Creates a new AssetsManager
  108985. * @param scene defines the scene to work on
  108986. */
  108987. constructor(scene: Scene);
  108988. /**
  108989. * Add a MeshAssetTask to the list of active tasks
  108990. * @param taskName defines the name of the new task
  108991. * @param meshesNames defines the name of meshes to load
  108992. * @param rootUrl defines the root url to use to locate files
  108993. * @param sceneFilename defines the filename of the scene file
  108994. * @returns a new MeshAssetTask object
  108995. */
  108996. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  108997. /**
  108998. * Add a TextFileAssetTask to the list of active tasks
  108999. * @param taskName defines the name of the new task
  109000. * @param url defines the url of the file to load
  109001. * @returns a new TextFileAssetTask object
  109002. */
  109003. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  109004. /**
  109005. * Add a BinaryFileAssetTask to the list of active tasks
  109006. * @param taskName defines the name of the new task
  109007. * @param url defines the url of the file to load
  109008. * @returns a new BinaryFileAssetTask object
  109009. */
  109010. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  109011. /**
  109012. * Add a ImageAssetTask to the list of active tasks
  109013. * @param taskName defines the name of the new task
  109014. * @param url defines the url of the file to load
  109015. * @returns a new ImageAssetTask object
  109016. */
  109017. addImageTask(taskName: string, url: string): ImageAssetTask;
  109018. /**
  109019. * Add a TextureAssetTask to the list of active tasks
  109020. * @param taskName defines the name of the new task
  109021. * @param url defines the url of the file to load
  109022. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109023. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  109024. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109025. * @returns a new TextureAssetTask object
  109026. */
  109027. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  109028. /**
  109029. * Add a CubeTextureAssetTask to the list of active tasks
  109030. * @param taskName defines the name of the new task
  109031. * @param url defines the url of the file to load
  109032. * @param extensions defines the extension to use to load the cube map (can be null)
  109033. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109034. * @param files defines the list of files to load (can be null)
  109035. * @returns a new CubeTextureAssetTask object
  109036. */
  109037. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  109038. /**
  109039. *
  109040. * Add a HDRCubeTextureAssetTask to the list of active tasks
  109041. * @param taskName defines the name of the new task
  109042. * @param url defines the url of the file to load
  109043. * @param size defines the size you want for the cubemap (can be null)
  109044. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109045. * @param generateHarmonics defines if you want to automatically generate (true by default)
  109046. * @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)
  109047. * @param reserved Internal use only
  109048. * @returns a new HDRCubeTextureAssetTask object
  109049. */
  109050. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  109051. /**
  109052. * Remove a task from the assets manager.
  109053. * @param task the task to remove
  109054. */
  109055. removeTask(task: AbstractAssetTask): void;
  109056. private _decreaseWaitingTasksCount;
  109057. private _runTask;
  109058. /**
  109059. * Reset the AssetsManager and remove all tasks
  109060. * @return the current instance of the AssetsManager
  109061. */
  109062. reset(): AssetsManager;
  109063. /**
  109064. * Start the loading process
  109065. * @return the current instance of the AssetsManager
  109066. */
  109067. load(): AssetsManager;
  109068. }
  109069. }
  109070. declare module BABYLON {
  109071. /**
  109072. * Wrapper class for promise with external resolve and reject.
  109073. */
  109074. export class Deferred<T> {
  109075. /**
  109076. * The promise associated with this deferred object.
  109077. */
  109078. readonly promise: Promise<T>;
  109079. private _resolve;
  109080. private _reject;
  109081. /**
  109082. * The resolve method of the promise associated with this deferred object.
  109083. */
  109084. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  109085. /**
  109086. * The reject method of the promise associated with this deferred object.
  109087. */
  109088. readonly reject: (reason?: any) => void;
  109089. /**
  109090. * Constructor for this deferred object.
  109091. */
  109092. constructor();
  109093. }
  109094. }
  109095. declare module BABYLON {
  109096. /**
  109097. * Class used to help managing file picking and drag'n'drop
  109098. */
  109099. export class FilesInput {
  109100. /**
  109101. * List of files ready to be loaded
  109102. */
  109103. static readonly FilesToLoad: {
  109104. [key: string]: File;
  109105. };
  109106. /**
  109107. * Callback called when a file is processed
  109108. */
  109109. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  109110. private _engine;
  109111. private _currentScene;
  109112. private _sceneLoadedCallback;
  109113. private _progressCallback;
  109114. private _additionalRenderLoopLogicCallback;
  109115. private _textureLoadingCallback;
  109116. private _startingProcessingFilesCallback;
  109117. private _onReloadCallback;
  109118. private _errorCallback;
  109119. private _elementToMonitor;
  109120. private _sceneFileToLoad;
  109121. private _filesToLoad;
  109122. /**
  109123. * Creates a new FilesInput
  109124. * @param engine defines the rendering engine
  109125. * @param scene defines the hosting scene
  109126. * @param sceneLoadedCallback callback called when scene is loaded
  109127. * @param progressCallback callback called to track progress
  109128. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  109129. * @param textureLoadingCallback callback called when a texture is loading
  109130. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  109131. * @param onReloadCallback callback called when a reload is requested
  109132. * @param errorCallback callback call if an error occurs
  109133. */
  109134. 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);
  109135. private _dragEnterHandler;
  109136. private _dragOverHandler;
  109137. private _dropHandler;
  109138. /**
  109139. * Calls this function to listen to drag'n'drop events on a specific DOM element
  109140. * @param elementToMonitor defines the DOM element to track
  109141. */
  109142. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  109143. /**
  109144. * Release all associated resources
  109145. */
  109146. dispose(): void;
  109147. private renderFunction;
  109148. private drag;
  109149. private drop;
  109150. private _traverseFolder;
  109151. private _processFiles;
  109152. /**
  109153. * Load files from a drop event
  109154. * @param event defines the drop event to use as source
  109155. */
  109156. loadFiles(event: any): void;
  109157. private _processReload;
  109158. /**
  109159. * Reload the current scene from the loaded files
  109160. */
  109161. reload(): void;
  109162. }
  109163. }
  109164. declare module BABYLON {
  109165. /**
  109166. * Defines the root class used to create scene optimization to use with SceneOptimizer
  109167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109168. */
  109169. export class SceneOptimization {
  109170. /**
  109171. * Defines the priority of this optimization (0 by default which means first in the list)
  109172. */
  109173. priority: number;
  109174. /**
  109175. * Gets a string describing the action executed by the current optimization
  109176. * @returns description string
  109177. */
  109178. getDescription(): string;
  109179. /**
  109180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109181. * @param scene defines the current scene where to apply this optimization
  109182. * @param optimizer defines the current optimizer
  109183. * @returns true if everything that can be done was applied
  109184. */
  109185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109186. /**
  109187. * Creates the SceneOptimization object
  109188. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109189. * @param desc defines the description associated with the optimization
  109190. */
  109191. constructor(
  109192. /**
  109193. * Defines the priority of this optimization (0 by default which means first in the list)
  109194. */
  109195. priority?: number);
  109196. }
  109197. /**
  109198. * Defines an optimization used to reduce the size of render target textures
  109199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109200. */
  109201. export class TextureOptimization extends SceneOptimization {
  109202. /**
  109203. * Defines the priority of this optimization (0 by default which means first in the list)
  109204. */
  109205. priority: number;
  109206. /**
  109207. * 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
  109208. */
  109209. maximumSize: number;
  109210. /**
  109211. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109212. */
  109213. step: number;
  109214. /**
  109215. * Gets a string describing the action executed by the current optimization
  109216. * @returns description string
  109217. */
  109218. getDescription(): string;
  109219. /**
  109220. * Creates the TextureOptimization object
  109221. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109222. * @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
  109223. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109224. */
  109225. constructor(
  109226. /**
  109227. * Defines the priority of this optimization (0 by default which means first in the list)
  109228. */
  109229. priority?: number,
  109230. /**
  109231. * 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
  109232. */
  109233. maximumSize?: number,
  109234. /**
  109235. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109236. */
  109237. step?: number);
  109238. /**
  109239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109240. * @param scene defines the current scene where to apply this optimization
  109241. * @param optimizer defines the current optimizer
  109242. * @returns true if everything that can be done was applied
  109243. */
  109244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109245. }
  109246. /**
  109247. * Defines an optimization used to increase or decrease the rendering resolution
  109248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109249. */
  109250. export class HardwareScalingOptimization extends SceneOptimization {
  109251. /**
  109252. * Defines the priority of this optimization (0 by default which means first in the list)
  109253. */
  109254. priority: number;
  109255. /**
  109256. * Defines the maximum scale to use (2 by default)
  109257. */
  109258. maximumScale: number;
  109259. /**
  109260. * Defines the step to use between two passes (0.5 by default)
  109261. */
  109262. step: number;
  109263. private _currentScale;
  109264. private _directionOffset;
  109265. /**
  109266. * Gets a string describing the action executed by the current optimization
  109267. * @return description string
  109268. */
  109269. getDescription(): string;
  109270. /**
  109271. * Creates the HardwareScalingOptimization object
  109272. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109273. * @param maximumScale defines the maximum scale to use (2 by default)
  109274. * @param step defines the step to use between two passes (0.5 by default)
  109275. */
  109276. constructor(
  109277. /**
  109278. * Defines the priority of this optimization (0 by default which means first in the list)
  109279. */
  109280. priority?: number,
  109281. /**
  109282. * Defines the maximum scale to use (2 by default)
  109283. */
  109284. maximumScale?: number,
  109285. /**
  109286. * Defines the step to use between two passes (0.5 by default)
  109287. */
  109288. step?: number);
  109289. /**
  109290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109291. * @param scene defines the current scene where to apply this optimization
  109292. * @param optimizer defines the current optimizer
  109293. * @returns true if everything that can be done was applied
  109294. */
  109295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109296. }
  109297. /**
  109298. * Defines an optimization used to remove shadows
  109299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109300. */
  109301. export class ShadowsOptimization extends SceneOptimization {
  109302. /**
  109303. * Gets a string describing the action executed by the current optimization
  109304. * @return description string
  109305. */
  109306. getDescription(): string;
  109307. /**
  109308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109309. * @param scene defines the current scene where to apply this optimization
  109310. * @param optimizer defines the current optimizer
  109311. * @returns true if everything that can be done was applied
  109312. */
  109313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109314. }
  109315. /**
  109316. * Defines an optimization used to turn post-processes off
  109317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109318. */
  109319. export class PostProcessesOptimization extends SceneOptimization {
  109320. /**
  109321. * Gets a string describing the action executed by the current optimization
  109322. * @return description string
  109323. */
  109324. getDescription(): string;
  109325. /**
  109326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109327. * @param scene defines the current scene where to apply this optimization
  109328. * @param optimizer defines the current optimizer
  109329. * @returns true if everything that can be done was applied
  109330. */
  109331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109332. }
  109333. /**
  109334. * Defines an optimization used to turn lens flares off
  109335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109336. */
  109337. export class LensFlaresOptimization extends SceneOptimization {
  109338. /**
  109339. * Gets a string describing the action executed by the current optimization
  109340. * @return description string
  109341. */
  109342. getDescription(): string;
  109343. /**
  109344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109345. * @param scene defines the current scene where to apply this optimization
  109346. * @param optimizer defines the current optimizer
  109347. * @returns true if everything that can be done was applied
  109348. */
  109349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109350. }
  109351. /**
  109352. * Defines an optimization based on user defined callback.
  109353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109354. */
  109355. export class CustomOptimization extends SceneOptimization {
  109356. /**
  109357. * Callback called to apply the custom optimization.
  109358. */
  109359. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  109360. /**
  109361. * Callback called to get custom description
  109362. */
  109363. onGetDescription: () => string;
  109364. /**
  109365. * Gets a string describing the action executed by the current optimization
  109366. * @returns description string
  109367. */
  109368. getDescription(): string;
  109369. /**
  109370. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109371. * @param scene defines the current scene where to apply this optimization
  109372. * @param optimizer defines the current optimizer
  109373. * @returns true if everything that can be done was applied
  109374. */
  109375. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109376. }
  109377. /**
  109378. * Defines an optimization used to turn particles off
  109379. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109380. */
  109381. export class ParticlesOptimization extends SceneOptimization {
  109382. /**
  109383. * Gets a string describing the action executed by the current optimization
  109384. * @return description string
  109385. */
  109386. getDescription(): string;
  109387. /**
  109388. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109389. * @param scene defines the current scene where to apply this optimization
  109390. * @param optimizer defines the current optimizer
  109391. * @returns true if everything that can be done was applied
  109392. */
  109393. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109394. }
  109395. /**
  109396. * Defines an optimization used to turn render targets off
  109397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109398. */
  109399. export class RenderTargetsOptimization extends SceneOptimization {
  109400. /**
  109401. * Gets a string describing the action executed by the current optimization
  109402. * @return description string
  109403. */
  109404. getDescription(): string;
  109405. /**
  109406. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109407. * @param scene defines the current scene where to apply this optimization
  109408. * @param optimizer defines the current optimizer
  109409. * @returns true if everything that can be done was applied
  109410. */
  109411. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109412. }
  109413. /**
  109414. * Defines an optimization used to merge meshes with compatible materials
  109415. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109416. */
  109417. export class MergeMeshesOptimization extends SceneOptimization {
  109418. private static _UpdateSelectionTree;
  109419. /**
  109420. * Gets or sets a boolean which defines if optimization octree has to be updated
  109421. */
  109422. /**
  109423. * Gets or sets a boolean which defines if optimization octree has to be updated
  109424. */
  109425. static UpdateSelectionTree: boolean;
  109426. /**
  109427. * Gets a string describing the action executed by the current optimization
  109428. * @return description string
  109429. */
  109430. getDescription(): string;
  109431. private _canBeMerged;
  109432. /**
  109433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109434. * @param scene defines the current scene where to apply this optimization
  109435. * @param optimizer defines the current optimizer
  109436. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  109437. * @returns true if everything that can be done was applied
  109438. */
  109439. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  109440. }
  109441. /**
  109442. * Defines a list of options used by SceneOptimizer
  109443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109444. */
  109445. export class SceneOptimizerOptions {
  109446. /**
  109447. * Defines the target frame rate to reach (60 by default)
  109448. */
  109449. targetFrameRate: number;
  109450. /**
  109451. * Defines the interval between two checkes (2000ms by default)
  109452. */
  109453. trackerDuration: number;
  109454. /**
  109455. * Gets the list of optimizations to apply
  109456. */
  109457. optimizations: SceneOptimization[];
  109458. /**
  109459. * Creates a new list of options used by SceneOptimizer
  109460. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  109461. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  109462. */
  109463. constructor(
  109464. /**
  109465. * Defines the target frame rate to reach (60 by default)
  109466. */
  109467. targetFrameRate?: number,
  109468. /**
  109469. * Defines the interval between two checkes (2000ms by default)
  109470. */
  109471. trackerDuration?: number);
  109472. /**
  109473. * Add a new optimization
  109474. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  109475. * @returns the current SceneOptimizerOptions
  109476. */
  109477. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  109478. /**
  109479. * Add a new custom optimization
  109480. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  109481. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  109482. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109483. * @returns the current SceneOptimizerOptions
  109484. */
  109485. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  109486. /**
  109487. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  109488. * @param targetFrameRate defines the target frame rate (60 by default)
  109489. * @returns a SceneOptimizerOptions object
  109490. */
  109491. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109492. /**
  109493. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  109494. * @param targetFrameRate defines the target frame rate (60 by default)
  109495. * @returns a SceneOptimizerOptions object
  109496. */
  109497. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109498. /**
  109499. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  109500. * @param targetFrameRate defines the target frame rate (60 by default)
  109501. * @returns a SceneOptimizerOptions object
  109502. */
  109503. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109504. }
  109505. /**
  109506. * Class used to run optimizations in order to reach a target frame rate
  109507. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109508. */
  109509. export class SceneOptimizer implements IDisposable {
  109510. private _isRunning;
  109511. private _options;
  109512. private _scene;
  109513. private _currentPriorityLevel;
  109514. private _targetFrameRate;
  109515. private _trackerDuration;
  109516. private _currentFrameRate;
  109517. private _sceneDisposeObserver;
  109518. private _improvementMode;
  109519. /**
  109520. * Defines an observable called when the optimizer reaches the target frame rate
  109521. */
  109522. onSuccessObservable: Observable<SceneOptimizer>;
  109523. /**
  109524. * Defines an observable called when the optimizer enables an optimization
  109525. */
  109526. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  109527. /**
  109528. * Defines an observable called when the optimizer is not able to reach the target frame rate
  109529. */
  109530. onFailureObservable: Observable<SceneOptimizer>;
  109531. /**
  109532. * Gets a boolean indicating if the optimizer is in improvement mode
  109533. */
  109534. readonly isInImprovementMode: boolean;
  109535. /**
  109536. * Gets the current priority level (0 at start)
  109537. */
  109538. readonly currentPriorityLevel: number;
  109539. /**
  109540. * Gets the current frame rate checked by the SceneOptimizer
  109541. */
  109542. readonly currentFrameRate: number;
  109543. /**
  109544. * Gets or sets the current target frame rate (60 by default)
  109545. */
  109546. /**
  109547. * Gets or sets the current target frame rate (60 by default)
  109548. */
  109549. targetFrameRate: number;
  109550. /**
  109551. * Gets or sets the current interval between two checks (every 2000ms by default)
  109552. */
  109553. /**
  109554. * Gets or sets the current interval between two checks (every 2000ms by default)
  109555. */
  109556. trackerDuration: number;
  109557. /**
  109558. * Gets the list of active optimizations
  109559. */
  109560. readonly optimizations: SceneOptimization[];
  109561. /**
  109562. * Creates a new SceneOptimizer
  109563. * @param scene defines the scene to work on
  109564. * @param options defines the options to use with the SceneOptimizer
  109565. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  109566. * @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)
  109567. */
  109568. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  109569. /**
  109570. * Stops the current optimizer
  109571. */
  109572. stop(): void;
  109573. /**
  109574. * Reset the optimizer to initial step (current priority level = 0)
  109575. */
  109576. reset(): void;
  109577. /**
  109578. * Start the optimizer. By default it will try to reach a specific framerate
  109579. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  109580. */
  109581. start(): void;
  109582. private _checkCurrentState;
  109583. /**
  109584. * Release all resources
  109585. */
  109586. dispose(): void;
  109587. /**
  109588. * Helper function to create a SceneOptimizer with one single line of code
  109589. * @param scene defines the scene to work on
  109590. * @param options defines the options to use with the SceneOptimizer
  109591. * @param onSuccess defines a callback to call on success
  109592. * @param onFailure defines a callback to call on failure
  109593. * @returns the new SceneOptimizer object
  109594. */
  109595. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  109596. }
  109597. }
  109598. declare module BABYLON {
  109599. /**
  109600. * Class used to serialize a scene into a string
  109601. */
  109602. export class SceneSerializer {
  109603. /**
  109604. * Clear cache used by a previous serialization
  109605. */
  109606. static ClearCache(): void;
  109607. /**
  109608. * Serialize a scene into a JSON compatible object
  109609. * @param scene defines the scene to serialize
  109610. * @returns a JSON compatible object
  109611. */
  109612. static Serialize(scene: Scene): any;
  109613. /**
  109614. * Serialize a mesh into a JSON compatible object
  109615. * @param toSerialize defines the mesh to serialize
  109616. * @param withParents defines if parents must be serialized as well
  109617. * @param withChildren defines if children must be serialized as well
  109618. * @returns a JSON compatible object
  109619. */
  109620. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  109621. }
  109622. }
  109623. declare module BABYLON {
  109624. /**
  109625. * This represents the different options avilable for the video capture.
  109626. */
  109627. export interface VideoRecorderOptions {
  109628. /** Defines the mime type of the video */
  109629. mimeType: string;
  109630. /** Defines the video the video should be recorded at */
  109631. fps: number;
  109632. /** Defines the chunk size for the recording data */
  109633. recordChunckSize: number;
  109634. }
  109635. /**
  109636. * This can helps recording videos from BabylonJS.
  109637. * This is based on the available WebRTC functionalities of the browser.
  109638. *
  109639. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  109640. */
  109641. export class VideoRecorder {
  109642. private static readonly _defaultOptions;
  109643. /**
  109644. * Returns wehther or not the VideoRecorder is available in your browser.
  109645. * @param engine Defines the Babylon Engine to check the support for
  109646. * @returns true if supported otherwise false
  109647. */
  109648. static IsSupported(engine: Engine): boolean;
  109649. private readonly _options;
  109650. private _canvas;
  109651. private _mediaRecorder;
  109652. private _recordedChunks;
  109653. private _fileName;
  109654. private _resolve;
  109655. private _reject;
  109656. /**
  109657. * True wether a recording is already in progress.
  109658. */
  109659. readonly isRecording: boolean;
  109660. /**
  109661. * Create a new VideoCapture object which can help converting what you see in Babylon to
  109662. * a video file.
  109663. * @param engine Defines the BabylonJS Engine you wish to record
  109664. * @param options Defines options that can be used to customized the capture
  109665. */
  109666. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  109667. /**
  109668. * Stops the current recording before the default capture timeout passed in the startRecording
  109669. * functions.
  109670. */
  109671. stopRecording(): void;
  109672. /**
  109673. * Starts recording the canvas for a max duration specified in parameters.
  109674. * @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.
  109675. * @param maxDuration Defines the maximum recording time in seconds.
  109676. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  109677. * @return a promise callback at the end of the recording with the video data in Blob.
  109678. */
  109679. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  109680. /**
  109681. * Releases internal resources used during the recording.
  109682. */
  109683. dispose(): void;
  109684. private _handleDataAvailable;
  109685. private _handleError;
  109686. private _handleStop;
  109687. }
  109688. }
  109689. declare module BABYLON {
  109690. /**
  109691. * Helper class to push actions to a pool of workers.
  109692. */
  109693. export class WorkerPool implements IDisposable {
  109694. private _workerInfos;
  109695. private _pendingActions;
  109696. /**
  109697. * Constructor
  109698. * @param workers Array of workers to use for actions
  109699. */
  109700. constructor(workers: Array<Worker>);
  109701. /**
  109702. * Terminates all workers and clears any pending actions.
  109703. */
  109704. dispose(): void;
  109705. /**
  109706. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109707. * pended until a worker has completed its action.
  109708. * @param action The action to perform. Call onComplete when the action is complete.
  109709. */
  109710. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109711. private _execute;
  109712. }
  109713. }
  109714. declare module BABYLON {
  109715. /**
  109716. * Class containing a set of static utilities functions for screenshots
  109717. */
  109718. export class ScreenshotTools {
  109719. /**
  109720. * Captures a screenshot of the current rendering
  109721. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109722. * @param engine defines the rendering engine
  109723. * @param camera defines the source camera
  109724. * @param size This parameter can be set to a single number or to an object with the
  109725. * following (optional) properties: precision, width, height. If a single number is passed,
  109726. * it will be used for both width and height. If an object is passed, the screenshot size
  109727. * will be derived from the parameters. The precision property is a multiplier allowing
  109728. * rendering at a higher or lower resolution
  109729. * @param successCallback defines the callback receives a single parameter which contains the
  109730. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109731. * src parameter of an <img> to display it
  109732. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109733. * Check your browser for supported MIME types
  109734. */
  109735. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  109736. /**
  109737. * Generates an image screenshot from the specified camera.
  109738. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109739. * @param engine The engine to use for rendering
  109740. * @param camera The camera to use for rendering
  109741. * @param size This parameter can be set to a single number or to an object with the
  109742. * following (optional) properties: precision, width, height. If a single number is passed,
  109743. * it will be used for both width and height. If an object is passed, the screenshot size
  109744. * will be derived from the parameters. The precision property is a multiplier allowing
  109745. * rendering at a higher or lower resolution
  109746. * @param successCallback The callback receives a single parameter which contains the
  109747. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109748. * src parameter of an <img> to display it
  109749. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109750. * Check your browser for supported MIME types
  109751. * @param samples Texture samples (default: 1)
  109752. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109753. * @param fileName A name for for the downloaded file.
  109754. */
  109755. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  109756. }
  109757. }
  109758. declare module BABYLON {
  109759. /**
  109760. * A cursor which tracks a point on a path
  109761. */
  109762. export class PathCursor {
  109763. private path;
  109764. /**
  109765. * Stores path cursor callbacks for when an onchange event is triggered
  109766. */
  109767. private _onchange;
  109768. /**
  109769. * The value of the path cursor
  109770. */
  109771. value: number;
  109772. /**
  109773. * The animation array of the path cursor
  109774. */
  109775. animations: Animation[];
  109776. /**
  109777. * Initializes the path cursor
  109778. * @param path The path to track
  109779. */
  109780. constructor(path: Path2);
  109781. /**
  109782. * Gets the cursor point on the path
  109783. * @returns A point on the path cursor at the cursor location
  109784. */
  109785. getPoint(): Vector3;
  109786. /**
  109787. * Moves the cursor ahead by the step amount
  109788. * @param step The amount to move the cursor forward
  109789. * @returns This path cursor
  109790. */
  109791. moveAhead(step?: number): PathCursor;
  109792. /**
  109793. * Moves the cursor behind by the step amount
  109794. * @param step The amount to move the cursor back
  109795. * @returns This path cursor
  109796. */
  109797. moveBack(step?: number): PathCursor;
  109798. /**
  109799. * Moves the cursor by the step amount
  109800. * If the step amount is greater than one, an exception is thrown
  109801. * @param step The amount to move the cursor
  109802. * @returns This path cursor
  109803. */
  109804. move(step: number): PathCursor;
  109805. /**
  109806. * Ensures that the value is limited between zero and one
  109807. * @returns This path cursor
  109808. */
  109809. private ensureLimits;
  109810. /**
  109811. * Runs onchange callbacks on change (used by the animation engine)
  109812. * @returns This path cursor
  109813. */
  109814. private raiseOnChange;
  109815. /**
  109816. * Executes a function on change
  109817. * @param f A path cursor onchange callback
  109818. * @returns This path cursor
  109819. */
  109820. onchange(f: (cursor: PathCursor) => void): PathCursor;
  109821. }
  109822. }
  109823. declare module BABYLON {
  109824. /** @hidden */
  109825. export var blurPixelShader: {
  109826. name: string;
  109827. shader: string;
  109828. };
  109829. }
  109830. declare module BABYLON {
  109831. /** @hidden */
  109832. export var bones300Declaration: {
  109833. name: string;
  109834. shader: string;
  109835. };
  109836. }
  109837. declare module BABYLON {
  109838. /** @hidden */
  109839. export var instances300Declaration: {
  109840. name: string;
  109841. shader: string;
  109842. };
  109843. }
  109844. declare module BABYLON {
  109845. /** @hidden */
  109846. export var pointCloudVertexDeclaration: {
  109847. name: string;
  109848. shader: string;
  109849. };
  109850. }
  109851. // Mixins
  109852. interface Window {
  109853. mozIndexedDB: IDBFactory;
  109854. webkitIndexedDB: IDBFactory;
  109855. msIndexedDB: IDBFactory;
  109856. webkitURL: typeof URL;
  109857. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  109858. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  109859. WebGLRenderingContext: WebGLRenderingContext;
  109860. MSGesture: MSGesture;
  109861. CANNON: any;
  109862. AudioContext: AudioContext;
  109863. webkitAudioContext: AudioContext;
  109864. PointerEvent: any;
  109865. Math: Math;
  109866. Uint8Array: Uint8ArrayConstructor;
  109867. Float32Array: Float32ArrayConstructor;
  109868. mozURL: typeof URL;
  109869. msURL: typeof URL;
  109870. VRFrameData: any; // WebVR, from specs 1.1
  109871. DracoDecoderModule: any;
  109872. setImmediate(handler: (...args: any[]) => void): number;
  109873. }
  109874. interface Document {
  109875. mozCancelFullScreen(): void;
  109876. msCancelFullScreen(): void;
  109877. webkitCancelFullScreen(): void;
  109878. requestPointerLock(): void;
  109879. exitPointerLock(): void;
  109880. mozFullScreen: boolean;
  109881. msIsFullScreen: boolean;
  109882. readonly webkitIsFullScreen: boolean;
  109883. readonly pointerLockElement: Element;
  109884. mozPointerLockElement: HTMLElement;
  109885. msPointerLockElement: HTMLElement;
  109886. webkitPointerLockElement: HTMLElement;
  109887. }
  109888. interface HTMLCanvasElement {
  109889. requestPointerLock(): void;
  109890. msRequestPointerLock?(): void;
  109891. mozRequestPointerLock?(): void;
  109892. webkitRequestPointerLock?(): void;
  109893. /** Track wether a record is in progress */
  109894. isRecording: boolean;
  109895. /** Capture Stream method defined by some browsers */
  109896. captureStream(fps?: number): MediaStream;
  109897. }
  109898. interface CanvasRenderingContext2D {
  109899. msImageSmoothingEnabled: boolean;
  109900. }
  109901. interface MouseEvent {
  109902. mozMovementX: number;
  109903. mozMovementY: number;
  109904. webkitMovementX: number;
  109905. webkitMovementY: number;
  109906. msMovementX: number;
  109907. msMovementY: number;
  109908. }
  109909. interface Navigator {
  109910. mozGetVRDevices: (any: any) => any;
  109911. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109912. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109913. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109914. webkitGetGamepads(): Gamepad[];
  109915. msGetGamepads(): Gamepad[];
  109916. webkitGamepads(): Gamepad[];
  109917. }
  109918. interface HTMLVideoElement {
  109919. mozSrcObject: any;
  109920. }
  109921. interface Math {
  109922. fround(x: number): number;
  109923. imul(a: number, b: number): number;
  109924. }
  109925. interface WebGLProgram {
  109926. context?: WebGLRenderingContext;
  109927. vertexShader?: WebGLShader;
  109928. fragmentShader?: WebGLShader;
  109929. isParallelCompiled: boolean;
  109930. onCompiled?: () => void;
  109931. }
  109932. interface WebGLRenderingContext {
  109933. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  109934. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  109935. vertexAttribDivisor(index: number, divisor: number): void;
  109936. createVertexArray(): any;
  109937. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  109938. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  109939. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  109940. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  109941. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  109942. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  109943. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  109944. // Queries
  109945. createQuery(): WebGLQuery;
  109946. deleteQuery(query: WebGLQuery): void;
  109947. beginQuery(target: number, query: WebGLQuery): void;
  109948. endQuery(target: number): void;
  109949. getQueryParameter(query: WebGLQuery, pname: number): any;
  109950. getQuery(target: number, pname: number): any;
  109951. MAX_SAMPLES: number;
  109952. RGBA8: number;
  109953. READ_FRAMEBUFFER: number;
  109954. DRAW_FRAMEBUFFER: number;
  109955. UNIFORM_BUFFER: number;
  109956. HALF_FLOAT_OES: number;
  109957. RGBA16F: number;
  109958. RGBA32F: number;
  109959. R32F: number;
  109960. RG32F: number;
  109961. RGB32F: number;
  109962. R16F: number;
  109963. RG16F: number;
  109964. RGB16F: number;
  109965. RED: number;
  109966. RG: number;
  109967. R8: number;
  109968. RG8: number;
  109969. UNSIGNED_INT_24_8: number;
  109970. DEPTH24_STENCIL8: number;
  109971. /* Multiple Render Targets */
  109972. drawBuffers(buffers: number[]): void;
  109973. readBuffer(src: number): void;
  109974. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  109975. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  109976. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  109977. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  109978. // Occlusion Query
  109979. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  109980. ANY_SAMPLES_PASSED: number;
  109981. QUERY_RESULT_AVAILABLE: number;
  109982. QUERY_RESULT: number;
  109983. }
  109984. interface WebGLBuffer {
  109985. references: number;
  109986. capacity: number;
  109987. is32Bits: boolean;
  109988. }
  109989. interface WebGLProgram {
  109990. transformFeedback?: WebGLTransformFeedback | null;
  109991. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  109992. }
  109993. interface EXT_disjoint_timer_query {
  109994. QUERY_COUNTER_BITS_EXT: number;
  109995. TIME_ELAPSED_EXT: number;
  109996. TIMESTAMP_EXT: number;
  109997. GPU_DISJOINT_EXT: number;
  109998. QUERY_RESULT_EXT: number;
  109999. QUERY_RESULT_AVAILABLE_EXT: number;
  110000. queryCounterEXT(query: WebGLQuery, target: number): void;
  110001. createQueryEXT(): WebGLQuery;
  110002. beginQueryEXT(target: number, query: WebGLQuery): void;
  110003. endQueryEXT(target: number): void;
  110004. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  110005. deleteQueryEXT(query: WebGLQuery): void;
  110006. }
  110007. interface WebGLUniformLocation {
  110008. _currentState: any;
  110009. }
  110010. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  110011. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  110012. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  110013. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110014. interface WebGLRenderingContext {
  110015. readonly RASTERIZER_DISCARD: number;
  110016. readonly DEPTH_COMPONENT24: number;
  110017. readonly TEXTURE_3D: number;
  110018. readonly TEXTURE_2D_ARRAY: number;
  110019. readonly TEXTURE_COMPARE_FUNC: number;
  110020. readonly TEXTURE_COMPARE_MODE: number;
  110021. readonly COMPARE_REF_TO_TEXTURE: number;
  110022. readonly TEXTURE_WRAP_R: number;
  110023. readonly HALF_FLOAT: number;
  110024. readonly RGB8: number;
  110025. readonly RED_INTEGER: number;
  110026. readonly RG_INTEGER: number;
  110027. readonly RGB_INTEGER: number;
  110028. readonly RGBA_INTEGER: number;
  110029. readonly R8_SNORM: number;
  110030. readonly RG8_SNORM: number;
  110031. readonly RGB8_SNORM: number;
  110032. readonly RGBA8_SNORM: number;
  110033. readonly R8I: number;
  110034. readonly RG8I: number;
  110035. readonly RGB8I: number;
  110036. readonly RGBA8I: number;
  110037. readonly R8UI: number;
  110038. readonly RG8UI: number;
  110039. readonly RGB8UI: number;
  110040. readonly RGBA8UI: number;
  110041. readonly R16I: number;
  110042. readonly RG16I: number;
  110043. readonly RGB16I: number;
  110044. readonly RGBA16I: number;
  110045. readonly R16UI: number;
  110046. readonly RG16UI: number;
  110047. readonly RGB16UI: number;
  110048. readonly RGBA16UI: number;
  110049. readonly R32I: number;
  110050. readonly RG32I: number;
  110051. readonly RGB32I: number;
  110052. readonly RGBA32I: number;
  110053. readonly R32UI: number;
  110054. readonly RG32UI: number;
  110055. readonly RGB32UI: number;
  110056. readonly RGBA32UI: number;
  110057. readonly RGB10_A2UI: number;
  110058. readonly R11F_G11F_B10F: number;
  110059. readonly RGB9_E5: number;
  110060. readonly RGB10_A2: number;
  110061. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  110062. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  110063. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  110064. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  110065. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  110066. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  110067. 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;
  110068. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  110069. readonly TRANSFORM_FEEDBACK: number;
  110070. readonly INTERLEAVED_ATTRIBS: number;
  110071. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  110072. createTransformFeedback(): WebGLTransformFeedback;
  110073. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  110074. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  110075. beginTransformFeedback(primitiveMode: number): void;
  110076. endTransformFeedback(): void;
  110077. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  110078. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110079. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110080. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110081. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  110082. }
  110083. interface ImageBitmap {
  110084. readonly width: number;
  110085. readonly height: number;
  110086. close(): void;
  110087. }
  110088. interface WebGLQuery extends WebGLObject {
  110089. }
  110090. declare var WebGLQuery: {
  110091. prototype: WebGLQuery;
  110092. new(): WebGLQuery;
  110093. };
  110094. interface WebGLSampler extends WebGLObject {
  110095. }
  110096. declare var WebGLSampler: {
  110097. prototype: WebGLSampler;
  110098. new(): WebGLSampler;
  110099. };
  110100. interface WebGLSync extends WebGLObject {
  110101. }
  110102. declare var WebGLSync: {
  110103. prototype: WebGLSync;
  110104. new(): WebGLSync;
  110105. };
  110106. interface WebGLTransformFeedback extends WebGLObject {
  110107. }
  110108. declare var WebGLTransformFeedback: {
  110109. prototype: WebGLTransformFeedback;
  110110. new(): WebGLTransformFeedback;
  110111. };
  110112. interface WebGLVertexArrayObject extends WebGLObject {
  110113. }
  110114. declare var WebGLVertexArrayObject: {
  110115. prototype: WebGLVertexArrayObject;
  110116. new(): WebGLVertexArrayObject;
  110117. };
  110118. // Type definitions for WebVR API
  110119. // Project: https://w3c.github.io/webvr/
  110120. // Definitions by: six a <https://github.com/lostfictions>
  110121. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110122. interface VRDisplay extends EventTarget {
  110123. /**
  110124. * Dictionary of capabilities describing the VRDisplay.
  110125. */
  110126. readonly capabilities: VRDisplayCapabilities;
  110127. /**
  110128. * z-depth defining the far plane of the eye view frustum
  110129. * enables mapping of values in the render target depth
  110130. * attachment to scene coordinates. Initially set to 10000.0.
  110131. */
  110132. depthFar: number;
  110133. /**
  110134. * z-depth defining the near plane of the eye view frustum
  110135. * enables mapping of values in the render target depth
  110136. * attachment to scene coordinates. Initially set to 0.01.
  110137. */
  110138. depthNear: number;
  110139. /**
  110140. * An identifier for this distinct VRDisplay. Used as an
  110141. * association point in the Gamepad API.
  110142. */
  110143. readonly displayId: number;
  110144. /**
  110145. * A display name, a user-readable name identifying it.
  110146. */
  110147. readonly displayName: string;
  110148. readonly isConnected: boolean;
  110149. readonly isPresenting: boolean;
  110150. /**
  110151. * If this VRDisplay supports room-scale experiences, the optional
  110152. * stage attribute contains details on the room-scale parameters.
  110153. */
  110154. readonly stageParameters: VRStageParameters | null;
  110155. /**
  110156. * Passing the value returned by `requestAnimationFrame` to
  110157. * `cancelAnimationFrame` will unregister the callback.
  110158. * @param handle Define the hanle of the request to cancel
  110159. */
  110160. cancelAnimationFrame(handle: number): void;
  110161. /**
  110162. * Stops presenting to the VRDisplay.
  110163. * @returns a promise to know when it stopped
  110164. */
  110165. exitPresent(): Promise<void>;
  110166. /**
  110167. * Return the current VREyeParameters for the given eye.
  110168. * @param whichEye Define the eye we want the parameter for
  110169. * @returns the eye parameters
  110170. */
  110171. getEyeParameters(whichEye: string): VREyeParameters;
  110172. /**
  110173. * Populates the passed VRFrameData with the information required to render
  110174. * the current frame.
  110175. * @param frameData Define the data structure to populate
  110176. * @returns true if ok otherwise false
  110177. */
  110178. getFrameData(frameData: VRFrameData): boolean;
  110179. /**
  110180. * Get the layers currently being presented.
  110181. * @returns the list of VR layers
  110182. */
  110183. getLayers(): VRLayer[];
  110184. /**
  110185. * Return a VRPose containing the future predicted pose of the VRDisplay
  110186. * when the current frame will be presented. The value returned will not
  110187. * change until JavaScript has returned control to the browser.
  110188. *
  110189. * The VRPose will contain the position, orientation, velocity,
  110190. * and acceleration of each of these properties.
  110191. * @returns the pose object
  110192. */
  110193. getPose(): VRPose;
  110194. /**
  110195. * Return the current instantaneous pose of the VRDisplay, with no
  110196. * prediction applied.
  110197. * @returns the current instantaneous pose
  110198. */
  110199. getImmediatePose(): VRPose;
  110200. /**
  110201. * The callback passed to `requestAnimationFrame` will be called
  110202. * any time a new frame should be rendered. When the VRDisplay is
  110203. * presenting the callback will be called at the native refresh
  110204. * rate of the HMD. When not presenting this function acts
  110205. * identically to how window.requestAnimationFrame acts. Content should
  110206. * make no assumptions of frame rate or vsync behavior as the HMD runs
  110207. * asynchronously from other displays and at differing refresh rates.
  110208. * @param callback Define the eaction to run next frame
  110209. * @returns the request handle it
  110210. */
  110211. requestAnimationFrame(callback: FrameRequestCallback): number;
  110212. /**
  110213. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  110214. * Repeat calls while already presenting will update the VRLayers being displayed.
  110215. * @param layers Define the list of layer to present
  110216. * @returns a promise to know when the request has been fulfilled
  110217. */
  110218. requestPresent(layers: VRLayer[]): Promise<void>;
  110219. /**
  110220. * Reset the pose for this display, treating its current position and
  110221. * orientation as the "origin/zero" values. VRPose.position,
  110222. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  110223. * updated when calling resetPose(). This should be called in only
  110224. * sitting-space experiences.
  110225. */
  110226. resetPose(): void;
  110227. /**
  110228. * The VRLayer provided to the VRDisplay will be captured and presented
  110229. * in the HMD. Calling this function has the same effect on the source
  110230. * canvas as any other operation that uses its source image, and canvases
  110231. * created without preserveDrawingBuffer set to true will be cleared.
  110232. * @param pose Define the pose to submit
  110233. */
  110234. submitFrame(pose?: VRPose): void;
  110235. }
  110236. declare var VRDisplay: {
  110237. prototype: VRDisplay;
  110238. new(): VRDisplay;
  110239. };
  110240. interface VRLayer {
  110241. leftBounds?: number[] | Float32Array | null;
  110242. rightBounds?: number[] | Float32Array | null;
  110243. source?: HTMLCanvasElement | null;
  110244. }
  110245. interface VRDisplayCapabilities {
  110246. readonly canPresent: boolean;
  110247. readonly hasExternalDisplay: boolean;
  110248. readonly hasOrientation: boolean;
  110249. readonly hasPosition: boolean;
  110250. readonly maxLayers: number;
  110251. }
  110252. interface VREyeParameters {
  110253. /** @deprecated */
  110254. readonly fieldOfView: VRFieldOfView;
  110255. readonly offset: Float32Array;
  110256. readonly renderHeight: number;
  110257. readonly renderWidth: number;
  110258. }
  110259. interface VRFieldOfView {
  110260. readonly downDegrees: number;
  110261. readonly leftDegrees: number;
  110262. readonly rightDegrees: number;
  110263. readonly upDegrees: number;
  110264. }
  110265. interface VRFrameData {
  110266. readonly leftProjectionMatrix: Float32Array;
  110267. readonly leftViewMatrix: Float32Array;
  110268. readonly pose: VRPose;
  110269. readonly rightProjectionMatrix: Float32Array;
  110270. readonly rightViewMatrix: Float32Array;
  110271. readonly timestamp: number;
  110272. }
  110273. interface VRPose {
  110274. readonly angularAcceleration: Float32Array | null;
  110275. readonly angularVelocity: Float32Array | null;
  110276. readonly linearAcceleration: Float32Array | null;
  110277. readonly linearVelocity: Float32Array | null;
  110278. readonly orientation: Float32Array | null;
  110279. readonly position: Float32Array | null;
  110280. readonly timestamp: number;
  110281. }
  110282. interface VRStageParameters {
  110283. sittingToStandingTransform?: Float32Array;
  110284. sizeX?: number;
  110285. sizeY?: number;
  110286. }
  110287. interface Navigator {
  110288. getVRDisplays(): Promise<VRDisplay[]>;
  110289. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  110290. }
  110291. interface Window {
  110292. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  110293. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  110294. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  110295. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110296. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110297. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  110298. }
  110299. interface Gamepad {
  110300. readonly displayId: number;
  110301. }
  110302. interface XRDevice {
  110303. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  110304. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  110305. }
  110306. interface XRSession {
  110307. getInputSources(): Array<any>;
  110308. baseLayer: XRWebGLLayer;
  110309. requestFrameOfReference(type: string): Promise<void>;
  110310. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  110311. end(): Promise<void>;
  110312. requestAnimationFrame: Function;
  110313. addEventListener: Function;
  110314. }
  110315. interface XRSessionCreationOptions {
  110316. outputContext?: WebGLRenderingContext | null;
  110317. immersive?: boolean;
  110318. environmentIntegration?: boolean;
  110319. }
  110320. interface XRLayer {
  110321. getViewport: Function;
  110322. framebufferWidth: number;
  110323. framebufferHeight: number;
  110324. }
  110325. interface XRView {
  110326. projectionMatrix: Float32Array;
  110327. }
  110328. interface XRFrame {
  110329. getDevicePose: Function;
  110330. getInputPose: Function;
  110331. views: Array<XRView>;
  110332. baseLayer: XRLayer;
  110333. }
  110334. interface XRFrameOfReference {
  110335. }
  110336. interface XRWebGLLayer extends XRLayer {
  110337. framebuffer: WebGLFramebuffer;
  110338. }
  110339. declare var XRWebGLLayer: {
  110340. prototype: XRWebGLLayer;
  110341. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  110342. };